🐛 修复一些字段错误

This commit is contained in:
Wuyi无疑 2023-03-01 21:43:08 +08:00
parent 97c8ae3996
commit b27cf3561b
3 changed files with 32 additions and 22 deletions

View File

@ -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

View File

@ -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'

View File

@ -35,26 +35,36 @@ class GsServer:
# 遍历插件文件夹内所有文件 # 遍历插件文件夹内所有文件
for plugin in plug_path.iterdir(): for plugin in plug_path.iterdir():
# 如果发现文件夹,则视为插件包 # 如果发现文件夹,则视为插件包
if plugin.is_dir(): try:
plugin_path = plugin / '__init__.py' if plugin.is_dir():
plugins_path = plugin / '__full__.py' plugin_path = plugin / '__init__.py'
# 如果文件夹内有__full_.py则视为插件包合集 plugins_path = plugin / '__full__.py'
sys.path.append(str(plugin_path.parents)) # 如果文件夹内有__full_.py则视为插件包合集
if plugins_path.exists(): sys.path.append(str(plugin_path.parents))
importlib.import_module(f'plugins.{plugin.name}.__full__') if plugins_path.exists():
for sub_plugin in plugin.iterdir(): importlib.import_module(
if sub_plugin.is_dir(): f'plugins.{plugin.name}.__full__'
plugin_path = sub_plugin / '__init__.py' )
if plugin_path.exists(): for sub_plugin in plugin.iterdir():
sys.path.append(str(plugin_path.parents)) if sub_plugin.is_dir():
_p = f'plugins.{plugin.name}.{sub_plugin.name}' plugin_path = sub_plugin / '__init__.py'
importlib.import_module(f'{_p}.__init__') if plugin_path.exists():
# 如果文件夹内有__init_.py则视为单个插件包 sys.path.append(str(plugin_path.parents))
elif plugin_path.exists(): _p = (
importlib.import_module(f'plugins.{plugin.name}.__init__') f'plugins.{plugin.name}.'
# 如果发现单文件,则视为单文件插件 f'{sub_plugin.name}'
if plugin.suffix == '.py': )
importlib.import_module(f'plugins.{plugin.name[:-3]}') importlib.import_module(f'{_p}.__init__')
# 如果文件夹内有__init_.py则视为单个插件包
elif plugin_path.exists():
importlib.import_module(
f'plugins.{plugin.name}.__init__'
)
# 如果发现单文件,则视为单文件插件
if plugin.suffix == '.py':
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()