forked from daizihan233/HanBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
227 lines (217 loc) · 10.7 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
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
import random
import aiohttp
import asyncio
def send(msg, gid, uid=None):
async def is_at(msg, gid, uid):
async with aiohttp.ClientSession() as session:
async with session.ws_connect('ws://127.0.0.1:6700/api') as ws:
await ws.send_json({'action': 'send_group_msg', 'params': {
'group_id': gid, # 往这个群发条消息
'message': '[CQ:at,qq=' + str(uid) + ']' + msg # 消息内容
}})
data = await ws.receive_json()
return data
async def no_at(msg, gid):
async with aiohttp.ClientSession() as session:
async with session.ws_connect('ws://127.0.0.1:6700/api') as ws:
await ws.send_json({'action': 'send_group_msg', 'params': {
'group_id': gid, # 往这个群发条消息
'message': msg # 消息内容
}})
data = await ws.receive_json()
return data
if uid is not None:
asyncio.run(is_at(msg, gid, uid))
else:
asyncio.run(no_at(msg, gid))
def keyword(msg, uid, gid):
import requests
import json
if msg == '' or msg == ' ':
send('嘿!这里是菜单\n'
'[1] 咕咕咕\n'
'(部分群可用,无需@)\n'
'[2] 黑名单\n'
'语法1:@机器人 黑名单 @...(直接@)\n'
'语法2:@机器人 黑名单 ...(QQ号)\n'
'[3] 加群自动同意\n'
'(部分群可用,无需@,自动检测)\n'
'[4] 特定关键词复读\n'
'(无需@,一条消息必须只包含关键词)\n'
'支持的关键词(“ | ”分割):\n'
'e | 额 | 呃 | 。 | w | www | 114514 | 1145141919810 | [CQ:face,id=298] '
'| [CQ:face,id=277] | [CQ:face,id=178]\n'
'[5] 聊天\n'
'(必须@,不要加回复,尽量不要加表情,直接说内容)\n'
'使用青云客机器人API\n'
'[6] 祖安戳一戳 / 祖安我\n'
'当你戳一戳机器人或at机器人说“祖安我”的时候他会说一句祖安话\n'
'========\n'
'https://github.com/daizihan233/HanBot 这是这个机器人的代码,欢迎Star!',
gid, uid)
else:
if "admin set 咕咕咕 " in msg and (uid == 183713750 or uid == 2443818489):
with open('gugu.txt', 'w') as file:
file.write(str(int(msg.strip("admin set 咕咕咕 "))))
send('您可以咕 {0} 天了'.format(str(int(msg.strip("admin set 咕咕咕 ")))),
gid)
elif ("群文件" == msg or "病毒库" == msg) and gid == 764869658:
send(msg='\nCN-xzf:https://xzfyyds.lanzoui.com/\n'
'OS相关:b02omemwh\n'
'浏览器(不经常更新):b02ok1xof\n'
'病毒库:b02ojc61a\n'
'OS激活相关:b02ojcf0d\n'
'驱动相关:b02ojckud\n'
'远程控制:b02ojcr4j\n'
'杀菌相关:b02ojnape\n'
'技术资料:b02ojnaxc\n'
'其他:b02ojj7kh\n'
'工具支持:蓝奏云\n'
'PS:密码均为 666',
gid=gid, uid=uid)
elif "祖安我" in msg:
herbalist = [ # 祖安语录
'nmd再@我一下试试!',
'滚',
'哎wcnmlgbd鬼!',
'fuck you',
'哎我cnmd谁tmd叫你m的让你个sb@我的?!!!',
# 从这一行开始,均为 苏孝泽 提供
'gun,傻逼',
'你礼貌吗?',
'脑残',
'操你妈',
'艹',
'我日你先人',
'我他娘的谢谢你啊',
'我********************',
'你是来吃屎的吧',
'一路走好,SB',
'你是啥玩意',
'你妈补天',
'TMD',
'CAO',
'大雨治水',
'你没妈',
'你没妈',
'马牛逼刚吃屎,你个马怂逼',
'SB',
'你死的好惨啊',
'孝出强大',
'宁真是个大孝子啊',
'你好骚啊',
'骚年,你爷爷在这',
'试试就逝世',
'全场目光向我看齐,我宣布一件事:你是傻逼',
'傻逼一号SB的你准备趋势',
'我操你妈',
'我不是人,但你绝对是狗',
'人家走到女生面前是夸好帅,而你走过去,会被骂变态',
'你好甩啊', # 甩在南京话里指250
'去你妈',
'学校是我家,文明去你妈',
'学校是我家,文明靠大家',
'250',
'我屮艸芔茻你妈的'
]
send(random.choice(herbalist), gid)
elif "admin set 咕咕咕 " in msg and (uid != 183713750 and uid != 2443818489):
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}]'
'{2}'.format(gid, uid, '你不是机器人的开发者/管理,权限不足,无法完成此操作'))
elif ("黑名单" in msg) and ("[CQ:at,qq=" in msg):
f = str(str(msg).split(' ')[-1])[len('[CQ:at,qq='):-1]
fuck = open('fucklist', 'r').readlines()
for i in range(len(fuck)):
fuck[i] = fuck[i].strip('\n')
if f in fuck:
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, '{} 已在黑名单\n'
'(如果发现恶意添加请尽快联系HanTools删除)'.format(f)))
else:
if f != 183713750 and f != 898140027:
open('fucklist', 'a').write(f + '\n')
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, '已添加 {} 至黑名单\n'
'(如果发现恶意添加请尽快联系HanTools删除)'.format(f)))
elif "黑名单" in msg:
f = str(str(msg).split(' ')[-1])
fuck = open('fucklist', 'r').readlines()
open('fucklist', 'a').write(f + '\n')
if f in fuck:
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, '{} 已在黑名单\n'
'(如果发现恶意添加请尽快联系HanTools删除)'.format(f)))
else:
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, '已添加 {} 至黑名单\n'
'(如果发现恶意添加请尽快联系HanTools删除)'.format(f)))
elif gid == 623377914 and ('咕' in msg):
msg = str(msg).count('咕')
with open('gugu.txt', 'r') as file:
gu = int(file.readlines()[0])
gu = gu + msg
with open('gugu.txt', 'w') as file:
file.write(str(gu))
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=鸽子'
'{1}'.format(gid, '您可以咕 {0} 天了').format(gu))
elif gid == 623377914 and ('咕' in msg):
msg = str(msg).count('咕')
with open('gugu.txt', 'r') as file:
gu = int(file.readlines()[0])
gu = gu + msg
with open('gugu.txt', 'w') as file:
file.write(str(gu))
send('鸽子 {1}'.format(gid, '您可以咕 {0} 天了').format(gu), gid)
elif "e" == msg or "额" == msg or "呃" == msg or "。" == msg or "w" == msg or \
"www" == msg or msg == "114514" or msg == "1145141919810" or \
msg == '[CQ:face,id=298]' or msg == '[CQ:face,id=178]' or msg == '[CQ:face,id=277]' or \
msg == '?' or msg == '?' or msg == '草':
send(msg, gid)
elif gid == 623377914 and uid == 2443818489:
if msg == '吃了:)':
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message='
'{1}'.format(gid, ':)'))
elif msg == '没吃:(':
requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message='
'{1}'.format(gid, ':('))
elif msg == '粉丝监测':
re = requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, '您可以去找HanTools(183713750)接入机器人'))
print('request:', re)
else:
for i in range(999):
msg = str(msg).strip("[CQ:face,id=" + str(i) + "]")
a = requests.get("https://api.qingyunke.com/api.php?key=free&appid=0&msg=" + msg.replace("+", "加"))
a = json.loads(a.text)
print(a)
a = a['content'].replace("{br}", "\n").replace("菲菲", "我").replace("{face:1}", "[CQ:face,id=1]")
for i in range(999):
msg = str(a).replace('{face:' + str(i) + '}', "[CQ:face,id=" + str(i) + "]")
print('msg: {0}'.format(msg))
print('uid: {0}'.format(uid))
print('gid: {0}'.format(gid))
re = requests.get('http://127.0.0.1:5700/send_group_msg?'
'group_id={0}&'
'message=[CQ:at,qq={1}] '
'{2}'.format(gid, uid, a))
re = re.text
print('requests_get: {0}'.format(re))
print('send: {0}'.format(a))