Skip to content

Commit

Permalink
✨ 新增开启自动清红, 并修复面板的数据转换BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Dec 22, 2024
1 parent 702ee2f commit 291bdf8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
38 changes: 37 additions & 1 deletion GenshinUID/genshinuid_ann/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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
Expand All @@ -19,6 +20,7 @@
sv_ann = SV('原神公告')
sv_ann_sub = SV('原神公告订阅', pm=2)
sv_ann_hint = SV('原神公告红点')
sv_ann_schedule = SV('原神定时清空公告红点', priority=3)


@sv_ann.on_command(('原神公告'))
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down
21 changes: 15 additions & 6 deletions GenshinUID/utils/ambr_to_minigg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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']]
Expand All @@ -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)

Expand Down Expand Up @@ -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)
3 changes: 2 additions & 1 deletion GenshinUID/utils/map/data/char_alias.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@
"紫茄子",
"阿忍",
"忍姐",
"九岐忍"
"九岐忍",
"九七人"
],
"神里绫人": [
"Kamisato Ayato",
Expand Down

0 comments on commit 291bdf8

Please sign in to comment.