def receive_events(ctx: dict): if ctx['CurrentPacket']['Data']['EventName'] == 'ON_EVENT_GROUP_REVOKE' and \ ctx['CurrentPacket']['Data']['EventData']['UserID'] != configuration.qq: # check plugin = PluginControl() if not plugin.check("防撤回", ctx['CurrentPacket']['Data']['EventData']['UserID'], ctx['CurrentPacket']['Data']['EventData']['GroupID']): return action = Action(configuration.qq) msg_set = ctx['CurrentPacket']['Data']['EventData'] msg_seq = msg_set['MsgSeq'] msg_group_id = msg_set['GroupID'] msg_revoke = find_group_msg_by_msg_seq(msg_seq, msg_group_id) if msg_revoke is None: logger.error('db.find returns null result') return if msg_revoke["msg_type"] == 'TextMsg': msg = "爷发现 " + msg_revoke["from_nickname"] + " 撤回了消息:\n\n" action.send_group_text_msg(msg_revoke["from_group_id"], msg + msg_revoke["content"]) if msg_revoke["msg_type"] == 'PicMsg': msg = "爷发现 " + msg_revoke["from_nickname"] + " 撤回了图片:\n\n" msg_content = msg_revoke["content"] if msg_revoke["content"] is not None else "" action.send_group_text_msg(msg_revoke["from_group_id"], msg + msg_content) pics = msg_revoke["pics"] for pic_id in pics: pic_content = find_img_by_id(pic_id) action.send_group_pic_msg( msg_revoke["from_group_id"], fileMd5=pic_content['FileMd5'], picBase64Buf=pic_content['ForwordBuf'] )
def admin_blacklist(flag, content, fromId): content = content.lstrip('.') if content.split(' ', 1)[0] == 'blacklist': command = content.split(' ') if len(command) == 3 and command[1] == "remove": plugins = PluginControl() if plugins.blacklist.delete(int(command[2]), fromId): return action_in_type(fromId, '用户 ' + command[2] + " 已成功从黑名单移除!", flag, True) else: return action_in_type(fromId, "黑名单移除失败!", flag, False) elif len(command) == 4 and command[1] == "add": plugins = PluginControl() try: account = int(command[2]) interval = int(command[3]) except Exception as e: return action_in_type(fromId, "非法命令", flag, False) if plugins.blacklist.add(account, fromId, interval, srartTime=int(time.time())): return action_in_type(fromId, '用户 ' + command[2] + " 已成功添加进黑名单!", flag, True) else: return action_in_type(fromId, "黑名单添加失败!", flag, False) else: return action_in_type(fromId, "命令格式错误", flag, False)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("百度", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "百度" and len(command) > 1: baidu_content = get_text(command[1]) url_new = "https:" + get_html_url("https://baike.baidu.com/search/word?word=" + command[1]) print("内容", baidu_content, baidu_content == "") if baidu_content == "": action.send_group_text_msg(ctx.FromGroupId, "爷没有搜索到结果!") else: if len(command) == 2: action.send_group_text_msg(ctx.FromGroupId, baidu_content[:] + url_new) elif len(command) == 3: try: i = int(command[2]) except: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!") if i > 0: action.send_group_text_msg(ctx.FromGroupId, baidu_content[:i] + "......\n\n" + url_new) else: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!") else: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
def admin_param(flag, content, fromId): content = content.lstrip('.') if content.split(' ', 1)[0] == 'param': command = content.split(' ') if len(command) == 4: # 允许的参数列表 with open("res/json/plugins_para.json", "r") as load_file: json_content = json.load(load_file) # 命令的插件、参数允许 if command[1] not in json_content: return action_in_type(fromId, "插件未开启", flag, False) if command[2] not in json_content[command[1]]: return action_in_type(fromId, "参数不存在", flag, False) key = "param." + command[2] para = {"$set": {key: command[3]}} plugins = PluginControl() result = plugins.update(command[1], fromId, para) if not result["ok"] or not result["nModified"]: return action_in_type(fromId, "参数更新失败", flag, False) return action_in_type(fromId, "参数更新成功", flag, True) else: return action_in_type(fromId, "命令格式错误", flag, False)
def receive_events(ctx: dict): if ctx['CurrentPacket']['Data']['EventName'] == "ON_EVENT_GROUP_JOIN" and\ ctx['CurrentPacket']['Data']['EventData']['UserID'] == configuration.qq: action = Action(configuration.qq) plugins = PluginControl() msg_group_id = ctx['CurrentPacket']['Data']['EventMsg']['FromUin'] msg = "爷来啦!\n\n默认开启插件:\n" for plugin_default in configuration.keywords_default: print(plugin_default) msg += plugins.add(plugin_default, msg_group_id)["content"] + '\n' msg.rstrip('\n') results = plugins.find_all(msg_group_id) content = "插件列表:\n" for key in plugins.keywords: flag = 0 for result in results: if key == result["plugin"]: flag = 1 is_opened = '(√) ' if flag else '(×) ' content += is_opened + key + "\n" msg += "\n" + content action.send_group_text_msg(msg_group_id, msg)
def receive_group_msg(ctx: GroupMsg): # check plugin = PluginControl() if not plugin.check("reply", ctx.FromUserId, ctx.FromGroupId): return # param param = plugin.find_one("reply", ctx.FromGroupId)["param"] p = float(param["p"]) q = float(param["q"]) delay_time = float(param["delay_time"]) if random.random() < p and ctx.FromUserId != configuration.qq: time.sleep(random.random() * delay_time) action = Action(configuration.qq) if ctx.MsgType == 'TextMsg' and not plugin.is_command( ctx.Content.split(' ', 1)[0], ctx.FromGroupId): action.send_group_text_msg(ctx.FromGroupId, replace_text_msg(ctx.Content, q)) elif ctx.MsgType == 'PicMsg': pic_msg = json.loads(ctx.Content) for pic_content in pic_msg['GroupPic']: action.send_group_pic_msg( ctx.FromGroupId, fileMd5=pic_content['FileMd5'], picBase64Buf=pic_content['ForwordBuf'])
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("setu", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "setu": if len(command) == 2: execute = command[1] else: # param param = plugin.find_one("setu", ctx.FromGroupId)["param"] execute = param["default"] id_url = "http://jinfans.top/setu/latest/view/random?type=" + execute id_image = get_html_text(id_url) id_json = json.loads(id_image) url = "http://jinfans.top/setu/latest/view/direct/" + id_json["_id"] action.send_group_pic_msg(ctx.FromGroupId, content=execute, picUrl=url)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content if command == "绝对音感测试": # check plugin = PluginControl() if not plugin.check("绝对音感测试", ctx.FromUserId, ctx.FromGroupId): return param = plugin.find_one("绝对音感测试", ctx.FromGroupId)["param"] sleep_time = int(param["time"]) low = int(param["low"]) high = int(param["high"]) num = random.randint(low, high) key = random_pitch(num) url = "http://jinfans.top/others/perfect_pitch/" + str( num) + ".mp3" print(url) action.send_group_voice_msg(ctx.FromGroupId, url) action.send_group_text_msg( ctx.FromGroupId, "绝对音感测试开始!" + str(sleep_time) + "s后公布答案") time.sleep(sleep_time) action.send_group_text_msg(ctx.FromGroupId, "正确答案是:" + key)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("latex", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ', 1) if command[0] == "latex" and len(command) > 1: latex_content = command[1] url = 'https://quicklatex.com/latex3.f' # param param = plugin.find_one("latex", ctx.FromGroupId)["param"] fsize = str(param["fsize"]) data = {"formula": transfer_spacing(latex_content), "fcolor": "000000", "fsize": fsize, "mode": "0", "out": "1", "remhost": "quicklatex.com"} response = post(url, data) content = response.text.split("\r\n") if content[0] == "0": pic_url = content[1].split(' ')[0] print(pic_url) action.send_group_pic_msg(ctx.FromGroupId, picUrl=pic_url, timeout=20) else: action.send_group_text_msg(ctx.FromGroupId, "无法识别公式!")
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: if ctx.MsgType == 'TextMsg': commands = ctx.Content.split(' ') if len(commands) == 2 and commands[0] == "plugins": plugins = PluginControl() action = Action(configuration.qq) # list命令 if commands[1] == "list": results = plugins.find_all(ctx.FromGroupId) content = "插件列表:\n" for key in plugins.keywords: flag = 0 for result in results: if key == result["plugin"]: flag = 1 is_opened = '(√) ' if flag else '(×) ' content += is_opened + key + "\n" action.send_group_text_msg(ctx.FromGroupId, content=content)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("python", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "runpython" and len(command) == 2: if not judge_name(command[1]): action.send_group_text_msg(ctx.FromGroupId, content="文件名非法") return res = runpy(command[1]) action.send_group_text_msg(ctx.FromGroupId, content=res) # 判断用\r还是\n char_r = ctx.Content.find('\r') char_n = ctx.Content.find('\n') if (char_r < char_n and char_r != -1) or char_n == -1: char = '\r' else: char = '\n' all_content = ctx.Content.split(char, 1) if len(all_content) == 2: command = all_content[0].split(' ') pycontent = all_content[1] if len(command) == 2 and command[0] == "newpython" and command[1][ -3:] == ".py": if not judge_name(command[1]): action.send_group_text_msg(ctx.FromGroupId, content="文件名非法") return if not judge_py(pycontent): action.send_group_text_msg(ctx.FromGroupId, " 文件包含不允许的字符串") return res = newpy(command[1], pycontent) if res: action.send_group_text_msg(ctx.FromGroupId, content=command[1] + " 创建成功") else: action.send_group_text_msg(ctx.FromGroupId, content="文件创建失败")
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId == configuration.qq: # check plugin = PluginControl() if not plugin.check("setu", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'PicMsg': labels = ["drawings", "hentai", "neutral", "p**n", "sexy"] for key in labels: if ctx.Content.find(key) != -1: time.sleep(15) action.revoke_msg(ctx.FromGroupId, ctx.MsgSeq, ctx.MsgRandom)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("echo", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': if ctx.Content[:5] == "echo ": command_test = ctx.Content[5:] action.send_group_text_msg(ctx.FromGroupId, content=command_test)
def receive_friend_msg(ctx: FriendMsg): action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "help": plugin = PluginControl() with open("res/json/help_friend.json", 'r') as load_file: help_content = json.load(load_file) if len(command) == 1: content = "帮助:\n" for key, value in help_content.items(): if key in plugin.keywords: content += '\n' + value + '\n' action.send_friend_text_msg(ctx.FromUin, content) elif len(command) == 2: content = "帮助:" for key, value in help_content.items(): if command[1] == key and key in plugin.keywords: content += value if not content == "帮助:": action.send_friend_text_msg(ctx.FromUin, content)
def admin_param_find(GroupId: int, page: int, page_size: int): plugins = PluginControl() list = plugins.find_all(GroupId) id = 1 for plugin in list: plugin.pop("_id") plugin["id"] = id id += 1 if len(list) == 0: return {"result": False, "content": {}} start = (page - 1) * page_size end = min(page * page_size, len(list)) return {"result": True, "content": list[start:end]}
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "help": # check plugin = PluginControl() if not plugin.check("help", ctx.FromUserId, ctx.FromGroupId): return with open("res/json/help_group.json", 'r') as load_file: help_content = json.load(load_file) if len(command) == 1: content = "帮助:\n" for key, value in help_content.items(): if key in plugin.keywords: content += '\n' + value + '\n' action.send_group_text_msg(ctx.FromGroupId, content) elif len(command) == 2 and command[1] == "admin": content = "管理员帮助:\n" with open("res/json/help_admin.json", 'r') as load_file: help_content = json.load(load_file) for key, value in help_content.items(): content += '\n' + value + '\n' action.send_group_text_msg(ctx.FromGroupId, content) elif len(command) == 2: content = "帮助:" for key, value in help_content.items(): if command[1] == key and key in plugin.keywords: content += value if not content == "帮助:": action.send_group_text_msg(ctx.FromGroupId, content)
def admin_refresh(bot, flag, content, fromId): content = content.lstrip('.') if content == 'refresh': if flag == 1: bot.refresh_plugins() plugins = PluginControl() plugins.refresh() action = Action(configuration.qq) action.send_group_text_msg(fromId, '插件已刷新') elif flag == 2: bot.refresh_plugins() action = Action(configuration.qq) action.send_friend_text_msg(fromId, '插件已刷新') else: bot.refresh_plugins() return {"result": True, "content": '插件已刷新'}
def admin_plugins_find(GroupId: int, page: int, page_size: int): plugins = PluginControl() list = plugins.find_all(GroupId) all_list = [] with open("res/json/plugins_para.json", 'r') as load_file: plugins_content = json.load(load_file) id = 1 keywords = plugins.keywords for keyword in keywords: flag = 0 for plugin in list: if plugin["plugin"] == keyword: plugin.pop("_id") plugin["id"] = id plugin["opened"] = True if "param" not in plugin: plugin["param"] = {} all_list.append(plugin) flag = 1 break if not flag: if plugins_content[keyword]: param = plugins_content[keyword] else: param = {} plugin = { "id": id, "plugin": keyword, "opened": False, "param": param, "from_group_id": GroupId } all_list.append(plugin) id += 1 if len(all_list) == 0: return {"result": False, "content": {}} start = (page - 1) * page_size end = min(page * page_size, len(all_list)) return {"result": True, "content": all_list[start:end]}
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "点歌": # check plugin = PluginControl() if not plugin.check("点歌", ctx.FromUserId, ctx.FromGroupId): return if len(command) == 2: content = xml_get_qq(command[1]) print(content) action.send_group_xml_msg(ctx.FromGroupId, content) if len(command) == 3: content = xml_get_qq(command[1], int(command[2])) print(content) action.send_group_xml_msg(ctx.FromGroupId, content)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: # check plugin = PluginControl() if not plugin.check("reply_at", ctx.FromUserId, ctx.FromGroupId): return action = Action(configuration.qq) if ctx.MsgType == 'AtMsg': all_content = json.loads(ctx.Content) content = all_content["Content"].split(" ", 1)[1] # 判断@的人 if not all_content["UserID"][0] == configuration.qq: return if content == "爬" or content == "爪巴": plugin.blacklist.add(ctx.FromUserId, ctx.FromGroupId, 10 * 60, srartTime=int(time.time())) action.send_group_text_msg(ctx.FromGroupId, content="爬什么爬,午夜凶铃啊!十分钟后再和我说话!", atUser=ctx.FromUserId) else: res_url = "https://api.ownthink.com/bot?appid=xiaosi&spoken=" + content res = json.loads(get_html_text(res_url)) if res["message"] == "error": action.send_group_text_msg(ctx.FromGroupId, "对话请求错误!") return elif not res["data"]["type"] == 5000: action.send_group_text_msg(ctx.FromGroupId, "对话返回错误!") return else: text = res["data"]["info"]["text"] action.send_group_text_msg(ctx.FromGroupId, text)
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': if ctx.Content[:3] == "计时 ": # check plugin = PluginControl() if not plugin.check("计时", ctx.FromUserId, ctx.FromGroupId): return command_time = ctx.Content.lstrip("计时 ") if time_shift(command_time): sleep_time = time_shift(command_time) if sleep_time > 4294967: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数:\n设置时间过长!") elif sleep_time < 0: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数:\n设置时间为负!") else: action.send_group_text_msg(ctx.FromGroupId, "爷开始计时啦!") time.sleep(sleep_time) msg = " 计时 " + command_time + " 结束!" action.send_group_text_msg(ctx.FromGroupId, atUser=ctx.FromUserId, content=msg) else: action.send_group_text_msg(ctx.FromGroupId, "非法时间格式!") if ctx.Content[:3] == "闹钟 ": # check plugin = PluginControl() if not plugin.check("闹钟", ctx.FromUserId, ctx.FromGroupId): return command = ctx.Content.lstrip("闹钟 ").split(' ', 1) time_array = alarm_shift(command[1]) if time_array: time_stamp = int(time.mktime(time_array)) sleep_time = time_stamp - int(time.time()) print(sleep_time) if sleep_time <= 0: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数:\n设定时间已过!") else: action.send_group_text_msg(ctx.FromGroupId, "爷设好闹钟啦!") time.sleep(sleep_time) msg = " 闹钟 " + f"""{command[0]}""" + " 到时间啦!" action.send_group_text_msg(ctx.FromGroupId, atUser=ctx.FromUserId, content=msg) else: action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数:\n非法时间格式!")
def admin_blacklist_find(GroupId: int, page: int, page_size: int): plugins = PluginControl() list = plugins.blacklist.find_all(GroupId) if len(list) == 0: return {"result": False, "content": {}} start = (page - 1) * page_size end = min(page * page_size, len(list)) id = 1 action = Action(configuration.qq) for member in list[start:end]: member.pop("_id") member["id"] = id id += 1 info = action.get_user_info(userID=member["user_id"])["data"] member["info"] = {} member["info"]['avatarUrl'] = info['avatarUrl'] member["info"]['nickname'] = info['nickname'] return {"result": True, "content": list[start:end]}
args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.INFO) else: logging.basicConfig(level=logging.ERROR) # bot类 bot = IOTBOT(configuration.qq, use_plugins=True, plugin_dir=args.plugin_dir, log_file_path=args.log_path) action = Action(bot) # 插件控制类 plugins = PluginControl() # admin命令接受 from admin.admin_else import admin_else_group, admin_else_friend bot.add_group_msg_receiver(admin_else_group) bot.add_friend_msg_receiver(admin_else_friend) from admin.admin_refresh import admin_refresh_group, admin_refresh_friend bot.add_group_msg_receiver(partial(admin_refresh_group, bot)) bot.add_friend_msg_receiver(partial(admin_refresh_friend, bot)) from admin.admin_test import admin_test_group, admin_test_friend
def pluginsNum(groupId): return len(PluginControl().find_all(groupId))
def receive_group_msg(ctx: GroupMsg): if ctx.FromUserId != configuration.qq: action = Action(configuration.qq) if ctx.MsgType == 'TextMsg': command = ctx.Content.split(' ') if command[0] == "说话" and len(command) >= 2: # check plugin = PluginControl() if not plugin.check("说话", ctx.FromUserId, ctx.FromGroupId): return text = command[1] # param param = plugin.find_one("说话", ctx.FromGroupId)["param"] voiceId = str(param["voiceId"]) speed = str(param["speed"]) volume = str(param["volume"]) audioType = str(param["audioType"]) for i in range(len(command) - 2): if command[i + 2][:8] == 'voiceId=': voiceId = command[i + 2].lstrip('voice=Id') elif command[i + 2][:6] == 'speed=': speed = command[i + 2].lstrip('speed=') elif command[i + 2][:7] == 'volume=': volume = command[i + 2].lstrip('volume=') elif command[i + 2][:10] == 'audioType=': audioType = command[i + 2].lstrip('audioType=') url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \ "&volume=" + volume + "&audioType=" + audioType + "&text=" + text action.send_group_voice_msg(ctx.FromGroupId, url) elif command[0] == "对话" and len(command) >= 2: # check plugin = PluginControl() if not plugin.check("对话", ctx.FromUserId, ctx.FromGroupId): return ask = command[1] # param param = plugin.find_one("对话", ctx.FromGroupId)["param"] voiceId = str(param["voiceId"]) speed = str(param["speed"]) volume = str(param["volume"]) audioType = str(param["audioType"]) for i in range(len(command) - 2): if command[i + 2][:8] == 'voiceId=': voiceId = command[i + 2].lstrip('voice=Id') elif command[i + 2][:6] == 'speed=': speed = command[i + 2].lstrip('speed=') elif command[i + 2][:7] == 'volume=': volume = command[i + 2].lstrip('volume=') elif command[i + 2][:10] == 'audioType=': audioType = command[i + 2].lstrip('audioType=') res_url = "https://api.ownthink.com/bot?appid=xiaosi&spoken=" + ask res = json.loads(get_html_text(res_url)) print(res) if res["message"] == "error": action.send_group_text_msg(ctx.FromGroupId, "对话请求错误!") return elif not res["data"]["type"] == 5000: action.send_group_text_msg(ctx.FromGroupId, "对话返回错误!") return else: text = res["data"]["info"]["text"] url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \ "&volume=" + volume + "&audioType=" + audioType + "&text=" + text action.send_group_voice_msg(ctx.FromGroupId, url)
def admin_plugins(flag, content, fromId): content = content.lstrip('.') if content.split(' ', 1)[0] == 'plugins': commands = content.split(' ') plugins = PluginControl() # open命令 if len(commands) == 3 and commands[1] == "open": if commands[2] in plugins.keywords: res = plugins.add(commands[2], fromId) return action_in_type(fromId, res["content"], flag, res["result"]) elif commands[2] == "all": false_set = plugins.add_all(fromId) if false_set == []: return action_in_type(fromId, "插件全部开启成功", flag, True) else: content = "插件 " for plugin in false_set: content += plugin + " , " content += "开启失败" return action_in_type(fromId, content, flag, False) else: return action_in_type(fromId, commands[2] + "不是可开启的插件", flag, False) # close命令 elif len(commands) == 3 and commands[1] == "close": if commands[2] == "all": false_set = plugins.delete_all(fromId) if false_set == []: return action_in_type(fromId, "插件全部关闭成功", flag, True) else: content = "插件 " for plugin in false_set: content += plugin + " , " content += "关闭失败" return action_in_type(fromId, content, flag, False) else: res = plugins.delete(commands[2], fromId) return action_in_type(fromId, res["content"], flag, res["result"]) # list命令 elif len(commands) == 2 and commands[1] == "list": results = plugins.find_all(fromId) content = "插件列表:\n" for key in plugins.keywords: new_flag = 0 for result in results: if key == result["plugin"]: new_flag = 1 is_opened = '(√) ' if new_flag else '(×) ' content += is_opened + key + "\n" return action_in_type(fromId, content, flag, False)