mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 08:41:29 +00:00
🐛 fix plugin load fail
This commit is contained in:
@ -10,8 +10,8 @@ from typing import Set, Dict, List, Union, Iterable, Optional, Sequence
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.utils import escape_tag
|
||||
from .plugin import Plugin, _new_plugin
|
||||
from . import _managers, _current_plugin
|
||||
from .plugin import Plugin, _new_plugin, _confirm_plugin
|
||||
|
||||
|
||||
class PluginManager:
|
||||
@ -180,6 +180,8 @@ class PluginLoader(SourceFileLoader):
|
||||
# ) from e
|
||||
super().exec_module(module)
|
||||
|
||||
_confirm_plugin(plugin)
|
||||
|
||||
_current_plugin.reset(_plugin_token)
|
||||
return
|
||||
|
||||
|
@ -96,5 +96,10 @@ def _new_plugin(fullname: str, module: ModuleType, manager: "PluginManager") ->
|
||||
if name in plugins:
|
||||
raise RuntimeError("Plugin already exists! Check your plugin name.")
|
||||
plugin = Plugin(name, module, fullname, manager)
|
||||
plugins[name] = plugin
|
||||
return plugin
|
||||
|
||||
|
||||
def _confirm_plugin(plugin: Plugin) -> None:
|
||||
if plugin.name in plugins:
|
||||
raise RuntimeError("Plugin already exists! Check your plugin name.")
|
||||
plugins[plugin.name] = plugin
|
||||
|
Reference in New Issue
Block a user