from nonebot.adapters.cqhttp import Bot, Event from nonebot.plugin import on_message import numpy as np import datetime op = ["123"] #白名单ops f = open("test.txt", "r",encoding='utf-8') data = f.readline() f.close() ops = eval(data) #记分 scores = np.load('scores.npy',allow_pickle=True).item() keys = ['QQ号','查分','记分','明细','穷举','清零','计分','op','deop'] #回复部分 reply = on_message(priority=100) @reply.handle() asyncdefreply_handle(bot: Bot, event: Event): try: #获取聊天内容user_msg user_msg = str(event.get_message()).strip() #获取发消息的人user,群号qun msg = str(event.get_session_id()) user = msg.split("_")[2] qun = msg.split("_")[1] now = datetime.datetime.now() #消息空格分割列表words user_msg.rstrip() words = user_msg.split(' ') globallen length = len(words) if words[0]=='QQ号'and words[1][1:6]=='CQ:at'and length==2 : await reply.finish(words[1][10:-1]) return if user_msg[0:2]=='查分'and length==2: if words[1][1:6]=='CQ:at': words[1]=words[1][10:-1] if words[1] in scores: await reply.finish(words[1]+' 的记分为 '+str(scores[words[1]][0])) return else: await reply.finish(words[1]+' 无记分记录') return if user in ops : if user_msg[0:2]=='记分'and length==4 : if words[2][1:6]=='CQ:at': words[2]=words[2][10:-1] if words[2] in scores: scores[words[2]][0]=scores[words[2]][0]+int(words[1]) scores[words[2]].append([now.strftime("%Y-%m-%d %H:%M:%S"),words[1],words[3]]) else: scores[words[2]]=[int(words[1]),[now.strftime("%Y-%m-%d %H:%M:%S"),words[1],words[3]]] np.save('scores.npy', scores) await reply.finish(words[2]+' 当前记分为 '+str(scores[words[2]][0])) return if user_msg[0:2]=='清零'and length==2 : if words[1][1:6]=='CQ:at': words[1]=words[1][10:-1] if words[1] in scores: del scores[words[1]] np.save('scores.npy', scores) await reply.finish(words[1]+' 记分已清空') return else: await reply.finish(words[1]+' 无记分记录') return if user_msg[0:2]=='明细'and length==2 : if words[1][1:6]=='CQ:at': words[1]=words[1][10:-1] if words[1] in scores: reason='总记分'+str(scores[words[1]][0])+':\n' for i inrange(1,len(scores[words[1]])): reason=reason+str(i)+'.'+scores[words[1]][i][0]+'\n 记分数:'+scores[words[1]][i][1]+'\n 理由:'+scores[words[1]][i][2]+'\n' await reply.finish(words[1]+' 记分明细如下:\n'+reason) return else: await reply.finish(words[1]+' 无记分记录') return if user_msg[0:2]=='穷举': await reply.finish('全部记录如下:'+str(scores)) return if words[0]=='op'and user in op and length==2: if words[1][1:6]=='CQ:at': words[1]=words[1][10:-1] if words[1] in ops: await reply.finish(words[1]+'已有权限') else : ops.append(words[1]) f = open("test.txt", "w",encoding='utf-8') f.write(str(ops)) f.close() await reply.finish(words[1]+'成功获得权限') return if words[0]=='deop'and user in op and length==2: if words[1][1:6]=='CQ:at': words[1]=words[1][10:-1] if words[1] in ops: ops.remove(words[1]) f = open("test.txt", "w",encoding='utf-8') f.write(str(ops)) f.close() await reply.finish(words[1]+'已被删除权限') else : await reply.finish(words[1]+'并没有权限') return if words[0] in keys and user in ops: await reply.finish('您输入的语法有误,如有问题请查看机器人说明书:http://triority.cc/2022/06/16/how-to-use-qqbot/') except KeyError: await reply.finish()
用于在QQ群中发送MC服务器rcon命令的插件
这个插件同样有带完善,如果无法连接至rcon服务端,可能导致进程一直卡在建立连接,同上,有待完善 作为一个好腐竹只需在QQ群中发送rcon name kill @e即可提高你的威望 import的rcon库在插件的代码下面
The domain name of this website has been changed to triority.cc(Using CDN via cloudflare, recommended) / www.triority.cc(Connecting directly, works better in Chinese mainland). Please contact me if you have any questions.