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

“ChatControl Pro/WIKI/规则”的版本间的差异

来自Minecraft插件百科
跳转至: 导航搜索
(创建页面,内容为“规则系统是ChatControl最有用的系统: 你可以设置基于正则表达式的过滤器来捕获消息. 规则基于运算符 (想 'match', 'then deny'这样…”)
 
第8行: 第8行:
  
 
== 制作有效的规则 ==
 
== 制作有效的规则 ==
以下示例为 "fuck" 的过滤器,它可以防止 <code>f.u.c.k</code> 甚至是 <code>fuuu-ck</code>. 使其匹配并捕获这类词语很简单.
+
以下示例为 "fuck" 的过滤器,它可以防止 <code>f.u.c.k</code> 甚至是 <code>fuuu-ck</code>. 使其匹配并捕获这类词语很简单.<br>
----Here is an example of a rule that catches 'jerk', even in forms like jeeerrk and so on.
+
[[file:ccp25.png]]<br>
 +
 
 
  <code>match \b(j+(\W|\d|_)*e+(\W|\d|_)*r+(\W|\d|_)*k+(\W|\d|_)*)
 
  <code>match \b(j+(\W|\d|_)*e+(\W|\d|_)*r+(\W|\d|_)*k+(\W|\d|_)*)
 
  handle as swear</code>
 
  handle as swear</code>
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 <code>handlers.yml</code> 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.
+
'match' 运算符保护了正则表达式来检测玩家的消息.如果匹配成功则应用规则. 下一个运算符, 'handle as',告诉程序执行“swear”部分中<code>handlers.yml</code>内所述的所有指令. 你可以手动给规则添加运算符,但是如果你想以同样的方式处理多调脏话的话,将指令存储在一个地方会更方便.
  
The example above matches the word 'jerk' even if its obfuscated like <code>jeeerk</code> or <code>j.e-r_k</code>, and it will be handled as a 'swear' (you can configure this in handlers.yml file).
+
以上示例匹配了单词 'jerk' ,即使该单词被混淆成<code>jeeerk</code><code>j.e-r_k</code>也都能检测到, 并且这条消息会被视为 'swear'处理 (你可以在handlers.yml 内配置这个).
  
 
== 禁止如 <code>sh*t</code> 和 <code>shi*t</code> 这样的单词==
 
== 禁止如 <code>sh*t</code> 和 <code>shi*t</code> 这样的单词==
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.
+
默认过滤器可以过滤如 shi*t, shi_t 和其他混淆形式的脏话, 但是过滤器无法捕获到中间的字母被替代的脏话.<br>
 +
 
 +
你可以在 https://regex101.com/ 检测你的正则表达式是否能够成功地屏蔽脏话
  
 
== 白名单/允许的链接或IP ==
 
== 白名单/允许的链接或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.  
+
想要忽略你的服务器的IP地址被捕获, 请打开 rules/rules.txt并在 71 和 85行使用 'ignore string' 运算符,示例如下图.  
 
+
<br>[[file:ccp26.png]]<br>
a) To whitelist an IP, locate the IP filter above and add the IP address literally as per the image above.
+
a) 想要给一个IP白名单, 找到IP过滤器并添加到如上图所示位置即可.
  
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"
+
b) 想要给一条指令白名单, 找到区域过滤器并用 | 添加指令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:
+
"tits" 的规则可能会捕获到如"but its"或相似的无辜的消息. 有两种方法来修复这个问题:
  
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):
+
a) 添加 \b 字符到匹配规则内. 这可以使规则只匹配没有空格的消息或是消息前无空格的消息 (需要把 \b 放在前面) 或是后面(\b 放到match的最后):
  
 
<code>match \btits</code>
 
<code>match \btits</code>
  
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.
+
这会匹配 "tits" 而不是 "but its".
  
b) Use "ignore string" operator. This is the best solution to allow certain words and won't make the rule easier to bypass:
+
b) 使用 "ignore string" 运算符. This is the best solution to allow certain words and won't make the rule easier to bypass:
 
  <code>match anal
 
  <code>match anal
 
  ignore string analog|an all</code>
 
  ignore string analog|an all</code>

2019年1月28日 (一) 18:46的版本

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

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

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

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

制作有效的规则

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

match \b(j+(\W|\d|_)*e+(\W|\d|_)*r+(\W|\d|_)*k+(\W|\d|_)*)
handle as swear
'match' 运算符保护了正则表达式来检测玩家的消息.如果匹配成功则应用规则. 下一个运算符, 'handle as',告诉程序执行“swear”部分中handlers.yml内所述的所有指令. 你可以手动给规则添加运算符,但是如果你想以同样的方式处理多调脏话的话,将指令存储在一个地方会更方便.

以上示例匹配了单词 'jerk' ,即使该单词被混淆成jeeerkj.e-r_k也都能检测到, 并且这条消息会被视为 'swear'处理 (你可以在handlers.yml 内配置这个).

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

默认过滤器可以过滤如 shi*t, shi_t 和其他混淆形式的脏话, 但是过滤器无法捕获到中间的字母被替代的脏话.

你可以在 https://regex101.com/ 检测你的正则表达式是否能够成功地屏蔽脏话

白名单/允许的链接或IP

想要忽略你的服务器的IP地址被捕获, 请打开 rules/rules.txt并在 71 和 85行使用 'ignore string' 运算符,示例如下图.
Ccp26.png
a) 想要给一个IP白名单, 找到IP过滤器并添加到如上图所示位置即可.

b) 想要给一条指令白名单, 找到区域过滤器并用 | 添加指令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"

白名单语法

如 "tits" 的规则可能会捕获到如"but its"或相似的无辜的消息. 有两种方法来修复这个问题:

a) 添加 \b 字符到匹配规则内. 这可以使规则只匹配没有空格的消息或是消息前无空格的消息 (需要把 \b 放在前面) 或是后面(把 \b 放到match的最后):

match \btits

这会匹配 "tits" 而不是 "but its".

b) 使用 "ignore string" 运算符. 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