From 728902bfcf76ac352804ac3677006ee5cc6c5884 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Mon, 20 Feb 2023 13:19:05 +0800 Subject: [PATCH] =?UTF-8?q?:loud=5Fsound:=20Feature:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=8A=A0=E8=BD=BD=E6=97=A5=E5=BF=97=20(#1716?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot/plugin/manager.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nonebot/plugin/manager.py b/nonebot/plugin/manager.py index 572879cf..7fe86a38 100644 --- a/nonebot/plugin/manager.py +++ b/nonebot/plugin/manager.py @@ -148,14 +148,21 @@ class PluginManager: else: raise RuntimeError(f"Plugin not found: {name}! Check your plugin name") - logger.opt(colors=True).success( - f'Succeeded to import "{escape_tag(name)}"' - ) - if (plugin := getattr(module, "__plugin__", None)) is None: + if ( + plugin := getattr(module, "__plugin__", None) + ) is None or not isinstance(plugin, Plugin): raise RuntimeError( f"Module {module.__name__} is not loaded as a plugin! " "Make sure not to import it before loading." ) + logger.opt(colors=True).success( + f'Succeeded to load plugin "{escape_tag(plugin.name)}"' + + ( + f' from "{escape_tag(plugin.module_name)}"' + if plugin.module_name != plugin.name + else "" + ) + ) return plugin except Exception as e: logger.opt(colors=True, exception=e).error(