mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-04 19:17:36 +08:00
🐛 修复加载插件Bug
This commit is contained in:
parent
e76b1e86cc
commit
9e1c003743
1
.gitignore
vendored
1
.gitignore
vendored
@ -675,3 +675,4 @@ gsuid_core/plugins/*
|
|||||||
logs
|
logs
|
||||||
.pdm-python
|
.pdm-python
|
||||||
.pdm-build
|
.pdm-build
|
||||||
|
.VSCodeCounter
|
||||||
|
@ -87,6 +87,7 @@ class GsServer:
|
|||||||
sys.path.append(str(plugin_path.parents))
|
sys.path.append(str(plugin_path.parents))
|
||||||
if plugins_path.exists():
|
if plugins_path.exists():
|
||||||
module_list = self.load_dir_plugins(plugin, plugin_parent)
|
module_list = self.load_dir_plugins(plugin, plugin_parent)
|
||||||
|
return module_list
|
||||||
elif nest_path.exists() or src_path.exists():
|
elif nest_path.exists() or src_path.exists():
|
||||||
path = nest_path.parent / plugin.name
|
path = nest_path.parent / plugin.name
|
||||||
pyproject = plugin / 'pyproject.toml'
|
pyproject = plugin / 'pyproject.toml'
|
||||||
@ -96,6 +97,7 @@ class GsServer:
|
|||||||
module_list = self.load_dir_plugins(
|
module_list = self.load_dir_plugins(
|
||||||
path, plugin_parent, True
|
path, plugin_parent, True
|
||||||
)
|
)
|
||||||
|
return module_list
|
||||||
# 如果文件夹内有__init_.py,则视为单个插件包
|
# 如果文件夹内有__init_.py,则视为单个插件包
|
||||||
elif plugin_path.exists():
|
elif plugin_path.exists():
|
||||||
module_list = [
|
module_list = [
|
||||||
@ -103,6 +105,7 @@ class GsServer:
|
|||||||
f'{plugin_parent}.{plugin.name}.__init__'
|
f'{plugin_parent}.{plugin.name}.__init__'
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
return module_list
|
||||||
# 如果发现单文件,则视为单文件插件
|
# 如果发现单文件,则视为单文件插件
|
||||||
elif plugin.suffix == '.py':
|
elif plugin.suffix == '.py':
|
||||||
module_list = [
|
module_list = [
|
||||||
@ -110,9 +113,9 @@ class GsServer:
|
|||||||
f'{plugin_parent}.{plugin.name[:-3]}'
|
f'{plugin_parent}.{plugin.name[:-3]}'
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
return module_list
|
||||||
'''导入成功'''
|
'''导入成功'''
|
||||||
logger.success(f'✅ 插件{plugin.stem}导入成功!')
|
logger.success(f'✅ 插件{plugin.stem}导入成功!')
|
||||||
return module_list
|
|
||||||
except Exception as e: # noqa
|
except Exception as e: # noqa
|
||||||
exception = sys.exc_info()
|
exception = sys.exc_info()
|
||||||
logger.opt(exception=exception).error(f'加载插件时发生错误: {e}')
|
logger.opt(exception=exception).error(f'加载插件时发生错误: {e}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user