From 20bdc7de58203fcd9e852d13ffb9c8fb11509306 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Tue, 17 Jan 2023 12:54:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E5=AE=89=E8=A3=85=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/qqbot/command.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/qqbot/command.py b/pkg/qqbot/command.py index 04eba40..507856c 100644 --- a/pkg/qqbot/command.py +++ b/pkg/qqbot/command.py @@ -109,6 +109,7 @@ def plugin_operation(cmd, params, is_admin): # 更新所有插件 if is_admin: def closure(): + import pkg.utils.context updated = [] for key in plugin_list: plugin = plugin_list[key] @@ -117,10 +118,22 @@ def plugin_operation(cmd, params, is_admin): if success: updated.append(plugin['name']) + # 检查是否有requirements.txt + pkg.utils.context.get_qqbot_manager().notify_admin("正在安装依赖...") + for key in plugin_list: + plugin = plugin_list[key] + if os.path.exists("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt"): + logging.info("{}检测到requirements.txt,安装依赖".format(plugin['name'])) + import pkg.utils.pkgmgr + pkg.utils.pkgmgr.install_requirements("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt") + + import main + main.reset_logging() + pkg.utils.context.get_qqbot_manager().notify_admin("[bot]已更新插件: {}".format(", ".join(updated))) threading.Thread(target=closure).start() - reply = ["[bot]正在更新所有插件..."] + reply = ["[bot]正在更新所有插件,请勿重复发起..."] else: reply = ["[bot]err:权限不足"] elif params[0].startswith("http"):