--聊天敏感字检测
local chat_dict
local chat_leaves ={}--构造字典树
local function Init_chat_dict()
chat_dict ={}
local record = Config_FraudWords
for i =1, #record do
local word = record[i]
local t = chat_dict
for j =1, #word do
local c = string.byte(word, j)if not t[c] then
t[c]={}
end
t = t[c]
end
chat_leaves[word]= true
end
end
--聊天敏感字匹配
function UIUtil:ShieldChat(msg)if not chat_dict then
Init_chat_dict()
end
--字体去空格
msg = string.trimAll(msg)--繁转简
msg = ToolGood.Words.WordsHelper.ToSimplifiedChinese(msg)for i =1, #msg do
local p = i
local q = p
local t = chat_dict
while true doif not t[string.byte(msg, q)] then
q = q -1break
end
t = t[string.byte(msg, q)]
q = q +1
end
if q >= p then
local str = string.sub(msg, p, q)if chat_leaves[str] then
return true
end
end
end
return false
end