🐛 修复体力推送以及注入BUG (#489)

This commit is contained in:
Wuyi无疑 2023-04-06 21:43:00 +08:00
parent 8a77c07793
commit 853d2d0519
4 changed files with 18 additions and 12 deletions

View File

@ -15,7 +15,7 @@ async def draw_genshin_map(
try: try:
raw_data = await get_map_data(resource_name, map_id) raw_data = await get_map_data(resource_name, map_id)
except MiniggNotFoundError: except MiniggNotFoundError:
return f'未在{map_name}找到{resource_name}...' return f'未在{map_name}找到所需资源...'
with open(MAP_DATA / f'{map_name}_{resource_name}.jpg', 'wb') as f: with open(MAP_DATA / f'{map_name}_{resource_name}.jpg', 'wb') as f:
f.write(raw_data) # 保存到文件夹中 f.write(raw_data) # 保存到文件夹中
return raw_data return raw_data

View File

@ -15,6 +15,7 @@ from ..utils.error_reply import UID_HINT
from .draw_resin_card import get_resin_img from .draw_resin_card import get_resin_img
sv_get_resin = SV('查询体力') sv_get_resin = SV('查询体力')
sv_get_resin_admin = SV('强制推送', pm=1)
@sv_get_resin.on_fullmatch(('当前状态')) @sv_get_resin.on_fullmatch(('当前状态'))
@ -29,12 +30,19 @@ async def send_daily_info(bot: Bot, ev: Event):
await bot.send(im) await bot.send(im)
@sv_get_resin_admin.on_fullmatch(('强制推送体力提醒'))
async def force_notice_job(bot: Bot, ev: Event):
await bot.logger.info('开始执行[强制推送体力信息]')
await notice_job()
@scheduler.scheduled_job('cron', minute='*/30') @scheduler.scheduled_job('cron', minute='*/30')
async def notice_job(): async def notice_job():
result = await get_notice_list() result = await get_notice_list()
logger.info('[推送检查]完成!等待消息推送中...') logger.info('[推送检查]完成!等待消息推送中...')
# 执行私聊推送 logger.debug(result)
# 执行私聊推送
for bot_id in result: for bot_id in result:
for BOT_ID in gss.active_bot: for BOT_ID in gss.active_bot:
bot = gss.active_bot[BOT_ID] bot = gss.active_bot[BOT_ID]

View File

@ -30,7 +30,7 @@ async def get_notice_list() -> Dict[str, Dict[str, Dict]]:
continue continue
push_data = await sqla.select_push_data(user.uid) push_data = await sqla.select_push_data(user.uid)
msg_dict = await all_check( msg_dict = await all_check(
bot_id, user.bot_id,
raw_data, raw_data,
push_data.__dict__, push_data.__dict__,
msg_dict, msg_dict,
@ -78,16 +78,14 @@ async def all_check(
# 群号推送到群聊 # 群号推送到群聊
else: else:
# 初始化 # 初始化
gid = f'{mode}_push' gid = push_data[f'{mode}_push']
if push_data[gid] not in msg_dict[bot_id]['group']: if gid not in msg_dict[bot_id]['group']:
msg_dict[bot_id]['direct'][gid] = {} msg_dict[bot_id]['group'][gid] = {}
if user_id not in msg_dict[bot_id]['direct'][gid]: if user_id not in msg_dict[bot_id]['group'][gid]:
msg_dict[bot_id]['direct'][gid][user_id] = NOTICE[mode] msg_dict[bot_id]['group'][gid][user_id] = NOTICE[mode]
else: else:
msg_dict[bot_id]['direct'][gid][user_id] += NOTICE[ msg_dict[bot_id]['group'][gid][user_id] += NOTICE[mode]
mode
]
await sqla.update_push_data(uid, {f'{mode}_is_push': 'on'}) await sqla.update_push_data(uid, {f'{mode}_is_push': 'on'})
return msg_dict return msg_dict

View File

@ -12,10 +12,10 @@ from ..utils.resource.generate_char_card import create_all_char_card
async def all_start(): async def all_start():
try: try:
await draw_help_img()
await startup() await startup()
await create_all_char_card() await create_all_char_card()
await draw_xk_abyss_img() await draw_xk_abyss_img()
await draw_help_img()
await generate_data() await generate_data()
except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)