fix several bugs

This commit is contained in:
yanyongyu
2020-08-24 17:59:36 +08:00
parent 599844d3ca
commit eaa9b98bd9
7 changed files with 53 additions and 22 deletions

View File

@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-
import re
import sys
import pkgutil
import importlib
from importlib.util import module_from_spec
from importlib._bootstrap import _load
from nonebot.log import logger
from nonebot.matcher import Matcher
@ -185,9 +186,12 @@ def load_plugins(*plugin_dir: str) -> Set[Plugin]:
if name.startswith("_"):
continue
spec = module_info.module_finder.find_spec(name)
if spec.name in sys.modules:
continue
try:
spec = module_info.module_finder.find_spec(name)
module = module_from_spec(spec)
module = _load(spec)
plugin = Plugin(name, module, _tmp_matchers.copy())
plugins[name] = plugin