diff --git a/LittlePaimon/manager/bot_manager/__init__.py b/LittlePaimon/manager/bot_manager/__init__.py index 6379ef4..17e3901 100644 --- a/LittlePaimon/manager/bot_manager/__init__.py +++ b/LittlePaimon/manager/bot_manager/__init__.py @@ -28,7 +28,9 @@ __plugin_meta__ = PluginMetadata( async def _(event: MessageEvent): await update_cmd.send(f'{NICKNAME}开始执行git pull更新', at_sender=True) p = subprocess.run(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - await update_cmd.finish('更新结果:' + (p.stdout if p.returncode == 0 else p.stderr).decode('utf-8').replace('+', '').replace('-', '').strip(' ')) + results = (p.stdout if p.returncode == 0 else p.stderr).decode('utf-8').split('\n') + result_msg = ''.join(result.split('|')[0].strip(' ') + '\n' for result in results) + await update_cmd.finish(f'更新结果:{result_msg}') @reboot_cmd.handle() diff --git a/LittlePaimon/manager/plugin_manager/__init__.py b/LittlePaimon/manager/plugin_manager/__init__.py index 3e78b73..e4ab490 100644 --- a/LittlePaimon/manager/plugin_manager/__init__.py +++ b/LittlePaimon/manager/plugin_manager/__init__.py @@ -36,11 +36,12 @@ async def _(event: GroupMessageEvent, state: T_State, match: dict = RegexDict(), state['plugin'] = [] state['plugin_no_exist'] = [] for plugin in match['plugin'].strip().split(' '): - if plugin not in plugin_manager.data.keys() and plugin not in ['all', '全部']: - if module_name := list(filter(lambda x: plugin_manager.data[x].name == plugin, plugin_manager.data.keys())): - state['plugin'].append(module_name[0]) - else: - state['plugin_no_exist'].append(plugin) + if plugin in plugin_manager.data.keys() or plugin in ['all', '全部']: + state['plugin'].append(plugin) + elif module_name := list(filter(lambda x: plugin_manager.data[x].name == plugin, plugin_manager.data.keys())): + state['plugin'].append(module_name[0]) + else: + state['plugin_no_exist'].append(plugin) if not match['group'] or event.user_id not in SUPERUSERS: state['group'] = [event.group_id] else: @@ -57,11 +58,12 @@ async def _(event: PrivateMessageEvent, state: T_State, match: dict = RegexDict( state['plugin'] = [] state['plugin_no_exist'] = [] for plugin in match['plugin'].strip().split(' '): - if plugin not in plugin_manager.data.keys() and plugin not in ['all', '全部']: - if module_name := list(filter(lambda x: plugin_manager.data[x].name == plugin, plugin_manager.data.keys())): - state['plugin'].append(module_name[0]) - else: - state['plugin_no_exist'].append(plugin) + if plugin in plugin_manager.data.keys() or plugin in ['all', '全部']: + state['plugin'].append(plugin) + elif module_name := list(filter(lambda x: plugin_manager.data[x].name == plugin, plugin_manager.data.keys())): + state['plugin'].append(module_name[0]) + else: + state['plugin_no_exist'].append(plugin) state['group'] = [int(group) for group in match['group'].strip().split(' ')] if match['group'] else [] state['user'] = [int(user) for user in match['user'].strip().split(' ')] if match['user'] else [] @@ -74,7 +76,7 @@ async def _(state: T_State): del cache_help[state['session_id']] if not state['plugin'] and state['plugin_no_exist']: await manage_cmd.finish(f'没有叫{" ".join(state["plugin_no_exist"])}的插件') - extra_msg = f'但没有叫{" ".join(state["plugin_no_exist"])}的插件' if state['plugin_no_exist'] else '' + extra_msg = f',但没有叫{" ".join(state["plugin_no_exist"])}的插件。' if state['plugin_no_exist'] else '。' if state['group'] and not state['user']: for group_id in state['group']: if 'all' in state['plugin']: @@ -82,7 +84,7 @@ async def _(state: T_State): else: await asyncio.gather(*[PluginPermission.filter(name=plugin, session_id=group_id, session_type='group').update(status=state['bool']) for plugin in state['plugin']]) logger.info('插件管理器', f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}的插件{" ".join(state["plugin"])}使用权限') - await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}的插件{" ".join(state["plugin"])}使用权限,{extra_msg}') + await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}的插件{" ".join(state["plugin"])}使用权限{extra_msg}') elif state['user'] and not state['group']: for user_id in state['user']: if 'all' in state['plugin']: @@ -91,7 +93,7 @@ async def _(state: T_State): await asyncio.gather(*[PluginPermission.filter(name=plugin, session_id=user_id, session_type='user').update(status=state['bool']) for plugin in state['plugin']]) logger.info('插件管理器', f'已{"启用" if state["bool"] else "禁用"}用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限') - await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限,{extra_msg}') + await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限{extra_msg}') else: for group_id in state['group']: if 'all' in state['plugin']: @@ -104,7 +106,7 @@ async def _(state: T_State): await plugin.save() logger.info('插件管理器', f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}中用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限') - await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}中用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限,{extra_msg}') + await manage_cmd.finish(f'已{"启用" if state["bool"] else "禁用"}群{" ".join(map(str, state["group"]))}中用户{" ".join(map(str, state["user"]))}的插件{" ".join(state["plugin"])}使用权限{extra_msg}') @help_cmd.handle()