33 lines
881 B
Python
33 lines
881 B
Python
from pathlib import Path
|
|
|
|
import nonebot
|
|
from loguru import logger
|
|
|
|
nonebot.init()
|
|
nonebot.load_plugins("konabot/plugins")
|
|
|
|
plugins = nonebot.get_loaded_plugins()
|
|
len_requires = len(
|
|
[
|
|
f
|
|
for f in (Path(__file__).parent.parent / "konabot" / "plugins").iterdir()
|
|
if (f.is_dir() and (f / "__init__.py").exists())
|
|
or ((not f.is_dir()) and f.suffix == ".py")
|
|
]
|
|
)
|
|
|
|
plugins = [p for p in plugins if p.module.__name__.startswith("konabot.plugins")]
|
|
|
|
logger.info(f"已经加载的插件数量 {len(plugins)}")
|
|
logger.info(f"期待加载的插件数量 {len_requires}")
|
|
|
|
assert len(plugins) == len_requires
|
|
|
|
# 测试数据库模块是否可以正确导入
|
|
try:
|
|
from konabot.common.database import DatabaseManager
|
|
logger.info("数据库模块导入成功")
|
|
except Exception as e:
|
|
logger.error(f"数据库模块导入失败: {e}")
|
|
raise
|