🐛 修复一些问题, 锁定依赖, 提前加载core_command插件包

This commit is contained in:
KimigaiiWuyi 2024-10-07 01:53:34 +08:00
parent 08f8a3010b
commit cc77f82e5c
14 changed files with 55 additions and 44 deletions

View File

@ -53,7 +53,7 @@ class GsClient:
bot_id='console', bot_id='console',
# bot_id='qqgroup', # bot_id='qqgroup',
bot_self_id='511love51', bot_self_id='511love51',
user_type='group', user_type='direct',
user_pm=0, user_pm=0,
group_id=group_id, group_id=group_id,
user_id=user_id, user_id=user_id,

View File

@ -46,7 +46,7 @@ async def check_msg():
logger.warning('遗留信息检查失败!') logger.warning('遗留信息检查失败!')
@sv_core_config.on_fullmatch(('core重启', 'gs重启')) @sv_core_config.on_fullmatch(('core重启', 'gs重启'), block=True)
async def send_restart_msg(bot: Bot, ev: Event): async def send_restart_msg(bot: Bot, ev: Event):
await bot.logger.warning('开始执行[重启]') await bot.logger.warning('开始执行[重启]')
if ev.group_id: if ev.group_id:
@ -61,7 +61,7 @@ async def send_restart_msg(bot: Bot, ev: Event):
) )
@sv_core_config.on_fullmatch(('core关闭', 'Core关闭')) @sv_core_config.on_fullmatch(('core关闭', 'Core关闭'), block=True)
async def send_shutdown_msg(bot: Bot, ev: Event): async def send_shutdown_msg(bot: Bot, ev: Event):
await bot.logger.warning('开始执行[关闭]') await bot.logger.warning('开始执行[关闭]')
await bot.send('正在执行[gs关闭Core]...') await bot.send('正在执行[gs关闭Core]...')

View File

@ -44,7 +44,7 @@ async def scheduled_save_global_val():
await count_group_user() await count_group_user()
@sv_core_status.on_command(('core状态', 'Core状态')) @sv_core_status.on_command(('core状态', 'Core状态'), block=True)
async def send_core_status_msg(bot: Bot, ev: Event): async def send_core_status_msg(bot: Bot, ev: Event):
day = ev.text.strip() day = ev.text.strip()
if day and day.isdigit(): if day and day.isdigit():

View File

@ -16,7 +16,7 @@ from gsuid_core.utils.plugins_update._plugins import (
sv_core_config = SV('Core管理', pm=0) sv_core_config = SV('Core管理', pm=0)
@sv_core_config.on_fullmatch(('core更新', 'core强制更新')) @sv_core_config.on_fullmatch(('core更新', 'core强制更新'), block=True)
async def send_core_update_msg(bot: Bot, ev: Event): async def send_core_update_msg(bot: Bot, ev: Event):
logger.info('开始执行[更新] 早柚核心') logger.info('开始执行[更新] 早柚核心')
if '强制' in ev.command: if '强制' in ev.command:
@ -27,7 +27,7 @@ async def send_core_update_msg(bot: Bot, ev: Event):
await bot.send(log_list) await bot.send(log_list)
@sv_core_config.on_command(('core设置代理')) @sv_core_config.on_command(('core设置代理'), block=True)
async def send_core_set_proxy(bot: Bot, ev: Event): async def send_core_set_proxy(bot: Bot, ev: Event):
logger.info('开始执行[设置代理]') logger.info('开始执行[设置代理]')
proxy_url = ev.text.strip() if ev.text else '' proxy_url = ev.text.strip() if ev.text else ''
@ -39,7 +39,7 @@ async def send_core_set_proxy(bot: Bot, ev: Event):
) )
@sv_core_config.on_command(('core应用设置代理')) @sv_core_config.on_command(('core应用设置代理'), block=True)
async def send_core_update_proxy(bot: Bot, ev: Event): async def send_core_update_proxy(bot: Bot, ev: Event):
logger.info('开始执行[应用设置代理]') logger.info('开始执行[应用设置代理]')
proxy = ev.text if ev.text else None proxy = ev.text if ev.text else None
@ -53,7 +53,7 @@ async def send_core_update_proxy(bot: Bot, ev: Event):
await bot.send(log_list) await bot.send(log_list)
@sv_core_config.on_fullmatch(('core更新依赖')) @sv_core_config.on_fullmatch(('core更新依赖'), block=True)
async def send_core_poetry_install(bot: Bot, ev: Event): async def send_core_poetry_install(bot: Bot, ev: Event):
logger.info('开始执行[更新] 早柚核心依赖') logger.info('开始执行[更新] 早柚核心依赖')
retcode = await asyncio.to_thread(run_install) retcode = await asyncio.to_thread(run_install)
@ -68,7 +68,8 @@ async def send_core_poetry_install(bot: Bot, ev: Event):
'core强制全部更新', 'core强制全部更新',
'core强行强制全部更新', 'core强行强制全部更新',
'core全部强行强制更新', 'core全部强行强制更新',
) ),
block=True,
) )
async def send_core_all_update_msg(bot: Bot, ev: Event): async def send_core_all_update_msg(bot: Bot, ev: Event):
logger.info('开始执行[更新] 全部更新') logger.info('开始执行[更新] 全部更新')

View File

@ -11,7 +11,7 @@ core_user_info = SV('core用户信息')
core_user_msg = SV('core信息确认') core_user_msg = SV('core信息确认')
@core_user_info.on_fullmatch(('绑定信息')) @core_user_info.on_fullmatch(('绑定信息'), block=True)
async def send_bind_card(bot: Bot, ev: Event): async def send_bind_card(bot: Bot, ev: Event):
await bot.logger.info('开始执行[查询用户绑定状态]') await bot.logger.info('开始执行[查询用户绑定状态]')
im = await get_user_card(ev.bot_id, ev) im = await get_user_card(ev.bot_id, ev)
@ -19,7 +19,7 @@ async def send_bind_card(bot: Bot, ev: Event):
await bot.send(im) await bot.send(im)
@core_user_msg.on_fullmatch(('给我发消息')) @core_user_msg.on_fullmatch(('给我发消息'), block=True)
async def send_direct_msg(bot: Bot, ev: Event): async def send_direct_msg(bot: Bot, ev: Event):
logger.info('开始执行[给我发消息]') logger.info('开始执行[给我发消息]')
messages = [ messages = [

View File

@ -14,7 +14,9 @@ from .drop_table import drop_web_table
core_web = SV('core网页控制台管理', pm=0, area='DIRECT') core_web = SV('core网页控制台管理', pm=0, area='DIRECT')
@core_web.on_fullmatch(('core清除网页控制台密码', 'core重置网页控制台密码')) @core_web.on_fullmatch(
('core清除网页控制台密码', 'core重置网页控制台密码'), block=True
)
async def reset_web_password(bot: Bot, ev: Event): async def reset_web_password(bot: Bot, ev: Event):
pw = generate_random_string() pw = generate_random_string()
try: try:

View File

@ -13,7 +13,7 @@ from gsuid_core.utils.plugins_update._plugins import (
sv_core_install_plugins = SV('core管理插件', pm=0) sv_core_install_plugins = SV('core管理插件', pm=0)
@sv_core_install_plugins.on_prefix(('core卸载插件')) @sv_core_install_plugins.on_prefix(('core卸载插件'), block=True)
async def send_plugins_uninstall(bot: Bot, ev: Event): async def send_plugins_uninstall(bot: Bot, ev: Event):
if not ev.text: if not ev.text:
return await bot.send( return await bot.send(
@ -40,7 +40,7 @@ async def send_plugins_uninstall(bot: Bot, ev: Event):
await bot.send('已取消删除!') await bot.send('已取消删除!')
@sv_core_install_plugins.on_prefix(('core安装插件')) @sv_core_install_plugins.on_prefix(('core安装插件'), block=True)
async def send_plugins_install(bot: Bot, ev: Event): async def send_plugins_install(bot: Bot, ev: Event):
plugins = await get_plugins_url(ev.text.strip().lower()) plugins = await get_plugins_url(ev.text.strip().lower())
if not plugins: if not plugins:
@ -53,7 +53,7 @@ async def send_plugins_install(bot: Bot, ev: Event):
await bot.send(im) await bot.send(im)
@sv_core_install_plugins.on_fullmatch(('core刷新插件列表')) @sv_core_install_plugins.on_fullmatch(('core刷新插件列表'), block=True)
async def refresh_plugins_list(bot: Bot, ev: Event): async def refresh_plugins_list(bot: Bot, ev: Event):
_list = await refresh_list() _list = await refresh_list()
if len(_list) <= 3: if len(_list) <= 3:
@ -64,7 +64,7 @@ async def refresh_plugins_list(bot: Bot, ev: Event):
@sv_core_install_plugins.on_prefix( @sv_core_install_plugins.on_prefix(
('core更新插件', 'core强制更新插件', 'core强行强制更新插件') ('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('开始更新...请稍等一段时间...')

View File

@ -25,21 +25,21 @@ sv_core_user_addck = SV('添加CK', area='DIRECT')
sv_data_manger = SV('用户数据管理', pm=0) sv_data_manger = SV('用户数据管理', pm=0)
@sv_core_user_config.on_fullmatch(('刷新全部CK', '刷新全部ck')) @sv_core_user_config.on_fullmatch(('刷新全部CK', '刷新全部ck'), block=True)
async def send_refresh_all_ck_msg(bot: Bot, ev: Event): async def send_refresh_all_ck_msg(bot: Bot, ev: Event):
await bot.logger.info('开始执行[刷新全部CK]') await bot.logger.info('开始执行[刷新全部CK]')
im = await get_ck_by_all_stoken(ev.bot_id) im = await get_ck_by_all_stoken(ev.bot_id)
await bot.send(im) await bot.send(im)
@sv_core_user_add.on_fullmatch(('刷新CK', '刷新ck')) @sv_core_user_add.on_fullmatch(('刷新CK', '刷新ck'), block=True)
async def send_refresh_ck_msg(bot: Bot, ev: Event): async def send_refresh_ck_msg(bot: Bot, ev: Event):
await bot.logger.info('开始执行[刷新CK]') await bot.logger.info('开始执行[刷新CK]')
im = await get_ck_by_stoken(ev.bot_id, ev.user_id) im = await get_ck_by_stoken(ev.bot_id, ev.user_id)
await bot.send(im) await bot.send(im)
@sv_data_manger.on_fullmatch(('校验全部Cookies')) @sv_data_manger.on_fullmatch(('校验全部Cookies'), block=True)
async def send_check_cookie(bot: Bot, ev: Event): async def send_check_cookie(bot: Bot, ev: Event):
user_list = await GsUser.get_all_user() user_list = await GsUser.get_all_user()
invalid_user: List[GsUser] = [] invalid_user: List[GsUser] = []
@ -93,7 +93,7 @@ async def send_check_cookie(bot: Bot, ev: Event):
await asyncio.sleep(3 + random.randint(1, 3)) await asyncio.sleep(3 + random.randint(1, 3))
@sv_data_manger.on_fullmatch(('校验全部Stoken')) @sv_data_manger.on_fullmatch(('校验全部Stoken'), block=True)
async def send_check_stoken(bot: Bot, ev: Event): async def send_check_stoken(bot: Bot, ev: Event):
user_list = await GsUser.get_all_user() user_list = await GsUser.get_all_user()
invalid_user: List[GsUser] = [] invalid_user: List[GsUser] = []
@ -162,7 +162,7 @@ async def _send_help(bot: Bot, im):
) )
@sv_core_user_qrcode_login.on_fullmatch(('扫码登陆', '扫码登录')) @sv_core_user_qrcode_login.on_fullmatch(('扫码登陆', '扫码登录'), block=True)
async def send_qrcode_login(bot: Bot, ev: Event): async def send_qrcode_login(bot: Bot, ev: Event):
await bot.logger.info('开始执行[扫码登陆]') await bot.logger.info('开始执行[扫码登陆]')
uid_list = await get_all_bind_uid(ev.bot_id, ev.user_id) uid_list = await get_all_bind_uid(ev.bot_id, ev.user_id)
@ -182,7 +182,7 @@ async def send_qrcode_login(bot: Bot, ev: Event):
await bot.send(im) await bot.send(im)
@sv_core_user_addck.on_prefix(('添加')) @sv_core_user_addck.on_prefix(('添加'), block=True)
async def send_add_ck_msg(bot: Bot, ev: Event): async def send_add_ck_msg(bot: Bot, ev: Event):
im, status = await deal_ck(ev.bot_id, ev.text, ev.user_id) im, status = await deal_ck(ev.bot_id, ev.text, ev.user_id)
if status: if status:
@ -196,7 +196,8 @@ async def send_add_ck_msg(bot: Bot, ev: Event):
'mys设备登录', 'mys设备登录',
'mys设备登陆', 'mys设备登陆',
'mys绑定设备', 'mys绑定设备',
) ),
block=True,
) )
async def send_add_device_msg(bot: Bot, ev: Event): async def send_add_device_msg(bot: Bot, ev: Event):
try: try:

View File

@ -12,12 +12,8 @@ from fastapi import WebSocket
from gsuid_core.bot import _Bot from gsuid_core.bot import _Bot
from gsuid_core.logger import logger from gsuid_core.logger import logger
from gsuid_core.utils.plugins_update._plugins import check_start_tool
from gsuid_core.utils.plugins_config.gs_config import core_plugins_config from gsuid_core.utils.plugins_config.gs_config import core_plugins_config
from gsuid_core.utils.plugins_update._plugins import (
check_start_tool,
sync_get_plugin_url,
sync_change_plugin_url,
)
auto_install_dep: bool = core_plugins_config.get_config('AutoInstallDep').data auto_install_dep: bool = core_plugins_config.get_config('AutoInstallDep').data
auto_update_dep: bool = core_plugins_config.get_config('AutoUpdateDep').data auto_update_dep: bool = core_plugins_config.get_config('AutoUpdateDep').data
@ -63,8 +59,16 @@ class GsServer:
get_installed_dependencies() get_installed_dependencies()
sys.path.append(str(Path(__file__).parents[1])) sys.path.append(str(Path(__file__).parents[1]))
plug_path = Path(__file__).parent / 'plugins' plug_path = Path(__file__).parent / 'plugins'
# 优先加载core_command
plug_path_list = list(plug_path.iterdir())
core_command_path = plug_path / 'core_command'
if core_command_path in plug_path_list:
plug_path_list.remove(core_command_path)
plug_path_list.insert(0, core_command_path)
# 遍历插件文件夹内所有文件 # 遍历插件文件夹内所有文件
for plugin in plug_path.iterdir(): for plugin in plug_path_list:
if plugin.stem.startswith('_'): if plugin.stem.startswith('_'):
continue continue
# 如果发现文件夹,则视为插件包 # 如果发现文件夹,则视为插件包
@ -97,7 +101,8 @@ class GsServer:
elif plugin.suffix == '.py': elif plugin.suffix == '.py':
importlib.import_module(f'plugins.{plugin.name[:-3]}') importlib.import_module(f'plugins.{plugin.name[:-3]}')
'''trick''' '''trick 注释掉'''
'''
if plugin.stem in ['StarRailUID', 'ArknightsUID']: if plugin.stem in ['StarRailUID', 'ArknightsUID']:
logger.info('[BAI] 检测是否存在失效仓库...') logger.info('[BAI] 检测是否存在失效仓库...')
origin_url = sync_get_plugin_url(plugin) origin_url = sync_get_plugin_url(plugin)
@ -110,6 +115,7 @@ class GsServer:
new_url = origin_url.replace('qwerdvd', 'baiqwerdvd') new_url = origin_url.replace('qwerdvd', 'baiqwerdvd')
logger.success(f'[BAI] 替换新仓库地址成功: {new_url}') logger.success(f'[BAI] 替换新仓库地址成功: {new_url}')
sync_change_plugin_url(plugin, new_url) sync_change_plugin_url(plugin, new_url)
'''
'''导入成功''' '''导入成功'''
logger.success(f'插件{plugin.stem}导入成功!') logger.success(f'插件{plugin.stem}导入成功!')

View File

@ -101,9 +101,10 @@ class Plugins:
if isinstance(prefix, str): if isinstance(prefix, str):
prefix = [prefix] prefix = [prefix]
if allow_empty_prefix is None: if allow_empty_prefix is None:
if '' in prefix: _pf = prefix + force_prefix
prefix.remove('') if '' in _pf:
if prefix: _pf.remove('')
if _pf:
allow_empty_prefix = False allow_empty_prefix = False
else: else:
allow_empty_prefix = True allow_empty_prefix = True

8
pdm.lock generated
View File

@ -5,7 +5,7 @@
groups = ["default"] groups = ["default"]
strategy = [] strategy = []
lock_version = "4.4.1" lock_version = "4.4.1"
content_hash = "sha256:79d7703eb8b2c942c03f2a487b3e7adf8813c9c390ca83e5dfd1b63d81ec4728" content_hash = "sha256:a64cc47816b04cfd02dc5e49fb334402dc15bcaa9b172d99b8facd33c3f005f7"
[[package]] [[package]]
name = "aioboto3" name = "aioboto3"
@ -309,7 +309,7 @@ files = [
[[package]] [[package]]
name = "fastapi" name = "fastapi"
version = "0.114.0" version = "0.112.2"
requires_python = ">=3.8" requires_python = ">=3.8"
summary = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" summary = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
dependencies = [ dependencies = [
@ -318,8 +318,8 @@ dependencies = [
"typing-extensions>=4.8.0", "typing-extensions>=4.8.0",
] ]
files = [ files = [
{file = "fastapi-0.114.0-py3-none-any.whl", hash = "sha256:fee75aa1b1d3d73f79851c432497e4394e413e1dece6234f68d3ce250d12760a"}, {file = "fastapi-0.112.2-py3-none-any.whl", hash = "sha256:db84b470bd0e2b1075942231e90e3577e12a903c4dc8696f0d206a7904a7af1c"},
{file = "fastapi-0.114.0.tar.gz", hash = "sha256:9908f2a5cc733004de6ca5e1412698f35085cefcbfd41d539245b9edf87b73c1"}, {file = "fastapi-0.112.2.tar.gz", hash = "sha256:3d4729c038414d5193840706907a41839d839523da6ed0c2811f1168cac1798c"},
] ]
[[package]] [[package]]

8
poetry.lock generated
View File

@ -626,13 +626,13 @@ reference = "mirrors"
[[package]] [[package]]
name = "fastapi" name = "fastapi"
version = "0.113.0" version = "0.112.2"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
files = [ files = [
{file = "fastapi-0.113.0-py3-none-any.whl", hash = "sha256:c8d364485b6361fb643d53920a18d58a696e189abcb901ec03b487e35774c476"}, {file = "fastapi-0.112.2-py3-none-any.whl", hash = "sha256:db84b470bd0e2b1075942231e90e3577e12a903c4dc8696f0d206a7904a7af1c"},
{file = "fastapi-0.113.0.tar.gz", hash = "sha256:b7cf9684dc154dfc93f8b718e5850577b529889096518df44defa41e73caf50f"}, {file = "fastapi-0.112.2.tar.gz", hash = "sha256:3d4729c038414d5193840706907a41839d839523da6ed0c2811f1168cac1798c"},
] ]
[package.dependencies] [package.dependencies]
@ -2932,4 +2932,4 @@ reference = "mirrors"
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.8.1" python-versions = "^3.8.1"
content-hash = "1aa433aadcec3b9231c36a74ed5a86f1c438cd8bae902b7b66e615e62f1b0df0" content-hash = "addb4ffcd2919b28ca0f7b741a1bcb44e2c1de993cd684b1ccb3fef13fbad011"

View File

@ -33,7 +33,7 @@ websockets = ">=13.1"
loguru = ">=0.6.0" loguru = ">=0.6.0"
urllib3 = "^1.26.15" urllib3 = "^1.26.15"
mpmath = "^1.3.0" mpmath = "^1.3.0"
fastapi = "<0.114" fastapi = "<0.112.3"
apscheduler = "^3.10.1" apscheduler = "^3.10.1"
aioboto3 = "^12.0.0" aioboto3 = "^12.0.0"
jinja2 = "^3.1.2" jinja2 = "^3.1.2"
@ -113,7 +113,7 @@ dependencies = [
"loguru<1.0.0,>=0.6.0", "loguru<1.0.0,>=0.6.0",
"urllib3<2.0.0,>=1.26.15", "urllib3<2.0.0,>=1.26.15",
"mpmath<2.0.0,>=1.3.0", "mpmath<2.0.0,>=1.3.0",
"fastapi<0.114.1,>=0.97.0", "fastapi<0.112.3,>=0.97.0",
"apscheduler<4.0.0,>=3.10.1", "apscheduler<4.0.0,>=3.10.1",
"aioboto3<13.0.0,>=12.0.0", "aioboto3<13.0.0,>=12.0.0",
"jinja2<4.0.0,>=3.1.2", "jinja2<4.0.0,>=3.1.2",

View File

@ -22,7 +22,7 @@ dnspython==2.7.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0
email-validator==2.2.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" email-validator==2.2.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-amis-admin==0.7.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" fastapi-amis-admin==0.7.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-user-auth==0.7.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" fastapi-user-auth==0.7.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.113.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" fastapi==0.112.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
frozenlist==1.4.1 ; python_full_version >= "3.8.1" and python_version < "4.0" frozenlist==1.4.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
gitdb==4.0.11 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" gitdb==4.0.11 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitpython==3.1.43 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" gitpython==3.1.43 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"