🎨 整合启动任务

This commit is contained in:
Wuyi无疑 2023-03-05 15:34:27 +08:00
parent 63717e7929
commit 8462ae66a9
6 changed files with 23 additions and 28 deletions

View File

@ -7,7 +7,7 @@ from ..utils.error_reply import UID_HINT
from .draw_abyss_card import draw_abyss_img
@SV('查询深渊').on_prefix(('查询深渊', 'sy', '查询上期深渊', 'sqsy'))
@SV('查询深渊').on_command(('查询深渊', 'sy', '查询上期深渊', 'sqsy'))
async def send_abyss_info(bot: Bot, ev: Event):
await bot.logger.info('开始执行[查询深渊信息]')
uid = await get_uid(bot, ev)

View File

@ -1,11 +1,8 @@
import asyncio
import threading
from pathlib import Path
from gsuid_core.sv import SV
from gsuid_core.bot import Bot
from .draw_help_card import draw_help_img
from ..utils.image.convert import convert_img
HELP_IMG = Path(__file__).parent / 'help.png'
@ -16,8 +13,3 @@ async def send_guide_pic(bot: Bot):
img = await convert_img(HELP_IMG)
await bot.logger.info('获得gs帮助图片成功')
await bot.send(img)
threading.Thread(
target=lambda: asyncio.run(draw_help_img()), daemon=True
).start()

View File

@ -1,16 +1,12 @@
import asyncio
import threading
from gsuid_core.sv import SV
from gsuid_core.bot import Bot
from gsuid_core.models import Event
from gsuid_core.logger import logger
from ..utils.resource.download_all_resource import download_all_resource
@SV('下载资源', pm=2).on_fullmatch(('深渊概览', '深渊统计', '深渊使用率'))
async def send_download_resource_msg(bot: Bot, ev: Event):
@SV('下载资源', pm=2).on_fullmatch(('下载全部资源'))
async def send_download_resource_msg(bot: Bot):
await bot.send('正在开始下载~可能需要较久的时间!')
im = await download_all_resource()
await bot.send(im)
@ -19,6 +15,3 @@ async def send_download_resource_msg(bot: Bot, ev: Event):
async def startup():
logger.info('[资源文件下载] 正在检查与下载缺失的资源文件,可能需要较长时间,请稍等')
logger.info(f'[资源文件下载] {await download_all_resource()}')
threading.Thread(target=lambda: asyncio.run(startup()), daemon=True).start()

View File

@ -0,0 +1,15 @@
import asyncio
import threading
from ..genshinuid_resource import startup
from ..genshinuid_xkdata import draw_xk_abyss_img
from ..genshinuid_help.draw_help_card import draw_help_img
async def all_start():
await startup()
await draw_xk_abyss_img()
await draw_help_img()
threading.Thread(target=lambda: asyncio.run(all_start()), daemon=True).start()

View File

@ -1,6 +1,5 @@
import random
import asyncio
import threading
from gsuid_core.sv import SV
from gsuid_core.bot import Bot
@ -21,8 +20,3 @@ async def send_abyss_pic(bot: Bot):
img = await convert_img(TOTAL_IMG)
await bot.logger.info('获得gs帮助图片成功!')
await bot.send(img)
threading.Thread(
target=lambda: asyncio.run(draw_xk_abyss_img()), daemon=True
).start()

View File

@ -131,8 +131,8 @@ class SQLA:
async def select_cache_cookie(self, uid: str) -> Optional[str]:
sql = select(GsCache).where(GsCache.uid == uid)
result = await self.session.execute(sql)
data: GsCache = result.scalars().one()
return data.cookie if data else None
data: List[GsCache] = result.scalars().all()
return data[0].cookie if len(data) >= 1 else None
async def delete_error_cache(self) -> bool:
data = await self.get_all_error_cookie()
@ -353,13 +353,14 @@ class SQLA:
):
await self.update_push_data(uid, {f'{mode}_is_push': status})
async def select_push_data(self, uid: str) -> GsPush:
async def select_push_data(self, uid: str) -> Optional[GsPush]:
await self.push_exists(uid)
sql = select(GsPush).where(
GsPush.uid == uid and GsPush.bot_id == self.bot_id
)
result = await self.session.execute(sql)
return result.scalars().one()
data = result.scalars().all()
return data[0] if len(data) >= 1 else None
async def push_exists(self, uid: str) -> bool:
sql = select(GsPush).where(