From 1795362bcd1df219a8d25ca953765674a524f4e7 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 13 May 2023 11:03:16 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/command/command.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/model/command/command.py b/model/command/command.py index 5f65d1321..642f97028 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -38,16 +38,19 @@ class Command: if plugins != None: # print(f"[DEBUG] 当前加载的插件:{plugins}") for p in plugins: - if p in self.cached_plugins: - module = self.cached_plugins[p] - else: - module = __import__("addons.plugins." + p + "." + p, fromlist=[p]) - self.cached_plugins[p] = module - cls = putil.get_classes(p, module) - obj = getattr(module, cls[0])() - hit, res = obj.run(message, role, platform, message_obj) - if hit: - return True, res + try: + if p in self.cached_plugins: + module = self.cached_plugins[p] + else: + module = __import__("addons.plugins." + p + "." + p, fromlist=[p]) + self.cached_plugins[p] = module + cls = putil.get_classes(p, module) + obj = getattr(module, cls[0])() + hit, res = obj.run(message, role, platform, message_obj) + if hit: + return True, res + except BaseException as e: + print(f"[Debug] 加载{p}插件出现问题,原因{str(e)}") except BaseException as e: print(f"[Debug] 插件加载出现问题,原因: {str(e)}\n已安装插件: {plugins}\n如果你没有相关装插件的想法, 请直接忽略此报错, 不影响其他功能的运行。")