首页 > 解决方案 > 审查 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 列表。

主要是我想知道是否有更有效的方法来做到这一点,或者我必须做我必须做的事情

标签: stringluastring-matching

解决方案


推荐阅读