聊天过滤🔗
简介 (Introduction)🔗
CMI 的聊天过滤功能允许服务器所有者更好地管理和审核其服务器内的内容。与命令读条和冷却分开,它将帮助检测命令刷屏、大写喊叫、聊天中的脏话等。
通过正则表达式和灵活的自定义,服务器所有者可以创建一个适合其社区和服务器设置的动态聊天过滤器。
自定义在 ~/plugins/CMI/Settings/ChatFilter.yml 文件中完成。它有几个部分。
- 启用/禁用聊天过滤功能。
- 在 ipBlock 中阻止广告。
- 阻止脏话(你可以添加很多)(不仅适用于脏话,你还可以阻止短语、政治性聊天或某些单词)。
- 通过白名单防止屏蔽某些域名。
- 阻止重复消息。
- 阻止滥用大写(带白名单,也会忽略玩家名)。
- 以及与 CMI 的聊天管理器(Chat Manager)的良好集成。
需求 (Requirements)🔗
要使聊天过滤工作,需要编辑 ~/plugins/CMI/Settings/ChatFilter.yml 文件并将顶部的 Enabled: 设置为 true。
推荐将 CMI 用作聊天管理器,但不是必需的。
命令 (Commands)🔗
此功能没有直接的命令。然而,值得注意的一点是,你可以运行你希望作用于触发聊天过滤的人的命令。你可以在 ~/plugins/CMI/Settings/ChatFilter.yml 文件中设置这些。与其自动封禁某人,不如考虑这些 CMI 功能:jail(监狱)、cuff(铐住)、mute(禁言)、ban(封禁)、temp ban(临时封禁)、kick(踢出)、mail(邮件)、clearchat(清屏),或来自其他插件的任何有效命令。
你可以使用专用命令。
权限 (Permissions)🔗
你可以将 inform 权限授予你的团队成员,也许还可以授予一些 bypass 权限给更高或特殊的组/等级。
cmi.chatfilter.bypass.[groupname] - 允许绕过特定的聊天过滤组
cmi.commandfilter.bypass - 允许绕过命令刷屏过滤器
cmi.chatfilter.capbypass - 允许绕过聊天大写过滤器
cmi.chatfilter.inform - 当有人违反聊天过滤规则时通知玩家
cmi.chatfilter.spambypass - 允许绕过聊天刷屏过滤器
占位符 (Placeholders)🔗
此功能没有占位符。然而,如果你使用 CMI 的警告(Warnings)功能,你可以使用 %cmi_user_warning_count% 和 %cmi_user_warning_points%。还有一些"间谍"占位符(允许你作为团队成员查看他们在刷屏什么)。
提示:RegEx(正则表达式)与测试🔗
正则表达式可能很难掌握。我们强烈建议先在开发环境中进行适当的测试。
有一些网站你可以用来构建自己的正则表达式:https://regexone.com/ 和 https://regex101.com/
还有一个由 Alax 制作的非官方(且不受支持)工具,你可以尝试使用:https://dkalaxdk.github.io/CMIRegexFilter/
启用或禁用聊天过滤功能🔗
如果你想开始过滤广告、脏话、重复消息、命令和/或大写滥用,则将下面的 Enabled 值从 false 改为 true 并配置好一切,之后你可以执行 /cmi reload。
使用 ipBlock 阻止广告🔗
使用 CMI,你可以防止玩家发布域名和 IP 地址。你可以启用/禁用 ipBlock。
你可以定义一个组并用它来防止你的团队成员或特殊组被阻止。要跟踪谁触发了 ipBlock,你可以记录到控制台。
# Defines filter group and defines required permission node to bypass this filter: cmi.chatfilter.bypass.[groupName]
Group: Advertising
# When set to true, each time player triggers filter, console will receive information about who triggered it, which filter and with what message
InformConsole: true
使用正则表达式,你可以微调玩家发布的域名和 IP 地址,并阻止它们。你也可以定义用什么来替换被捕获的单词。
# Regex expression to filter by. How to use regex https://regexone.com/
Regex:
- '[a-zA-Z0-9\-\.]+\s?(\.|dot|\(dot\)|-|;|:|,|_|\/)\s?([a-zA-Z]{2}|aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel)\b'
- \b[0-9]{1,3}(\.|dot|\(dot\)|-|;|:|,|(\W|\d|_)*\s)+[0-9]{1,3}(\.|dot|\(dot\)|-|;|:|,|(\W|\d|_)*\s)+[0-9]{1,3}(\.|dot|\(dot\)|-|;|:|,|(\W|\d|_)*\s)+[0-9]{1,3}\b
# With what we need to replace word, if not defined found expression will not be changed
ReplaceWith: ''
ipBlock 的下一部分将让你定义如何处理被阻止的消息。你可以设置它是否也检查私密消息,是将其从聊天中完全移除,还是每个人仍然看到消息。以及你可以定义如何通知工作人员。
# With what we need to replace word, if not defined found expression will not be changed
ReplaceWith: ''
# possible: none, others, all
# Where 'none' means everyone will receive this message
# 'others' means that sender will get message but not other players, this is usefull to prevent advertising and silently block it
# 'all' means that no one will receive sent message
BlockType: others
# When enabled rule will be applied to private messages
includePrivateMessages: true
# Players with cmi.chatfilter.inform permission will receive defined message when rule is broken
msgToStaff: '&4!&6[playerName] &4advertising with: &r[message]'
如果需要,你可以给 ipBlock 一个或多个命令,在某人消息被阻止时执行。你可以用它自动禁言或踢出某人。或者给他们发送 bossbar 或 actionbar 消息,或给版主和玩家都发送 /cmi mail 消息,也许把玩家关进监狱。你可以在这里使用专用命令、[senderName] 变量以及其他全局变量。下面是一些例子。
不运行命令:
# List of commands to perform when rule is broken. Use [senderName] to include message sender name. Supports global variables same as locale file
Commands: []
运行单个命令:
# List of commands to perform when rule is broken. Use [senderName] to include message sender name. Supports global variables same as locale file
Commands:
- cmi mail [senderName] Please refrain from Advertising, see /rules
运行多个命令:
# List of commands to perform when rule is broken. Use [senderName] to include message sender name. Supports global variables same as locale file
Commands:
- cmi mail [senderName] Please refrain from Advertising, see /rules
- cmi kick [senderName] Please refrain from Advertising, see /rules
- cmi note [senderName] add Broke rule Advertising
ipBlock 的最后一部分非常动态。除了 ipBlock 之外还列出了两个例子:swearing1、swearing2,你可以添加任意多你想要的数量。例如,如果你希望玩家不再说 bedwars 或 hypixel,或某个政治短语,你可以在这里为它们添加阻止部分。只需复制/粘贴一个并相应配置即可。你可以在每个部分添加多个正则表达式,或给每个单词一个自己的部分。允许某些单词得到警告,但例如当它是仇恨言论时自动封禁。
在黑名单上使用白名单🔗
如果你仍然希望你的成员通过链接帮助他们,让他们链接到你的 discord、论坛、youtube 频道等。或者允许某些域名如 twitter 和 twitch,但阻止其他所有内容。那么你可以使用正则表达式将它们添加到白名单中来做例外。提醒一下,你也可以给某些组一个聊天过滤绕过权限,用于所有内容或专门定义的组。
# List of regex filter to exlude from block list. Usefull if you want to block all ip/host address but want to allow usage of your own server.
WhiteList:
- \bgoogle.\s?([a-zA-Z]{2,4})\b
- \bspigotmc.\s?([a-zA-Z]{2,4})\b
防止玩家发送重复消息🔗
~/plugins/CMI/Settings/ChatFilter.yml 文件的第二部分是关于 DuplicatedMessagePrevention:你可以在那里防止玩家在短时间内发送相似的消息。你也可以启用它,并给组绕过权限。
# When set to true, plugin will prevent spamming of same or similar messages in short time range. Can be bypassed with cmi.chatfilter.spambypass permission
Use: true
以下选项允许你微调消息刷屏被捕获的速度:
# How much in percentage message is counted as same
Percentage: 80
# Defines how often in seconds you can send same/similar message
Interval: 5
# How many commands you can repeat before stopped for cooldown
MinAmount: 2
命令刷屏过滤器目前(仍然)在 ~/plugins/CMI/config.yml 中——它们几乎与消息刷屏过滤有相同的选项。搜索:CommandFilter:
过滤包含多个大写字母的聊天消息 (CAPS SPAM)🔗
~/plugins/CMI/Settings/ChatFilter.yml 的最后部分让你定义如何处理包含多个大写字符的聊天消息。你可以通过将过滤器设置为 true 来启用此功能。附注:玩家名将不会被计算在内。
# When nebaled we will try to prevent chat messages with multiple capitalized letters by defined criteria
# Can be bypassed with cmi.chatfilter.capbypass permission node
Filter: true
你可以微调什么会被视为大写刷屏。
# Defines amount of letters we can ignore
# For example ':DDD' would be made of 2 letters with 3 capitalized letters which would make it 75% capitalized
IgnoreUnder: 6
# Amount in percentage of capitalized letters we should not cross over.
# In example 'GOOD thing' would be 4 capitalized and 5 not, spaces gets ignored, whic makes it 44% capitalized and passes check
Percentage: 50
你也可以运行零个、一个或多个命令。在本文档前面我展示了例子。你可以将之应用到下面的选项:
你也可以为大写使用白名单,以帮助防止过滤器过于敏感,在只是快速说声 hello 或常用词时触发。
# List of messages, excluding color codes, player can use even if it 100% capitalized
WhiteList:
- AFAIK
- AFK
- BRB
- IMHO
- OMG
- ROFL
- ROFLMAO
- LQTM
- LSMH
- LMHO
当你完成配置 ~/plugins/CMI/Settings/ChatFilter.yml 后,你必须考虑给你玩家的权限。并且可选地,你可以使用 config.yml 中的命令读条(warmup)和冷却(cooldown)选项来进一步微调你希望玩家在你的服务器上"如何表现"。
(内容由AI生成,仅供参考)