mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🐛 修复一些字段错误
This commit is contained in:
parent
97c8ae3996
commit
b27cf3561b
@ -15,7 +15,7 @@ class GsClient:
|
|||||||
self = GsClient()
|
self = GsClient()
|
||||||
cls.ws_url = f'ws://{IP}:{PORT}/ws/Nonebot'
|
cls.ws_url = f'ws://{IP}:{PORT}/ws/Nonebot'
|
||||||
print(f'连接至WS链接{self.ws_url}...')
|
print(f'连接至WS链接{self.ws_url}...')
|
||||||
cls.ws = await websockets.client.connect(cls.ws_url)
|
cls.ws = await websockets.client.connect(cls.ws_url, max_size=2**25)
|
||||||
print('已成功链接!')
|
print('已成功链接!')
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ async def handle_event(ws: _Bot, msg: MessageReceive):
|
|||||||
for tr in SL.lst[sv].TL
|
for tr in SL.lst[sv].TL
|
||||||
if (
|
if (
|
||||||
SL.lst[sv].enabled
|
SL.lst[sv].enabled
|
||||||
and user_pm <= SL.lst[sv].permission
|
and user_pm <= SL.lst[sv].pm
|
||||||
and msg.group_id not in SL.lst[sv].black_list
|
and msg.group_id not in SL.lst[sv].black_list
|
||||||
and True
|
and True
|
||||||
if SL.lst[sv].area == 'ALL'
|
if SL.lst[sv].area == 'ALL'
|
||||||
|
@ -35,26 +35,36 @@ class GsServer:
|
|||||||
# 遍历插件文件夹内所有文件
|
# 遍历插件文件夹内所有文件
|
||||||
for plugin in plug_path.iterdir():
|
for plugin in plug_path.iterdir():
|
||||||
# 如果发现文件夹,则视为插件包
|
# 如果发现文件夹,则视为插件包
|
||||||
|
try:
|
||||||
if plugin.is_dir():
|
if plugin.is_dir():
|
||||||
plugin_path = plugin / '__init__.py'
|
plugin_path = plugin / '__init__.py'
|
||||||
plugins_path = plugin / '__full__.py'
|
plugins_path = plugin / '__full__.py'
|
||||||
# 如果文件夹内有__full_.py,则视为插件包合集
|
# 如果文件夹内有__full_.py,则视为插件包合集
|
||||||
sys.path.append(str(plugin_path.parents))
|
sys.path.append(str(plugin_path.parents))
|
||||||
if plugins_path.exists():
|
if plugins_path.exists():
|
||||||
importlib.import_module(f'plugins.{plugin.name}.__full__')
|
importlib.import_module(
|
||||||
|
f'plugins.{plugin.name}.__full__'
|
||||||
|
)
|
||||||
for sub_plugin in plugin.iterdir():
|
for sub_plugin in plugin.iterdir():
|
||||||
if sub_plugin.is_dir():
|
if sub_plugin.is_dir():
|
||||||
plugin_path = sub_plugin / '__init__.py'
|
plugin_path = sub_plugin / '__init__.py'
|
||||||
if plugin_path.exists():
|
if plugin_path.exists():
|
||||||
sys.path.append(str(plugin_path.parents))
|
sys.path.append(str(plugin_path.parents))
|
||||||
_p = f'plugins.{plugin.name}.{sub_plugin.name}'
|
_p = (
|
||||||
|
f'plugins.{plugin.name}.'
|
||||||
|
f'{sub_plugin.name}'
|
||||||
|
)
|
||||||
importlib.import_module(f'{_p}.__init__')
|
importlib.import_module(f'{_p}.__init__')
|
||||||
# 如果文件夹内有__init_.py,则视为单个插件包
|
# 如果文件夹内有__init_.py,则视为单个插件包
|
||||||
elif plugin_path.exists():
|
elif plugin_path.exists():
|
||||||
importlib.import_module(f'plugins.{plugin.name}.__init__')
|
importlib.import_module(
|
||||||
|
f'plugins.{plugin.name}.__init__'
|
||||||
|
)
|
||||||
# 如果发现单文件,则视为单文件插件
|
# 如果发现单文件,则视为单文件插件
|
||||||
if plugin.suffix == '.py':
|
if plugin.suffix == '.py':
|
||||||
importlib.import_module(f'plugins.{plugin.name[:-3]}')
|
importlib.import_module(f'plugins.{plugin.name[:-3]}')
|
||||||
|
except: # noqa
|
||||||
|
logger.warning(f'插件{plugin.name}加载失败')
|
||||||
|
|
||||||
async def connect(self, websocket: WebSocket, bot_id: str) -> _Bot:
|
async def connect(self, websocket: WebSocket, bot_id: str) -> _Bot:
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user