This repository has been archived by the owner on Nov 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
132 lines (111 loc) · 5.51 KB
/
api.py
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
import requests
class PostMsg:
def __init__(self, url, botqq):
self.url = url
self.botqq = botqq
def UserMsg(self, msg, to, picurl=0, picbase=0):
serverurl = self.url
botqq = self.botqq
url = serverurl + f'/v1/LuaApiCaller?qq={botqq}&funcname=SendMsg'
if picbase != 0 or picurl != 0:
payload = {"toUser": to, "sendToType": 1, "sendMsgType": "PicMsg",
"content": msg, "picUrl": picurl, "picBase64Buf": picbase} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
else:
payload = {"toUser": to, "sendToType": 1,
"sendMsgType": "TextMsg", "content": msg} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
def GroupMsg(self, msg, groupid, picbase=0, picurl=0):
serverurl = self.url
botqq = self.botqq
url = serverurl + f'/v1/LuaApiCaller?qq={botqq}&funcname=SendMsg'
if picbase != 0 or picurl != 0:
payload = {"toUser": groupid, "sendToType": 2, "sendMsgType": "PicMsg",
"content": msg, "picUrl": picurl, "picBase64Buf": picbase, } # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
else:
payload = {"toUser": groupid, "sendToType": 2,
"sendMsgType": "TextMsg", "content": msg} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
def SetShutUpUser(self, qq, time, groupid):
serverurl = self.url
botqq = self.botqq
url = serverurl + f'/v1/LuaApiCaller?qq={botqq}&funcname=OidbSvc.0x570_8'
payload = {"GroupID": groupid,
"ShutUpUserID": qq, "ShutTime": time} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, json=payload)
return (response.text)
def TemporaryMsg(self, msg, to, groupid, picbase=0, picurl=0):
serverurl = self.url
botqq = self.botqq
url = serverurl + f'/v1/LuaApiCaller?qq={botqq}&funcname=SendMsg'
if picbase != 0 or picurl != 0:
payload = {"toUser": to, "groupid": groupid, "sendToType": 3, "sendMsgType": "PicMsg",
"content": msg, "picUrl": picurl, "picBase64Buf": picbase} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
else:
payload = {"toUser": to, "groupid": groupid, "sendToType": 3,
"sendMsgType": "TextMsg", "content": msg} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request(
"POST", url, headers=headers, json=payload)
return (response.text)
def Announce(self, groupid, title, text, Pinned=False, Usewindow=False, tonewuser=False):
serverurl = self.url
botqq = self.botqq
url = serverurl + f'/v1/Group/Announce?qq={botqq}'
if Pinned == True:
Pinned = 1
else:
Pinned = 0
if Usewindow == True:
Type = 10
elif tonewuser == True:
Type = 20
else:
Type = 0
payload = {"GroupID": groupid, "Title": title,
"Text": text, "Pinned": Pinned, "Type": Type} # 拼接消息包
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, json=payload)
return (response.text)
def CheHui(self, GroupID, MsgSeq, MsgRandom):
serverurl = self.url
botqq = self.botqq
url = serverurl + \
f'/v1/LuaApiCaller?qq={botqq}&funcname=PbMessageSvc.PbMsgWithDraw'
payload = {"GroupID": GroupID,
"MsgSeq": MsgSeq, "MsgRandom": MsgRandom}
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, json=payload)
return (response.text)
# A = PostMsg('http://127.0.0.1:8888',2502515980)
# A.UserMsg(msg='这是Wordpress',to=3526436393,picbase=0,picurl=0)
def GetUserBilibili(QQ):
import sql
QQ = str(QQ)
tmp = sql.read(f'SELECT * FROM bilibili WHERE QQ="{QQ}"')
return ({"csrf": tmp[1], "cookie": tmp[2]})
'''
POST.GroupMsg(msg=要发的信息,groupid=群号,picurl=图片url,picbase=图片base) #发送群信息
POST.SetShutUpUser(qq=被禁言的QQ,time=时间,0为解除,groupid=群号) #群禁言
POST.UserMsg(msg=信息,to=发给谁,picurl=图片url,picbase=图片的base64) #发送私聊信息
POST.TemporaryMsg(msg=信息,to=发给谁,groupid=群号,picurl=图片url,picbase=图片的base64) #发送临时会话
POST.Announce(groupid=群号,title=公告标题,text="公告内容",Pinned=是否置顶(传入布尔参数),Usewindow=是否弹出(布尔),tonewuser="是否给新用户发送(布尔)")#发送群公告
'''