-
Notifications
You must be signed in to change notification settings - Fork 8
Rules
The rules are the most popular feature of ChatControl: They are user-defined filters that catch messages based on regular expressions.
The rules are based on operators (things like 'match', 'then deny', basically those, who tell the program what to do - they all are located in the header of rules.txt for your convenience). They consist of two parts: rules and handlers. Rules catch one single message using regular expressions, and handlers are group of actions a rule can be assigned to, avoiding the need of writing instructions twice or more.
Below is an example of a filter which blocks the word "fuck", and is also immune to some bypasses like f.u.c.k
and even fuuu-ck
. It is simple to configure it to match other words, too.
Here is an example of a rule that catches 'jerk', even in forms like jeeerrk and so on.
match \b(j+(\W|\d|_)*e+(\W|\d|_)*r+(\W|\d|_)*k+(\W|\d|_)*)
handle as swear
The 'match' operator has a regular expression that is evaluated against players' messages. If it matches, the rule applies. The latter operator, 'handle as', tells the program to do all the instructions stated in the 'swear' section in handlers.yml
file. You can write all the operators manually to the rule itself, if you want, but in case you wish to handle multiple swear words the same way, it becomes more convenient to store the instructions in one place.
The example above matches the word 'jerk' even if its obfuscated like jeeerk
or j.e-r_k
, and it will be handled as
a 'swear' (you can configure this in handlers.yml file).
Some rules such as "tits" may catch messages such as "but its" or similar. You can fix this in two ways:
a) Add the \b characters in the match rule. This makes the rule only match if the message does not have a whitespace either in front (if you put \b in front) or at the end (if you put \b as the last thing in the match):
match \btits
This will match "tits" but not "but its". Similarly, you can add also add \b at the end to make it only match when it ends with a whitespace. Be aware that such rules are easier to bypass.
b) Use "ignore string" operator. This is the best solution to allow certain words and won't make the rule easier to bypass:
match anal
ignore string analog|an all
This will prevent the two phrases 'analog' and 'an all' being blocked.
If you wish to block a message containing spaces inside ("f u c k", or "come to m y s e r v e r . c o m"), use the 'before strip' operator. Insert it under each rule you want to affect and all whitespaces will be removed:
match <your rule>
before strip \s*
[...]
© MineAcademy | Code Unique Minecraft Plugins & Servers In 20 Days
About
Free version
Basics
Understanding
- Channels
- Formatting
- Rules / Filters
- Handlers
- Groups
- JSON
- Discord
- Toggle ignoring swears
- Variables
- JavaScript Variables
Tweaking
Solving Issues
Miscellaneous