🐛 优化插件加载逻辑,修复内置插件加载的问题,动态加载内置插件并增强对sys.path下包的支持

This commit is contained in:
远野千束(神羽) 2024-12-29 15:57:11 +08:00
parent fb428ffc19
commit 3003dfad55

View File

@ -128,12 +128,13 @@ async def _():
if config.marshoai_enable_plugins:
marshoai_plugin_dirs = config.marshoai_plugin_dirs # 外部插件目录列表
"""加载内置插件"""
marshoai_plugin_dirs.insert(
0, Path(__file__).parent / "plugins"
) # 预置插件目录
for p in os.listdir(Path(__file__).parent / "plugins"):
load_plugin(f"{__package__}.plugins.{p}")
"""加载指定目录插件"""
load_plugins(*marshoai_plugin_dirs)
"""加载sys.path下的包"""
"""加载sys.path下的包, 包括从pip安装的包"""
for package_name in config.marshoai_plugins:
load_plugin(package_name)
logger.info(