|
@@ -0,0 +1,169 @@
|
|
1
|
+--[[
|
|
2
|
+Descripttion:第三方工具
|
|
3
|
+version:
|
|
4
|
+Author: Neo,Huang
|
|
5
|
+Date: 2023-11-19 21:20:05
|
|
6
|
+LastEditors: Neo,Huang
|
|
7
|
+LastEditTime: 2023-11-19 21:23:40
|
|
8
|
+--]]
|
|
9
|
+local const = require("const.const")
|
|
10
|
+local httpc = require("http.httpc")
|
|
11
|
+local md5 = require("md5")
|
|
12
|
+local code = require("code")
|
|
13
|
+
|
|
14
|
+local root = {}
|
|
15
|
+
|
|
16
|
+----------------------------------------
|
|
17
|
+-- 敏感词
|
|
18
|
+----------------------------------------
|
|
19
|
+-- 是否包含敏感词
|
|
20
|
+function root:is_sensitive(words)
|
|
21
|
+ if is_nil(words) then
|
|
22
|
+ return false
|
|
23
|
+ end
|
|
24
|
+ -- 过滤数字
|
|
25
|
+ local word = ""
|
|
26
|
+ for i = 1, string.len(words) do
|
|
27
|
+ local c = string.sub(words, i, i)
|
|
28
|
+ if not (c >= "0" and c <= "9") then
|
|
29
|
+ word = word .. c
|
|
30
|
+ end
|
|
31
|
+ end
|
|
32
|
+ set_log("is_sensitive words[%s] word[%s]", tostring(words), tostring(word))
|
|
33
|
+ if is_nil(word) then
|
|
34
|
+ return false
|
|
35
|
+ end
|
|
36
|
+
|
|
37
|
+ local host = skynet.getenv("server_3rd")
|
|
38
|
+ if is_empty(host) then
|
|
39
|
+ -- 不检查敏感词
|
|
40
|
+ return false
|
|
41
|
+ end
|
|
42
|
+ local url = "/sensitive/checkword?"
|
|
43
|
+ local body = string.format("word=%s", word)
|
|
44
|
+ local auth = md5.sumhexa(body .. const.SALT_MD5)
|
|
45
|
+ body = string.format("%s&sign=%s", body, auth)
|
|
46
|
+ local code, ret = httpc.get(host, url .. body)
|
|
47
|
+ if ret and string.match(ret, "false") then
|
|
48
|
+ return true
|
|
49
|
+ end
|
|
50
|
+ return false
|
|
51
|
+end
|
|
52
|
+
|
|
53
|
+----------------------------------------
|
|
54
|
+-- 实名认证
|
|
55
|
+----------------------------------------
|
|
56
|
+-- 检验账号
|
|
57
|
+function root:real_name_check(uid, channel, name, idNum)
|
|
58
|
+ log.info(
|
|
59
|
+ "real_name_check uid[%s] channel[%s] name[%s] idNum[%s]",
|
|
60
|
+ tostring(uid),
|
|
61
|
+ tostring(channel),
|
|
62
|
+ tostring(name),
|
|
63
|
+ tostring(idNum)
|
|
64
|
+ )
|
|
65
|
+ if uid == nil or channel == nil or name == nil or idNum == nil then
|
|
66
|
+ return -1
|
|
67
|
+ end
|
|
68
|
+ local host = skynet.getenv("server_3rd")
|
|
69
|
+ if is_nil(host) then
|
|
70
|
+ if IS_TEST then
|
|
71
|
+ return 0
|
|
72
|
+ end
|
|
73
|
+ return -1
|
|
74
|
+ end
|
|
75
|
+ local url =
|
|
76
|
+ string.format(
|
|
77
|
+ "/nppa/check_id?uid=%s&channel=%s&name=%s&idNum=%s",
|
|
78
|
+ tostring(uid),
|
|
79
|
+ tostring(channel),
|
|
80
|
+ tostring(name),
|
|
81
|
+ tostring(idNum)
|
|
82
|
+ )
|
|
83
|
+
|
|
84
|
+ local errCode, res = httpc.get(host, url)
|
|
85
|
+ log.info(
|
|
86
|
+ "real_name_check uid[%s] errCode[%s] res[%s] host[%s] url[%s]",
|
|
87
|
+ tostring(uid),
|
|
88
|
+ tostring(errCode),
|
|
89
|
+ tostring(res),
|
|
90
|
+ tostring(host),
|
|
91
|
+ tostring(url)
|
|
92
|
+ )
|
|
93
|
+ if errCode ~= 200 or is_nil(res) then
|
|
94
|
+ return -1
|
|
95
|
+ end
|
|
96
|
+ res = cjson_decode(res)
|
|
97
|
+ if is_nil(res) then
|
|
98
|
+ return -1
|
|
99
|
+ end
|
|
100
|
+ if res.code ~= 200 then
|
|
101
|
+ return -1
|
|
102
|
+ end
|
|
103
|
+ return res.status, res.pi
|
|
104
|
+end
|
|
105
|
+
|
|
106
|
+-- 获取账号校验结果
|
|
107
|
+function root:real_name_query_player_result(uid, channel)
|
|
108
|
+ if uid == nil or channel == nil then
|
|
109
|
+ return
|
|
110
|
+ end
|
|
111
|
+ local host = skynet.getenv("server_3rd")
|
|
112
|
+ if is_nil(host) then
|
|
113
|
+ return -1
|
|
114
|
+ end
|
|
115
|
+ local url = string.format("/nppa/query_id?uid=%s&channel=%s", tostring(uid), tostring(channel))
|
|
116
|
+
|
|
117
|
+ local errCode, res = httpc.get(host, url)
|
|
118
|
+ if code.is_not_ok(errCode) or is_nil(res) then
|
|
119
|
+ return -1
|
|
120
|
+ end
|
|
121
|
+ res = cjson_decode(res)
|
|
122
|
+ if is_nil(res) then
|
|
123
|
+ return -1
|
|
124
|
+ end
|
|
125
|
+ return res.status, res.pi
|
|
126
|
+end
|
|
127
|
+
|
|
128
|
+-- 玩家行为上报
|
|
129
|
+-- channel:渠道
|
|
130
|
+-- si:游戏内部会话标识
|
|
131
|
+-- bt:用户行为类型 0:下线 1:上线
|
|
132
|
+-- ot:行为发生时间戳
|
|
133
|
+-- ct:用户行为数据上报类型 0:已认证用户 2:游客
|
|
134
|
+-- di:游客模式设备标识
|
|
135
|
+-- pi:实名用户唯一标识
|
|
136
|
+function root:real_name_report_collect_login_and_out(channel, si, bt, ot, ct, di, pi)
|
|
137
|
+ log.info(
|
|
138
|
+ "real_name_report_collect_login_and_out channel[%s] si[%s] bt[%s]",
|
|
139
|
+ tostring(channel),
|
|
140
|
+ tostring(si),
|
|
141
|
+ tostring(bt)
|
|
142
|
+ )
|
|
143
|
+ local host = skynet.getenv("server_3rd")
|
|
144
|
+ if is_nil(host) then
|
|
145
|
+ return
|
|
146
|
+ end
|
|
147
|
+ local url =
|
|
148
|
+ string.format(
|
|
149
|
+ "/nppa/loginout?channel=%s&si=%s&bt=%s&ot=%s&ct=%s&di=%s&pi=%s",
|
|
150
|
+ tostring(channel),
|
|
151
|
+ tostring(si),
|
|
152
|
+ tostring(bt),
|
|
153
|
+ tostring(ot),
|
|
154
|
+ tostring(ct),
|
|
155
|
+ tostring(di),
|
|
156
|
+ tostring(pi)
|
|
157
|
+ )
|
|
158
|
+
|
|
159
|
+ local errCode, res = httpc.get(host, url)
|
|
160
|
+ log.info(
|
|
161
|
+ "real_name_report_collect_login_and_out host[%s] url[%s] errCode[%s] res[%s]",
|
|
162
|
+ tostring(host),
|
|
163
|
+ tostring(url),
|
|
164
|
+ tostring(errCode),
|
|
165
|
+ tostring(res)
|
|
166
|
+ )
|
|
167
|
+end
|
|
168
|
+
|
|
169
|
+return root
|