123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- --[[
- Descripttion:第三方工具
- version:
- Author: Neo,Huang
- Date: 2023-11-19 21:20:05
- LastEditors: Neo,Huang
- LastEditTime: 2023-11-19 21:23:40
- --]]
- local skynet = require("skynet")
- local const = require("const.const")
- local httpc = require("http.httpc")
- local md5 = require("md5")
- local code = require("code")
- 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
- log.info("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
- ----------------------------------------
- -- 实名认证
- ----------------------------------------
- -- 检验账号
- function root:real_name_check(uid, channel, name, idNum)
- log.info(
- "real_name_check uid[%s] channel[%s] name[%s] idNum[%s]",
- tostring(uid),
- tostring(channel),
- tostring(name),
- tostring(idNum)
- )
- if uid == nil or channel == nil or name == nil or idNum == nil then
- return -1
- end
- local host = skynet.getenv("server_3rd")
- if is_nil(host) then
- if IS_TEST then
- return 0
- end
- return -1
- end
- local url =
- string.format(
- "/nppa/check_id?uid=%s&channel=%s&name=%s&idNum=%s",
- tostring(uid),
- tostring(channel),
- tostring(name),
- tostring(idNum)
- )
- local errCode, res = httpc.get(host, url)
- log.info(
- "real_name_check uid[%s] errCode[%s] res[%s] host[%s] url[%s]",
- tostring(uid),
- tostring(errCode),
- tostring(res),
- tostring(host),
- tostring(url)
- )
- if errCode ~= 200 or is_nil(res) then
- return -1
- end
- res = cjson_decode(res)
- if is_nil(res) then
- return -1
- end
- if res.code ~= 200 then
- return -1
- end
- return res.status, res.pi
- end
- -- 获取账号校验结果
- function root:real_name_query_player_result(uid, channel)
- if uid == nil or channel == nil then
- return
- end
- local host = skynet.getenv("server_3rd")
- if is_nil(host) then
- return -1
- end
- local url = string.format("/nppa/query_id?uid=%s&channel=%s", tostring(uid), tostring(channel))
- local errCode, res = httpc.get(host, url)
- if code.is_not_ok(errCode) or is_nil(res) then
- return -1
- end
- res = cjson_decode(res)
- if is_nil(res) then
- return -1
- end
- return res.status, res.pi
- end
- -- 玩家行为上报
- -- channel:渠道
- -- si:游戏内部会话标识
- -- bt:用户行为类型 0:下线 1:上线
- -- ot:行为发生时间戳
- -- ct:用户行为数据上报类型 0:已认证用户 2:游客
- -- di:游客模式设备标识
- -- pi:实名用户唯一标识
- function root:real_name_report_collect_login_and_out(channel, si, bt, ot, ct, di, pi)
- log.info(
- "real_name_report_collect_login_and_out channel[%s] si[%s] bt[%s]",
- tostring(channel),
- tostring(si),
- tostring(bt)
- )
- local host = skynet.getenv("server_3rd")
- if is_nil(host) then
- return
- end
- local url =
- string.format(
- "/nppa/loginout?channel=%s&si=%s&bt=%s&ot=%s&ct=%s&di=%s&pi=%s",
- tostring(channel),
- tostring(si),
- tostring(bt),
- tostring(ot),
- tostring(ct),
- tostring(di),
- tostring(pi)
- )
- local errCode, res = httpc.get(host, url)
- log.info(
- "real_name_report_collect_login_and_out host[%s] url[%s] errCode[%s] res[%s]",
- tostring(host),
- tostring(url),
- tostring(errCode),
- tostring(res)
- )
- end
- return root
|