mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-06-09 17:09:41 +08:00
🎨 优化显示
This commit is contained in:
parent
c8170d5808
commit
d5c2ebb878
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from gsuid_core.sv import SV
|
from gsuid_core.sv import SV
|
||||||
from gsuid_core.bot import Bot
|
from gsuid_core.bot import Bot
|
||||||
@ -15,7 +16,8 @@ sv_core_config = SV('Core管理', pm=0)
|
|||||||
@gss.on_bot_connect
|
@gss.on_bot_connect
|
||||||
async def check_msg():
|
async def check_msg():
|
||||||
try:
|
try:
|
||||||
logger.info('检查遗留信息...')
|
await asyncio.sleep(3)
|
||||||
|
logger.info('📝 检查遗留信息...')
|
||||||
update_log = await restart_message()
|
update_log = await restart_message()
|
||||||
if update_log == {}:
|
if update_log == {}:
|
||||||
return
|
return
|
||||||
@ -39,9 +41,9 @@ async def check_msg():
|
|||||||
update_log['bot_self_id'],
|
update_log['bot_self_id'],
|
||||||
'',
|
'',
|
||||||
)
|
)
|
||||||
logger.info('遗留信息检查完毕!')
|
logger.info('✅ 遗留信息检查完毕!')
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning('遗留信息检查失败!')
|
logger.warning('🚧 遗留信息检查失败!')
|
||||||
|
|
||||||
|
|
||||||
@sv_core_config.on_fullmatch(('core重启', 'gs重启'), block=True)
|
@sv_core_config.on_fullmatch(('core重启', 'gs重启'), block=True)
|
||||||
|
@ -58,7 +58,7 @@ async def restart_genshinuid(
|
|||||||
if is_send:
|
if is_send:
|
||||||
update_log = {
|
update_log = {
|
||||||
'type': 'restart',
|
'type': 'restart',
|
||||||
'msg': '重启完成!',
|
'msg': '🚀 重启完成!',
|
||||||
'bot_id': bot_id,
|
'bot_id': bot_id,
|
||||||
'bot_self_id': bot_self_id,
|
'bot_self_id': bot_self_id,
|
||||||
'send_type': send_type,
|
'send_type': send_type,
|
||||||
|
@ -67,7 +67,7 @@ async def refresh_plugins_list(bot: Bot, ev: Event):
|
|||||||
('core更新插件', 'core强制更新插件', 'core强行强制更新插件'), block=True
|
('core更新插件', 'core强制更新插件', 'core强行强制更新插件'), block=True
|
||||||
)
|
)
|
||||||
async def send_update_msg(bot: Bot, ev: Event):
|
async def send_update_msg(bot: Bot, ev: Event):
|
||||||
await bot.send('开始更新...请稍等一段时间...')
|
await bot.send('🚀 开始更新...请稍等一段时间...')
|
||||||
if '强制' in ev.command:
|
if '强制' in ev.command:
|
||||||
if '强行' in ev.command:
|
if '强行' in ev.command:
|
||||||
level = 2
|
level = 2
|
||||||
|
@ -67,6 +67,42 @@ class GsServer:
|
|||||||
self.active_bot: Dict[str, _Bot] = {}
|
self.active_bot: Dict[str, _Bot] = {}
|
||||||
self.is_initialized = True
|
self.is_initialized = True
|
||||||
|
|
||||||
|
def load_dir_plugins(
|
||||||
|
self, plugin: Path, plugin_parent: str, nest: bool = False
|
||||||
|
) -> List[Tuple[str, Path, str]]:
|
||||||
|
module_list = []
|
||||||
|
init_path = plugin / '__init__.py'
|
||||||
|
name = plugin.name
|
||||||
|
if init_path.exists():
|
||||||
|
if str(init_path.parents) not in sys.path:
|
||||||
|
sys.path.append(str(init_path.parents))
|
||||||
|
module_list.append(
|
||||||
|
(
|
||||||
|
f'{plugin_parent}.{name}.{name}.__init__',
|
||||||
|
init_path,
|
||||||
|
'plugin',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
for sub_plugin in plugin.iterdir():
|
||||||
|
if sub_plugin.is_dir():
|
||||||
|
plugin_path = sub_plugin / '__init__.py'
|
||||||
|
if plugin_path.exists():
|
||||||
|
if str(plugin_path.parents) not in sys.path:
|
||||||
|
sys.path.append(str(plugin_path.parents))
|
||||||
|
if nest:
|
||||||
|
_p = f'{plugin_parent}.{name}.{name}.{sub_plugin.name}'
|
||||||
|
else:
|
||||||
|
_p = f'{plugin_parent}.{name}.{sub_plugin.name}'
|
||||||
|
module_list.append(
|
||||||
|
(
|
||||||
|
f'{_p}',
|
||||||
|
plugin_path,
|
||||||
|
'module',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return module_list
|
||||||
|
|
||||||
def load_plugin(self, plugin: Union[str, Path, str]):
|
def load_plugin(self, plugin: Union[str, Path, str]):
|
||||||
if isinstance(plugin, str):
|
if isinstance(plugin, str):
|
||||||
plugin = PLUGIN_PATH / plugin
|
plugin = PLUGIN_PATH / plugin
|
||||||
@ -100,7 +136,9 @@ class GsServer:
|
|||||||
check_pyproject(pyproject)
|
check_pyproject(pyproject)
|
||||||
if path.exists():
|
if path.exists():
|
||||||
module_list = self.load_dir_plugins(
|
module_list = self.load_dir_plugins(
|
||||||
path, plugin_parent, True
|
path,
|
||||||
|
plugin_parent,
|
||||||
|
True,
|
||||||
)
|
)
|
||||||
# 如果文件夹内有__init_.py,则视为单个插件包
|
# 如果文件夹内有__init_.py,则视为单个插件包
|
||||||
elif plugin_path.exists():
|
elif plugin_path.exists():
|
||||||
@ -188,32 +226,6 @@ class GsServer:
|
|||||||
core_config.lazy_write_config()
|
core_config.lazy_write_config()
|
||||||
logger.success('[GsCore] 插件加载完成!')
|
logger.success('[GsCore] 插件加载完成!')
|
||||||
|
|
||||||
def load_dir_plugins(
|
|
||||||
self, plugin: Path, plugin_parent: str, nest: bool = False
|
|
||||||
) -> List[Tuple[str, Path, str]]:
|
|
||||||
module_list = []
|
|
||||||
init_path = plugin / '__init__.py'
|
|
||||||
name = plugin.name
|
|
||||||
if init_path.exists():
|
|
||||||
if str(init_path.parents) not in sys.path:
|
|
||||||
sys.path.append(str(init_path.parents))
|
|
||||||
module_list.append(
|
|
||||||
(f'{plugin_parent}.{name}.{name}.__init__', init_path, 'full')
|
|
||||||
)
|
|
||||||
|
|
||||||
for sub_plugin in plugin.iterdir():
|
|
||||||
if sub_plugin.is_dir():
|
|
||||||
plugin_path = sub_plugin / '__init__.py'
|
|
||||||
if plugin_path.exists():
|
|
||||||
if str(plugin_path.parents) not in sys.path:
|
|
||||||
sys.path.append(str(plugin_path.parents))
|
|
||||||
if nest:
|
|
||||||
_p = f'{plugin_parent}.{name}.{name}.{sub_plugin.name}'
|
|
||||||
else:
|
|
||||||
_p = f'{plugin_parent}.{name}.{sub_plugin.name}'
|
|
||||||
module_list.append((f'{_p}', plugin_path, 'module'))
|
|
||||||
return module_list
|
|
||||||
|
|
||||||
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()
|
||||||
self.active_ws[bot_id] = websocket
|
self.active_ws[bot_id] = websocket
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
import time
|
|
||||||
|
|
||||||
starttime = time.time()
|
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -46,7 +43,6 @@ from fastapi_amis_admin.amis.components import (
|
|||||||
ButtonToolbar,
|
ButtonToolbar,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f'[Ba] 加载完成,耗时{time.time() - starttime}秒')
|
|
||||||
from gsuid_core.logger import logger, handle_exceptions
|
from gsuid_core.logger import logger, handle_exceptions
|
||||||
from gsuid_core.utils.cookie_manager.add_ck import _deal_ck
|
from gsuid_core.utils.cookie_manager.add_ck import _deal_ck
|
||||||
from gsuid_core.version import __version__ as gscore_version
|
from gsuid_core.version import __version__ as gscore_version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user