-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwx_hook.py
More file actions
331 lines (282 loc) · 8.43 KB
/
wx_hook.py
File metadata and controls
331 lines (282 loc) · 8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
"""
详细接口文档见:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/doc-1040329 密码:vHCAG7IM
"""
import os
from Fuction import request_data
wx_hook_url = ""
data_path = "./"
def get_state():
"""
获取微信状态 Q0000
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-27678639
"""
res = request_data('POST', url=wx_hook_url, json={
"type": "Q0000",
"data": {
}
})
return res
def send_content(send_user, content, data=None):
"""
发送文本消息 Q0001
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-27676096
"""
if not data:
data = {
"type": "Q0001",
"data": {
"wxid": send_user,
"msg": content
}
}
headers = {"content-type": "application/json"}
res = request_data('POST', url=wx_hook_url, json=data, headers=headers)
return res
def get_personal_information():
"""
获取个人信息 Q0003
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-27889656
"""
res = request_data('POST', url=wx_hook_url, json={
"type": "Q0003",
"data": {
}
})
return res
def obtain_user(xid):
"""
查询对象信息 Q0004
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-28615818
"""
res = request_data("POST", wx_hook_url, json={"type": "Q0004", "data": {"wxid": xid}})
return res
def get_friend_list():
"""
获取好友列表 Q0005
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-28612335
"""
res = request_data('POST', url=wx_hook_url, json={"type": "Q0005", "data": {"type": "1"}})
return res.json()['result']
def get_group_list():
"""
获取群列表 Q0006
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-28617101
"""
res = request_data('POST', url=wx_hook_url, json={"type": "Q0006", "data": {"type": "1"}})
return res.json()['result']
def get_official_account_list():
"""
获取公众号列表 Q0007
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-28617223
"""
res = request_data('POST', url=wx_hook_url, json={"type": "Q0007", "data": {"type": "1"}})
return res.json()['result']
def get_user_list_by_group(xid):
"""
获取指定群聊的成员 Q0008
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-28626229
"""
res = request_data('POST', url=wx_hook_url, json={"type": "Q0008", "data": {"wxid": xid}})
return res.json()['result']
def send_img(send_user, path):
"""
发送图片 Q0010
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29054153
"""
if 'http' in path:
res = request_data('GET', path)
path = os.path.join(data_path, '文件/temp.png')
with open(path, mode='wb') as f:
f.write(res.content)
data = {
"type": "Q0010",
"data": {
"wxid": send_user,
"path": path
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def send_file(send_user, path, _type=None):
"""
发送文件 Q0011
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29054299
"""
if _type:
res = request_data('GET', path)
path = os.path.join(data_path, '文件/temp.%s' % _type)
with open(path, mode='wb') as f:
f.write(res.content)
data = {
"type": "Q0011",
"data": {
"wxid": send_user,
"path": path
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def send_data(data):
"""
发送消息 Q0009、Q0012、Q0013、Q0014、Q00015
发送聊天记录、分享链接、小程序、音乐分享、xml
"""
res = request_data('POST', wx_hook_url, json=data)
return res
def confirm_receipt(xid, transferid):
"""
确定收款 Q0016
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29691607
"""
data = {
"type": "Q0016",
"data": {
"wxid": xid,
"transferid": transferid
}
}
res = request_data('post', wx_hook_url, json=data)
return res
def agree_with_friends(scene, v3, v4):
"""
同意好友 Q0017
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29722609
"""
data = {
"type": "Q0017",
"data": {
"scene": scene,
"v3": v3,
"v4": v4
}
}
request_data('POST', wx_hook_url, json=data)
def add_friends_by_v3(v3, content, scene=30):
"""
添加好友--v3 Q0018
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29739888
"""
data = {
"type": "Q0018",
"data": {
"v3": v3,
"content": content,
"scene": scene,
"type": 1
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def add_friends_by_wxid(wxid, content, scene=30):
"""
添加好友—-wxid Q0019
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29739919
"""
data = {
"type": "Q0019",
"data": {
"wxid": wxid,
"content": content,
"scene": scene
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def query_strangers(pq):
"""
查询陌生人 Q0020
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29739946
pd可以是QQ号或者手机号
"""
data = {
"type": "Q0020",
"data": {
"pq": pq
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def invite_group_chat(group_xid, xid, _type=1):
"""
邀请进群 Q0021
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29745022
"""
data = {
"type": "Q0021",
"data": {
"wxid": group_xid,
"objWxid": xid,
"type": _type
}
}
res = request_data('post', wx_hook_url, json=data)
return res
def del_friends(xid):
"""
删除好友 Q0022
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29745067
"""
data = {
"type": "Q0022",
"data": {
"wxid": xid
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def modify_remarks(xid, remark):
"""
修改备注 Q0023
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29745102
"""
data = {
"type": "Q0023",
"data": {
"wxid": xid,
"remark": remark
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def modify_group_remarks(xid, content):
"""
修改群聊备注 Q0024
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-29745126
"""
data = {
"type": "Q0024",
"data": {
"wxid": xid,
"nick": content
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def send_business_card(xid, _xml):
"""
发送名片 Q0025
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-30373859
"""
data = {
"type": "Q0025",
"data": {
"wxid": xid,
"xml": _xml
}
}
res = request_data('POST', wx_hook_url, json=data)
return res
def login():
"""
获取登录二维码 Q0026
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-30832986
"""
res = request_data('POST', wx_hook_url, json={"type": "Q0026", "data": {}})
return res
def accessing_pictures(name):
"""
访问图片
接口文档:https://apifox.com/apidoc/shared-af49a169-8b5c-4137-a5ea-723a10e8e794/api-34212216
"""
res = request_data("GET", wx_hook_url, params={'name': name})
return res