From 3a1233488fed4da7567483ce6a58cd823dd917e3 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Sat, 17 Dec 2022 18:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BC=98=E5=8C=96`Wiki`=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Genshin_Voice/__init__.py | 2 +- LittlePaimon/plugins/Paimon_Wiki/__init__.py | 12 +++++++++++- LittlePaimon/utils/message.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LittlePaimon/plugins/Genshin_Voice/__init__.py b/LittlePaimon/plugins/Genshin_Voice/__init__.py index 81cf7ed..bd06924 100644 --- a/LittlePaimon/plugins/Genshin_Voice/__init__.py +++ b/LittlePaimon/plugins/Genshin_Voice/__init__.py @@ -78,7 +78,7 @@ async def _(event: Union[GroupMessageEvent, PrivateMessageEvent], lang=CommandLa await get_voice.finish(MessageBuild.Record(voice.voice_url) if voice else MessageBuild.Text(f'没有{msg}号原神语音')) else: if chara := get_match_alias(msg, ['角色'], True): - chara = list(chara.keys())[0] + chara = chara[0] else: await get_voice.finish(MessageBuild.Text(f'没有叫{chara}的角色')) voices = await GenshinVoice.filter(character=chara, language=lang).all() diff --git a/LittlePaimon/plugins/Paimon_Wiki/__init__.py b/LittlePaimon/plugins/Paimon_Wiki/__init__.py index 8976487..d2df278 100644 --- a/LittlePaimon/plugins/Paimon_Wiki/__init__.py +++ b/LittlePaimon/plugins/Paimon_Wiki/__init__.py @@ -262,11 +262,21 @@ async def _(event: MessageEvent, state: T_State, type: str = Arg('type'), name: elif type.startswith('七圣召唤'): matches = await get_match_card(name) else: + if alias := await PlayerAlias.get_or_none(user_id=str(event.user_id), alias=name): + final_name = alias.character + if type in {'材料', '攻略', '图鉴'}: + type = f'角色{type}' + try: + await total_wiki.finish( + MessageSegment.image(API[type].format(proxy=config.github_proxy, name=final_name))) + except ActionFailed: + await total_wiki.finish( + MessageBuild.Text(f'{final_name}的{type}发送失败,可能是网络问题或者不存在该资源')) matches = get_match_alias(name, ['角色', '武器', '原魔', '圣遗物']) if m := await get_match_card(name): matches['七圣召唤'] = m if not matches: - await total_wiki.finish() + await total_wiki.finish(MessageBuild.Text(f'没有名为{name}的{type}哦,是不是打错了~'), at_sender=True) elif len(matches) == 1 and len(list(matches.values())[0]) == 1: final_name = list(matches.values())[0][0] temp_type = list(matches.keys())[0] diff --git a/LittlePaimon/utils/message.py b/LittlePaimon/utils/message.py index 39eea66..e8db916 100644 --- a/LittlePaimon/utils/message.py +++ b/LittlePaimon/utils/message.py @@ -211,7 +211,7 @@ def CommandCharacter(limit: int = 3) -> List[str]: msg.replace(character_name, '') # 如果有匹配别名 elif character_match := get_match_alias(character_name, ['角色'], True): - character_list.append(list(character_match.keys())[0]) + character_list.append(character_match[0]) msg.replace(character_name, '') # 没有匹配到角色时,结束事件 if not character_list: