• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

ChatControl Pro/WIKI/规则

来自Minecraft插件百科
Qsefthuopq留言 | 贡献2019年1月26日 (六) 10:33的版本 (创建页面,内容为“规则系统是ChatControl最有用的系统: 你可以设置基于正则表达式的过滤器来捕获消息. 规则基于运算符 (想 'match', 'then deny'这样…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转到导航 跳转到搜索

规则系统是ChatControl最有用的系统: 你可以设置基于正则表达式的过滤器来捕获消息.

规则基于运算符 (想 'match', 'then deny'这样的东西, 这些运算符决定编程内容 - 你可以在 rules.txt 的顶部看到所有的运算符). 它们由两部分组成:规则和处理器. 规则可以使用正则表达式来捕获一条消息, 处理器则为一组行为.

任何添加新规则 / 过滤器?

打开你的 rules/ 文件夹,打开你想要编辑的规则文件 (rules.txt 应用于游戏的所有元素, 而 commands.txt 只对指令有效, chat.txt 只对聊天有效等.)然后用合适的文本编辑器进行编辑即可. 每条规则开头都要有 "match" ,结尾都有 "then" 运算符. 你可以查看已存在的规则,复制粘帖它们并进行修改.

制作有效的规则

以下示例为 "fuck" 的过滤器,它可以防止 f.u.c.k 甚至是 fuuu-ck. 使其匹配并捕获这类词语很简单.


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).

禁止如 sh*tshi*t 这样的单词

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.

白名单/允许的链接或IP

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.

空格文字白名单

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*
[...]

防止想Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ 这样的 unicode字符

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