1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- --[[
- Descripttion:敏感词
- version:
- Author: Neo,Huang
- Date: 2023-11-19 21:20:05
- LastEditors: Neo,Huang
- LastEditTime: 2023-11-19 21:23:40
- --]]
- local const = require("const.const")
- local httpc = require("http.httpc")
- local md5 = require("md5")
- local root = {}
- -- 是否包含敏感词
- function root:is_sensitive(words)
- if is_nil(words) then
- return false
- end
- -- 过滤数字
- local word = ""
- for i = 1, string.len(words) do
- local c = string.sub(words, i, i)
- if not (c >= "0" and c <= "9") then
- word = word .. c
- end
- end
- set_log("is_sensitive words[%s] word[%s]", tostring(words), tostring(word))
- if is_nil(word) then
- return false
- end
- local host = skynet.getenv("server_3rd")
- if is_empty(host) then
- -- 不检查敏感词
- return false
- end
- local url = "/sensitive/checkword?"
- local body = string.format("word=%s", word)
- local auth = md5.sumhexa(body .. const.SALT_MD5)
- body = string.format("%s&sign=%s", body, auth)
- local code, ret = httpc.get(host, url .. body)
- if ret and string.match(ret, "false") then
- return true
- end
- return false
- end
- return root
|