string - 审查 lua 中的单词
问题描述
我目前正在为我的朋友制作一个不和谐的审查机器人,我想知道是否有任何高级脚本编写者可以帮助我,或者是否有更简单的方法来完成我的代码。
local BadWords = {
['poop']=true,
}
client:on('messageCreate', function(msg)
Msg = msg.content
local msgs = string.split(Msg,' ')
for i,v in pairs(msgs) do
if BadWords[v:lower()] then
msg:reply({
embed = {
fields = {
{name = "Bad Word",value=v,inline = true},
},
color = discordia.Color.fromRGB(114, 137, 218).value,
--footer = os.time(),
}
})
--msg:reply(('Blacklisted word: %s'):format(v))
end
end
--[[table.foreach(msgs,function(i,v)
if BadWords[i] or BadWords[v] then
msg:reply(('Blacklisted word: %s'):format(v))
end
end)--]]
end)
client:run(Settings.Token)
它没有任何问题,也不完整,但我的想法是拆分或连接它们分别发送的所有单词,变异成单词的所有版本(即farm,f4rm,type shit),然后检查BadWord 列表。
主要是我想知道是否有更有效的方法来做到这一点,或者我必须做我必须做的事情
解决方案
推荐阅读
- python - Python Tkinter 弹出窗口未显示
- c++ - 求两个数之间的质数问题
- python - 如何安装 pyscipopt 及其依赖项
- sapui5 - 不同的条形颜色取决于 SAPUI5 VizFrame 中的值
- javascript - 来自 CSS 的预加载器背景图像
- ruby - `.bundle` 目录应该添加到 CVS 中吗?
- ubuntu - 无法启动 minikube --driver=none :
- regex - RegExp 发现错误的标签
- sapui5 - 输入:getSelectedKey 不是函数
- sharepoint - 如何向 SharePoint 列表添加自动通知和报告功能?