-
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.
Simply navigate to your rules/ folder, open the rules file that you want to edit (rules.txt is for all game elements, whereas commands.txt only for / commands, chat.txt for chat etc.) and simply edit the file directly using a proper text editor. Each rule starts with "match" operator and ends with "then" operators. You can take a look at the rules that are already there, remove them if not needed or copy and paste them and modify them to your advantage.
Please see Variables page for a list of placeholders you can use. Please know that not all placeholders are available on all places within the rules files.
Rules should work fine for your non-English language and we even make it easier to catch swears by replacing accents so that á ä ô and others get replaced into regular a and o. If you want to disable this feature set Translate_Diacritical_Marks to false in settings.yml.
If you have issues see https://github.com/kangarko/ChatControl-Pro/wiki/Frequently-Asked-Questions#rules-dont-work-for-my-non-english-server---i-use-special-characters-but-they-are-not-matched
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).
By default, our filters like the one above already do block shi*t, shi_t and other obfuscated alternatives, but they do not catch the word when letters in the center are replaced. See my answer from a private PM below to fix that.
To allow your server's IP address or website, open rules/rules.txt and use the 'ignore string' operator as per lines 71 and 85, explained under the image.
a) To whitelist an IP, locate the IP filter above and add the IP address literally as per the image above.
b) To whitelist a dommand, locate the domain filter above and add the domain by adding | and the domain itself at the end of the 'ignore string' operator that is there already. If your domain is "craftblock.com", you would add it as "|craftblock.com"
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. To ignore multiple words, use the | letter as a separator (shown above, in that case we will ignore both "analog" and "an all").
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*
[...]
Below you will find a rule that denies all special, unicode characters. Those are misused to bypass filters. Please keep in mind that non-english languages might use them as well. You can past it directly to rules/rules.txt.
match [^\u0000-\u007F]+
then warn Unicode is prohibited
then deny
© 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