From 731dedf155e0bc19bf4173efae16e81e7a9a32d6 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Wed, 15 Feb 2023 13:32:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20!plugin=E6=8C=87=E4=BB=A4=E6=8C=89?= =?UTF-8?q?=E7=85=A7=E9=A1=BA=E5=BA=8F=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/plugin/host.py | 6 ++++++ pkg/qqbot/command.py | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/plugin/host.py b/pkg/plugin/host.py index f431aa04..eb29e38e 100644 --- a/pkg/plugin/host.py +++ b/pkg/plugin/host.py @@ -54,6 +54,12 @@ def iter_plugins(): yield __plugins__[plugin_name] +def iter_plugins_name(): + """ 迭代插件名 """ + for plugin_name in __plugins_order__: + yield plugin_name + + __current_module_path__ = "" diff --git a/pkg/qqbot/command.py b/pkg/qqbot/command.py index 7989cbcd..66c83ed0 100644 --- a/pkg/qqbot/command.py +++ b/pkg/qqbot/command.py @@ -90,12 +90,15 @@ def plugin_operation(cmd, params, is_admin): plugin_list = plugin_host.__plugins__ if len(params) == 0: - reply_str = "[bot]所有插件({}):\n".format(len(plugin_list)) + reply_str = "[bot]所有插件({}):\n".format(len(plugin_host.__plugins__)) idx = 0 - for key in plugin_list: + for key in plugin_host.iter_plugins_name(): plugin = plugin_list[key] - reply_str += "#{} {}:\n{}\nv{}\n作者: {}\n".format((idx+1), plugin['name'], plugin['description'], - plugin['version'], plugin['author']) + reply_str += "\n#{} {} {}\n{}\nv{}\n作者: {}\n"\ + .format((idx+1), plugin['name'], + "[已禁用]" if not plugin['enabled'] else "", + plugin['description'], + plugin['version'], plugin['author']) if updater.is_repo("/".join(plugin['path'].split('/')[:-1])): remote_url = updater.get_remote_url("/".join(plugin['path'].split('/')[:-1]))