♻️ remove plugin namespace

This commit is contained in:
yanyongyu
2021-11-11 17:33:30 +08:00
parent 08f56db385
commit 2ccbc93e48
9 changed files with 210 additions and 204 deletions

View File

@ -2,9 +2,8 @@ from types import ModuleType
from dataclasses import field, dataclass
from typing import Set, Dict, Type, Optional
from nonebot.matcher import Matcher
from .export import Export
from nonebot.matcher import Matcher
plugins: Dict[str, "Plugin"] = {}
"""
@ -77,7 +76,7 @@ def get_loaded_plugins() -> Set[Plugin]:
def _new_plugin(fullname: str, module: ModuleType) -> Plugin:
_, name = fullname.rsplit(".", 1)
name = fullname.rsplit(".", 1)[-1] if "." in fullname else fullname
if name in plugins:
raise RuntimeError("Plugin already exists! Check your plugin name.")
plugin = Plugin(name, module, fullname)