> For the complete documentation index, see [llms.txt](https://tchat.tect.host/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tchat.tect.host/anti-spam/configuration.md).

# Configuration

## General

```yml
modules:
  # Block similar letters and other types of spam in the chat.
  #
  # Anti spam module loaded from modules/antispam.yml
  anti-spam: true
```

* modules.anti-spam: Enable/disable the module

***

## Module

#### Action

```yml
# Action to execute when spam is detected.
# Available values:
# - BLOCK : cancel the message entirely.
# - CENSOR : replace uppercase letters with '*' (or the selected censor-char).
action: CENSOR
```

* BLOCK: Cancels the message.
* CENSOR: Replace the uppercase letters with the 'censor-char' character.

#### Censor-char

```yml
# Character used to replace matched letters (only relevant when action: CENSOR)
censor-char: "*"
```

* The censor character for the 'CENSOR' action.

#### Checks

```yaml
checks:

  # Repeated Characters
  # Example: "aaaaaaa", "!!!!!!!!"
  # Detects the same character repeated multiple times.
  repeated-chars:
    enabled: true
    threshold: 5

  # Repeated Pattern
  # Example: "hahahaha", "xdxdxdxd"
  # Detects short fragments repeated consecutively.
  repeated-pattern:
    enabled: true
    min-length: 2
    max-length: 4
    min-repeats: 3

  # Repeated Words
  # Example: "hello hello hello hello"
  # Detects the same word repeated multiple times.
  repeated-words:
    enabled: true
    threshold: 3

  # Character Diversity
  # Example: "asdkjfhqwe"
  # Detects long messages with very low character diversity.
  # Disabled by default to reduce false positives.
  char-diversity:
    enabled: false
    min-length: 12
    min-ratio: 0.30
```

* repeated-chars: Detects when the same character is repeated multiple times in a row.
  * enabled: Enable/disable this check.
  * threshold: Minimum number of consecutive repeated characters required to trigger detection.
* repeated-pattern: Detects when a short sequence of characters is repeated consecutively.
  * enabled: Enable/disable this check.
  * min-length: Minimum length of the repeated pattern.
  * max-length: Maximum length of the repeated pattern.
  * min-repeats: Minimum number of consecutive repetitions required before the message is flagged.
* repeated-words: Detects when the same word is repeated multiple times in succession.
  * enabled: Enable/disable this check.
  * threshold: Minimum number of consecutive repeated words required to trigger detection.
* char-diversity: Detects long messages that contain very few unique characters compared to their total length.
  * enabled: Enable/disable this check.
  * min-length: Minimum message length (excluding spaces) before the diversity check is applied.
  * min-ratio: Minimum required ratio of unique characters to total characters. Messages below this value are considered spam.

#### Whitelist

```yaml
# Words ignored by the Repeated Words check.
# Matching is case-insensitive.
whitelist:
  words:
    - "haha"
```

* List of words that are ignored by the repeated-words check.
