Skip to content

Commit

Permalink
修复了私聊机器人频繁发送"无权限"的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoRabi committed Nov 6, 2022
1 parent 009da81 commit 888d10e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
32 changes: 15 additions & 17 deletions core/fun/admin_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,40 @@
@bot.on(FriendMessage)
async def addadmin(event: FriendMessage):
"""添加管理员"""
if event.sender.id == master:
msg = "".join(map(str, event.message_chain[Plain]))
m = re.match(
fr"^{commandpre}{commands_map['sys']['addadmin']}", msg.strip())
if m:
msg = "".join(map(str, event.message_chain[Plain]))
m = re.match(
fr"^{commandpre}{commands_map['sys']['addadmin']}", msg.strip())
if m:
if event.sender.id == master:
qqid = int(m.group(1))
if qqid not in admin:
admin.append(qqid)
write_file(content=config, path=r'./config/config.yml')
await messagechain_sender(event=event, msg=f"已将 {m.group(1)} 添加为机器人管理员")
else:
await messagechain_sender(event=event, msg=f"{m.group(1)} 已经是管理员了")

else:
await messagechain_sender(event=event, msg=await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True))

else:
await messagechain_sender(event=event, msg=await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True))
return


@bot.on(FriendMessage)
async def deladmin(event: FriendMessage):
"""删除管理员"""
if event.sender.id == master:
msg = "".join(map(str, event.message_chain[Plain]))
m = re.match(
fr"^{commandpre}{commands_map['sys']['deladmin']}", msg.strip())
if m:
msg = "".join(map(str, event.message_chain[Plain]))
m = re.match(
fr"^{commandpre}{commands_map['sys']['deladmin']}", msg.strip())
if m:
if event.sender.id == master:
qqid = int(m.group(1))
if qqid in admin:
admin.remove(qqid)
write_file(content=config, path=r'./config/config.yml')
return await messagechain_sender(event=event, msg=f"已将 {m.group(1)} 从机器人管理员中移出")
else:
return await messagechain_sender(event=event, msg=f"{m.group(1)} 不是再管理员了")
else:
await bot.send(event, await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True))
else:
await bot.send(event, await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True))
return


Expand Down Expand Up @@ -149,8 +147,8 @@ async def tell_to_master(event: GroupMessage):
msg = "".join(map(str, event.message_chain[Plain]))
m = re.match(
fr"^{commandpre}{commands_map['sys']['tell_master']}", msg.strip())
qqid = event.sender.id
if m:
qqid = event.sender.id
if qqid in _black_list:
return await bot.send(event, await messagechain_builder(text='你已被列入黑名单,禁止使用该功能'))
if master != 0:
Expand Down
3 changes: 3 additions & 0 deletions plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@

print('\n所有插件加载完毕')
logging.info('所有插件加载完毕')

# 'Else'

# from plugin.AlarmClock import *
# from plugin.AutoReply import *
# from plugin.BilibiliPlugin import *
# from plugin.draw_wife import *
# from plugin.ImgGenerator import *
# from plugin.LocalImageAutoSender import *
# from plugin.MajSoulInfo import *
# from plugin.paili_analysis import *
# from plugin.Petpet import *
# from plugin.Remake import *
# from plugin.RichiMahjongMatchControl import *
# from plugin.Setu import *
# from plugin.Tarot import *
# from plugin.TencentCloudAPI import *
Expand Down

0 comments on commit 888d10e

Please sign in to comment.