新增开启自动清红, 并修复面板的数据转换BUG

This commit is contained in:
KimigaiiWuyi 2024-12-22 12:18:09 +08:00
parent 702ee2fd26
commit 291bdf8458
3 changed files with 54 additions and 8 deletions

View File

@ -7,6 +7,7 @@ from gsuid_core.gss import gss
from gsuid_core.models import Event
from gsuid_core.aps import scheduler
from gsuid_core.logger import logger
from gsuid_core.subscribe import gs_subscribe
from gsuid_core.utils.error_reply import UID_HINT
from .util import black_ids
@ -19,6 +20,7 @@ from .ann_card import sub_ann, unsub_ann, ann_list_card, ann_detail_card
sv_ann = SV('原神公告')
sv_ann_sub = SV('原神公告订阅', pm=2)
sv_ann_hint = SV('原神公告红点')
sv_ann_schedule = SV('原神定时清空公告红点', priority=3)
@sv_ann.on_command(('原神公告'))
@ -51,7 +53,14 @@ async def unsub_ann_(bot: Bot, ev: Event):
await bot.send(unsub_ann(bot.bot_id, ev.group_id))
@sv_ann_hint.on_fullmatch(('取消原神公告红点', '清除原神公告红点'))
@sv_ann_hint.on_fullmatch(
(
'取消原神公告红点',
'清除原神公告红点',
'清除公告红点',
'取消公告红点',
)
)
async def consume_remind_(bot: Bot, ev: Event):
uid = await get_uid(bot, ev)
if uid is None:
@ -60,6 +69,33 @@ async def consume_remind_(bot: Bot, ev: Event):
await bot.send(await consume_remind(uid))
@sv_ann_schedule.on_fullmatch(('开启自动清红', '关闭自动清红'))
async def get_ann_schedule_msg(bot: Bot, ev: Event):
uid = await get_uid(bot, ev)
if not uid:
return await bot.send(UID_HINT)
logger.info(f'[原神][开启定时清空公告红点] UID: {uid}')
await gs_subscribe.add_subscribe(
'single',
'[原神] 自动清红',
ev,
extra_message=uid,
)
await bot.send(f'UID{uid}已开启自动清红!')
@scheduler.scheduled_job('cron', hour='*/5')
async def send_ann_schedule():
logger.info('[原神][定时清空公告红点] 正在执行中!')
datas = await gs_subscribe.get_subscribe('[原神] 自动清红')
if datas:
for subscribe in datas:
if subscribe.extra_message:
await consume_remind(subscribe.extra_message)
await asyncio.sleep(random.uniform(5, 10))
@scheduler.scheduled_job('cron', minute=10)
async def check_ann():
await check_ann_state()

View File

@ -129,6 +129,18 @@ async def convert_exist_data_to_char(
async with aiofiles.open(path, 'w', encoding='utf-8') as f:
await f.write(json.dumps(raw_data))
substatText = PROP_MAP[
list(raw_data['upgrade']['promote'][-1]['addProps'].keys())[-1]
]
sp = raw_data['upgrade']['promote'][-1]['addProps'][
list(raw_data['upgrade']['promote'][-1]['addProps'].keys())[-1]
]
if substatText == '暴击伤害':
sp += 0.5
elif substatText == '暴击率':
sp += 0.05
result = {
'name': raw_data['name'],
'title': raw_data['fetter']['title'],
@ -137,9 +149,7 @@ async def convert_exist_data_to_char(
'elementText': ELEMENT_MAP[raw_data['element']],
'element': ELEMENT_MAP[raw_data['element']],
'images': {'namesideicon': raw_data['icon']}, # 暂时适配
'substatText': PROP_MAP[
list(raw_data['upgrade']['promote'][-1]['addProps'].keys())[-1]
],
'substatText': substatText,
'hp': raw_data['upgrade']['prop'][0]['initValue']
* GROW_CURVE_LIST[89]['curveInfos'][
TYPE_TO_INT[raw_data['upgrade']['prop'][0]['type']]
@ -159,9 +169,7 @@ async def convert_exist_data_to_char(
+ raw_data['upgrade']['promote'][-1]['addProps'][
'FIGHT_PROP_BASE_DEFENSE'
],
'specialized': raw_data['upgrade']['promote'][-1]['addProps'][
list(raw_data['upgrade']['promote'][-1]['addProps'].keys())[-1]
],
'specialized': sp,
}
return cast(ConvertCharacter, result)
@ -309,3 +317,4 @@ async def convert_ambr_to_talent(
para
].append(talent_data[i]['promote'][level]['params'][ig])
return cast(CharacterTalents, result)
return cast(CharacterTalents, result)

View File

@ -628,7 +628,8 @@
"紫茄子",
"阿忍",
"忍姐",
"九岐忍"
"九岐忍",
"九七人"
],
"神里绫人": [
"Kamisato Ayato",