forked from SuperWaterGod/BFserver-Bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGroup.py
437 lines (388 loc) · 25.8 KB
/
Group.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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# -*-coding:utf-8-*-
from graia.broadcast import Broadcast
from graia.application import GraiaMiraiApplication, Session
from graia.application.message.chain import MessageChain
from graia.application.friend import Friend
from graia.application.message.elements.internal import At, Plain, Image, Voice, Quote, Source
from graia.application.session import Session
from graia.broadcast.interrupt import InterruptControl
from graia.broadcast.interrupt.waiter import Waiter
from graia.application.event.messages import GroupMessage
from graia.application.event.mirai import BotInvitedJoinGroupRequestEvent
from graia.application.group import Group, Member, Optional
from graia.scheduler import timers
import graia.scheduler as scheduler
from graia.application.message.parser.kanata import Kanata
from graia.application.message.parser.signature import FullMatch, OptionalParam, RequireParam
import asyncio
import os
import re
import json
import time
import jieba
from pypinyin import lazy_pinyin
from match import AutoReply, AutoVoice
from battlefield import BFservers, Binding
from Botstatus import Botstatus
from XunProxy import aioRequest, PicDownload
from video import NewVideo
from Botstatus import Botstatus
from config import LoliconKey, SearchSetting
settings = json.load(open("./Settings.json", encoding='utf-8'))
Admin = settings["Admin"]
Bot = settings["Bot"]
ScheduleGroup = []
TestGroup = []
BlackId = set()
StartTime = time.time()
PerNumMessages = 0
AllNumMessages = 0
for i in settings["Group"]:
if i["function"]["Schedule"]:
ScheduleGroup.append(i["id"])
if i["function"]["test"]:
TestGroup.append(i["id"])
print("配置文件载入成功!")
BFUid = [18706000, 287122113, 526559715]
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop)
sche = scheduler.GraiaScheduler(loop=loop, broadcast=bcc)
inc = InterruptControl(bcc)
app = GraiaMiraiApplication(
broadcast=bcc,
connect_info=Session(
host="http://localhost:8080", # 填入 httpapi 服务运行的地址
authKey="INITKEYfiyhSQvQ", # 填入 authKey
account=Bot, # 你的机器人的 qq 号
websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作.
)
)
@sche.schedule(timers.every_custom_seconds(60))
async def Schedule_Task():
UseTime = time.strftime('%H:%M', time.localtime(time.time()))
if UseTime == "08:00":
for i in range(len(ScheduleGroup)):
await app.sendGroupMessage(ScheduleGroup[i], MessageChain.create([Image.fromLocalFile("./Menhera/121.png"), Plain("早早早(*´▽`)ノノ")]))
elif UseTime == "12:00":
for i in range(len(ScheduleGroup)):
await app.sendGroupMessage(ScheduleGroup[i], MessageChain.create([Image.fromLocalFile("./Menhera/44.jpg"), Plain("干饭时间到,开始干饭啦ヾ(^▽^*)))~")]))
elif UseTime == "23:00":
for i in range(len(ScheduleGroup)):
await app.sendGroupMessage(ScheduleGroup[i], MessageChain.create([Image.fromLocalFile("./Menhera/122.png"), Plain("米娜桑,晚安( ̄o ̄) . z Z")]))
VideoDetail = None
if VideoDetail is not None:
VideoMessage = "你关注的UP主:" + VideoDetail[2] + "发布了新的视频:\n" + VideoDetail[0] + "\n视频链接:https://www.bilibili.com/video/" + VideoDetail[1] + "\n快去给他一个三连吧o(*////▽////*)q"
for i in range(len(ScheduleGroup)):
await app.sendGroupMessage(ScheduleGroup[i], MessageChain.create([Image.fromNetworkAddress("http://" + VideoDetail[3]), Plain(VideoMessage)]))
global PerNumMessages
PerNumMessages = 0
pass
@bcc.receiver("GroupMessage")
async def battlefield(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
if SearchSetting(group.id)["function"]["battlefield"]:
MessageStr = message.asDisplay()
if any([MessageStr.startswith("/最近"), MessageStr.startswith("/战绩"), MessageStr.startswith("/服务器"), MessageStr.startswith("/武器"), MessageStr.startswith("/载具"),
MessageStr.startswith("/帮助"), MessageStr.startswith("/绑定")]) or \
any([MessageStr.startswith("/手榴弹"), MessageStr.startswith("/步枪"), MessageStr.startswith("/轻机枪"), MessageStr.startswith("/手枪"),
MessageStr.startswith("/半自动"), MessageStr.startswith("/霰弹枪"), MessageStr.startswith("/精英兵"), MessageStr.startswith("/近战"),
MessageStr.startswith("/冲锋枪"), MessageStr.startswith("/装备")]):
if member.id in BlackId:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("哼(╯▔皿▔)╯,不理你了!")]), quote=message[Source][0])
else:
if MessageStr.startswith("/最近"):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + await BFservers(member.id, MessageStr))]), quote=message[Source][0])
elif MessageStr.startswith("/战绩"):
MessageGet = await BFservers(member.id, MessageStr)
if MessageGet.startswith("头像"):
avatar = re.findall('头像:(.*)', MessageGet)[0]
MessageStr = re.findall('昵称:[\s\S]*', MessageGet)[0]
try:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromNetworkAddress(avatar), Plain("\n" + MessageStr)]),
quote=message[Source][0])
except:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + MessageGet)]), quote=message[Source][0])
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + MessageGet)]), quote=message[Source][0])
elif MessageStr.startswith("/服务器") or MessageStr.startswith("/武器") or MessageStr.startswith("/载具"):
if MessageStr == "/服务器":
MessageStr += SearchSetting(group.id)["name"]
MessageGet = await BFservers(member.id, MessageStr)
if MessageGet.startswith("./"):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromLocalFile(MessageGet)]), quote=message[Source][0])
await asyncio.sleep(30)
os.remove(MessageGet)
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + MessageGet)]), quote=message[Source][0])
elif MessageStr.startswith("/帮助"):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + await BFservers(member.id, MessageStr))]), quote=message[Source][0])
elif MessageStr.startswith("/绑定"):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain(Binding(member.id, MessageStr.replace("/绑定", "").replace(" ", "")))]),
quote=message[Source][0])
elif any([MessageStr.startswith("/手榴弹"), MessageStr.startswith("/步枪"), MessageStr.startswith("/轻机枪"), MessageStr.startswith("/手枪"),
MessageStr.startswith("/半自动"), MessageStr.startswith("/霰弹枪"), MessageStr.startswith("/精英兵"), MessageStr.startswith("/近战"),
MessageStr.startswith("/冲锋枪"), MessageStr.startswith("/装备")]):
MessageGet = await BFservers(member.id, MessageStr)
if MessageGet.startswith("./"):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromLocalFile(MessageGet)]), quote=message[Source][0])
await asyncio.sleep(30)
os.remove(MessageGet)
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("\n" + MessageGet)]), quote=message[Source][0])
@bcc.receiver("GroupMessage") # 收集群消息
async def message_log(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
global PerNumMessages, AllNumMessages
PerNumMessages = PerNumMessages + 1
AllNumMessages = AllNumMessages + 1
if SearchSetting(group.id)["function"]["Record"]:
if member.id not in SearchSetting(group.id)["blacklist"]:
messageStr = message.asDisplay()
name = "./log/" + str(group.id) + ".log"
try:
fp = open(name, 'a+', encoding='utf-8')
fp.write(messageStr)
except:
fp = open(name, 'w', encoding='utf-8')
fp.write(messageStr)
fp.close()
if member.id == Admin:
if messageStr == "/词云":
txt = open(name, "r", encoding='utf-8').read()
words = jieba.lcut(txt) # 使用精确模式对文本进行分词
counts = {} # 通过键值对的形式存储词语及其出现的次数
for word in words:
if len(word) == 1: # 单个词语不计算在内
continue
else:
counts[word] = counts.get(word, 0) + 1 # 遍历所有词语,每出现一次其对应的值加 1
items = list(counts.items())
items.sort(key=lambda x: x[1], reverse=True) # 根据词语出现的次数进行从大到小排序
for i in range(20):
word, count = items[i]
print("{0:<5}{1:>5}".format(word, count))
@bcc.receiver("GroupMessage") # 自动发送色图
async def pixiv_Group_listener(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
pinyinStr = ""
for i in range(len(lazy_pinyin(message.asDisplay()))):
pinyinStr += lazy_pinyin(message.asDisplay())[i]
if not pinyinStr.startswith("/"):
if pinyinStr.find("setu") >= 0:
if member.id in BlackId:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("哼(╯▔皿▔)╯,不理你了!")]))
else:
if SearchSetting(group.id)["function"]["setu"]:
try:
url = "https://api.lolicon.app/setu/?apikey=" + LoliconKey[0] # 1号api
data = json.loads(await aioRequest(url))
if data['code'] == 0:
messageId = await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromNetworkAddress(data['data'][0]['url'])]))
await asyncio.sleep(60)
await app.revokeMessage(messageId)
elif data['code'] == 429:
url = "https://api.lolicon.app/setu/?apikey=" + LoliconKey[1] # 2号api
data = json.loads(await aioRequest(url))
if data['code'] == 0:
messageId = await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromNetworkAddress(data['data'][0]['url'])]))
await asyncio.sleep(60)
await app.revokeMessage(messageId)
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("今天发的已经够多了,明天再来吧~")]))
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("今天发的已经够多了,明天再来吧~")]))
except:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("诶呀,发生一个未知的错误(ˉ▽ˉ;)...")]))
else:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("本群因管理要求已禁止使用色图功能╮(╯▽╰)╭")]))
@bcc.receiver("GroupMessage") # 自动回复群消息表情及语音
async def AutoReply_Group_listener(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
if SearchSetting(group.id)["function"]["AutoReply"]:
if member.id not in BlackId:
MessageGet = AutoReply(message.asDisplay())
if MessageGet.startswith("./Menhera/"):
await app.sendGroupMessage(group, MessageChain.create([Image.fromLocalFile(MessageGet)]))
elif MessageGet == "":
pass
else:
await app.sendGroupMessage(group, MessageChain.create([Plain(MessageGet)]))
MessageGet = AutoVoice(message.asDisplay())
if MessageGet.startswith("./voice/"):
await app.sendGroupMessage(group, MessageChain.create([Voice().fromLocalFile(MessageGet)]))
elif MessageGet == "":
pass
slogan = re.findall('(.*)\n(.*).jpg', message.asDisplay()) # 在线P图
if slogan:
upper = slogan[0][0]
lower = slogan[0][1]
await app.sendGroupMessage(group, MessageChain.create([Image.fromNetworkAddress("https://api.dihe.moe/5000choyen?upper=" + upper + "&lower=" + lower)]))
@bcc.receiver("GroupMessage") # 加入/移除黑名单
async def BlackId_Group_listener(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
if message.has(At):
AtLsit = []
for i in range(len(message.get(At))):
AtLsit.append(int(re.findall('target=(.*) ', str(message.get(At)[i]))[0]))
MessageGet = message.asDisplay().replace(" ", "")
for i in range(len(AtLsit)):
if AtLsit[i] == Bot:
pinyinStr = ""
for i in range(len(lazy_pinyin(MessageGet))):
pinyinStr += lazy_pinyin(MessageGet)[i]
if pinyinStr.find("shabi") >= 0 or pinyinStr.find("hanhan") >= 0 or pinyinStr.find("bendan") >= 0:
if pinyinStr.find("woshishabi") < 0:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("不理你了!")]), quote=message[Source][0])
BlackId.add(member.id)
elif MessageGet.find("对不起") >= 0 or MessageGet.find("我错了") >= 0 or MessageGet.find("抱歉") >= 0:
if member.id in BlackId:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromLocalFile("./Menhera/37.jpg"), Plain("想让我原谅你?请问谁是傻逼?")]))
@Waiter.create_using_function([GroupMessage])
async def Remove_Blacklist(event: GroupMessage, waiter_group: Group, waiter_member: Member, waiter_message: MessageChain):
if waiter_group.id == group.id and waiter_member.id == member.id and waiter_message.asDisplay().find("我是傻逼") >= 0:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromLocalFile("./Menhera/110.jpg"), Plain("哼,这还差不多┑( ̄Д  ̄)┍")]))
BlackId.remove(member.id)
await app.sendGroupMessage(group, MessageChain.create([Plain("这次就算了,下不为例哦╰( ̄ω ̄o)")]))
return event
try:
await asyncio.wait_for(inc.wait(Remove_Blacklist), timeout=30)
except asyncio.TimeoutError:
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Image.fromLocalFile("./Menhera/63.jpg"), Plain("\n不承认自己是傻逼就算了(*  ̄︿ ̄)")]))
pass
else:
await app.sendGroupMessage(group, MessageChain.create([Image.fromLocalFile("./Menhera/139.png")]), quote=message[Source][0])
else:
await app.sendGroupMessage(group, MessageChain.create([Plain("@我没有用哦~")]), quote=message[Source][0])
@bcc.receiver("MemberJoinEvent") # 新人加入群
async def Member_join(app: GraiaMiraiApplication, group: Group, member: Member):
await app.sendGroupMessage(group, MessageChain.create([At(member.id), Plain("欢迎加入" + str(group.name) + "\n请将群昵称改为游戏ID!")]))
@bcc.receiver("MemberLeaveEventKick") # 群员被T
async def Member_kick(app: GraiaMiraiApplication, group: Group, member: Member = "target"):
await app.sendGroupMessage(group, MessageChain.create([Plain(str(member.name) + "(" + str(member.id) + ")" + "因语言过激,被管理员移出了本群。")]))
@bcc.receiver("MemberLeaveEventQuit") # 群员离开
async def Member_quit(app: GraiaMiraiApplication, group: Group, member: Member):
await app.sendGroupMessage(group, MessageChain.create([Plain("一根丧失梦想的薯条" + str(member.name) + "(" + str(member.id) + ")" + "心灰意冷地离开了本群")]))
@bcc.receiver("BotMuteEvent") # 机器人被禁言
async def Bot_muted(app: GraiaMiraiApplication, group: Group, member: Member):
await app.sendFriendMessage(Admin, MessageChain.create([Plain("已被" + str(member.name) + "在" + str(group.name) + "禁言")]))
@bcc.receiver("BotUnmuteEvent") # 机器人解除禁言
async def Bot_unmuted(app: GraiaMiraiApplication, group: Group, member: Member):
await app.sendFriendMessage(Admin, MessageChain.create([Plain("已被" + str(member.name) + "在" + str(group.name) + "解除禁言")]))
@bcc.receiver(BotInvitedJoinGroupRequestEvent) # 机器人邀请进群
async def Bot_Join_Group(app: GraiaMiraiApplication, event: BotInvitedJoinGroupRequestEvent):
if event.supplicant == Admin:
await app.sendFriendMessage(Admin, MessageChain.create([Plain("已同意加入" + event.groupName + "(" + str(event.groupId) + ")")]))
await event.accept()
else:
await app.sendFriendMessage(Admin, MessageChain.create([Plain("已拒绝" + str(event.supplicant) + "加入" + event.groupName + "(" + str(event.groupId) + ")")]))
await event.reject("请联系作者QQ:1341283988")
@bcc.receiver("FriendMessage") # 自动回复好友消息及表情
async def AutoReply_Friend_listener(message: MessageChain, app: GraiaMiraiApplication, friend: Friend):
MessageGet = AutoReply(message.asDisplay())
if MessageGet.startswith("./Menhera/"):
await app.sendFriendMessage(friend, MessageChain.create([Image.fromLocalFile(MessageGet)]))
elif MessageGet == "":
pass
else:
await app.sendFriendMessage(friend, MessageChain.create([Plain(MessageGet)]))
@bcc.receiver("FriendMessage") # 好友TEST
async def Admin_Friend_Test(message: MessageChain, app: GraiaMiraiApplication, friend: Friend):
if friend.id == Admin:
slogan = re.findall('(.*)\n(.*).jpg', message.asDisplay())
if slogan:
upper = slogan[0][0]
lower = slogan[0][1]
await app.sendFriendMessage(friend, MessageChain.create([Image.fromNetworkAddress("https://api.dihe.moe/5000choyen?upper=" + upper + "&lower=" + lower)]))
@bcc.receiver("GroupMessage") # 群TEST
async def Admin_Group_Test(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member):
if group.id in TestGroup:
if message.asDisplay().startswith("/test_need_confirm"):
await app.sendGroupMessage(group, MessageChain.create([
At(member.id), Plain("发送 /confirm 以继续运行")
]))
@Waiter.create_using_function([GroupMessage])
async def waiter(
event: GroupMessage, waiter_group: Group,
waiter_member: Member, waiter_message: MessageChain
):
if all([
waiter_group.id == group.id,
waiter_member.id == member.id,
waiter_message.asDisplay().startswith("/confirm")
]):
await app.sendGroupMessage(group, MessageChain.create([Plain("开始执行.")]))
return event
# await asyncio.wait_for(waiter, 60)
try:
await asyncio.wait_for(inc.wait(waiter), timeout=10)
except asyncio.TimeoutError:
await app.sendGroupMessage(group, MessageChain.create([Plain("命令超时")]))
await app.sendGroupMessage(group, MessageChain.create([Plain("执行完毕.")]))
@bcc.receiver("GroupMessage", dispatchers=[Kanata([FullMatch("/"), RequireParam(name="command")])]) # 配置工具
async def group_settings(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member, command: MessageChain):
if member.id == Admin:
commands = command.asDisplay().split(" ")
# await app.sendGroupMessage(group, MessageChain.create([Plain("执行命令ing")]))
if commands[0] == "reload":
global settings, ScheduleGroup, TestGroup
settings = json.load(open("./Settings.json", encoding='utf-8'))
ScheduleGroup = []
TestGroup = []
for i in settings["Group"]:
if i["function"]["Schedule"]:
ScheduleGroup.append(i["id"])
if i["function"]["test"]:
TestGroup.append(i["id"])
await app.sendGroupMessage(group, MessageChain.create([Plain("重新载入配置文件成功")]))
elif commands[0] == "addgroup":
try:
setting = json.load(open("./Settings.json", encoding='utf-8'))
if SearchSetting(group.id) is None:
NullSetting = [{"name": "", "nickname": group.name, "id": group.id, "blacklist": [2267088317, 1753013648],
"function": {"AutoReply": True, "battlefield": True, "setu": False, "Schedule": True, "Record": True, "bilibili": False, "test": False}}]
setting["Group"].extend(NullSetting)
json.dump(setting, open("./Settings.json", "w", encoding='utf-8'), ensure_ascii=False, indent=4)
await app.sendGroupMessage(group, MessageChain.create([Plain("已成功配置本群")]))
else:
await app.sendGroupMessage(group, MessageChain.create([Plain("本群已有配置文件")]))
except:
await app.sendGroupMessage(group, MessageChain.create([Plain("诶呀,发生一个未知的错误(ˉ▽ˉ;)...")]))
elif commands[0] == "set":
try:
if commands[1] in ["AutoReply", "battlefield", "setu", "Schedule", "Record", "bilibili", "test"]:
setting = json.load(open("./Settings.json", encoding='utf-8'))
if commands[2] == "true":
for i in setting["Group"]:
if group.id == i["id"]:
i["function"][commands[1]] = True
json.dump(setting, open("./Settings.json", "w", encoding='utf-8'), ensure_ascii=False, indent=4)
await app.sendGroupMessage(group, MessageChain.create([Plain(f"{commands[1]}功能已开启")]))
elif commands[2] == "false":
for i in setting["Group"]:
if group.id == i["id"]:
i["function"][commands[1]] = False
json.dump(setting, open("./Settings.json", "w", encoding='utf-8'), ensure_ascii=False, indent=4)
await app.sendGroupMessage(group, MessageChain.create([Plain(f"{commands[1]}功能已关闭")]))
except:
await app.sendGroupMessage(group, MessageChain.create([Plain("参数错误")]))
elif commands[0] == "mod":
try:
if commands[1] in ["Msg"]:
setting = json.load(open("./Settings.json", encoding='utf-8'))
setting[commands[1]][commands[2]][commands[3]] = commands[4]
json.dump(setting, open("./Settings.json", "w", encoding='utf-8'), ensure_ascii=False, indent=4)
await app.sendGroupMessage(group, MessageChain.create([Plain(f"{commands[3]}信息已修改为{commands[4]}")]))
except:
await app.sendGroupMessage(group, MessageChain.create([Plain("参数错误")]))
elif commands[0] == "status":
try:
setting = json.load(open("./Settings.json", encoding='utf-8'))
counts = len(setting["Group"])
EndTime = int((time.time() - StartTime) / 60)
status = await Botstatus()
await app.sendGroupMessage(group, MessageChain.create([Plain(f"CPU占用率:{status[0]}%\n内存状态:{status[1]}\n"
f"数据接收:{status[2][0]}|{status[2][1]}\n"
f"数据发送:{status[2][2]}|{status[2][3]}\n"
f"目前已在{counts}个群内服务\n黑名单里共有{len(BlackId)}人\n"
f"Menhera酱已经运行了{EndTime}分钟\n"
f"累计收到{AllNumMessages}条消息\n最近一分钟内收到{PerNumMessages}条消息")]))
except:
await app.sendGroupMessage(group, MessageChain.create([Plain("参数错误")]))
else:
pass
app.launch_blocking()