diff --git a/Paimon_Info/__init__.py b/Paimon_Info/__init__.py index dfa5e47..c90ed56 100644 --- a/Paimon_Info/__init__.py +++ b/Paimon_Info/__init__.py @@ -563,15 +563,19 @@ async def _(event: MessageEvent, state: T_State, msg: Message = CommandArg()): if msg_seg.type == "at": user = msg_seg.data['qq'] if user: - state['uid'] = await get_last_query(str(user)) + uid = await get_last_query(str(user)) + if uid: + state['uid'] = uid else: - state['uid'] = await get_last_query(str(event.user_id)) + uid = await get_last_query(str(event.user_id)) + if uid: + state['uid'] = uid msg = msg.extract_plain_text().replace(state['uid'], '').strip() if not msg: await role_info.finish('请把要查询角色名给派蒙哦~') else: match_alias = get_match_alias(msg, 'roles', True) - state['role'] = tuple(match_alias.keys())[0] + state['role'] = match_alias if isinstance(match_alias, str) else tuple(match_alias.keys())[0] @role_info.got('uid', prompt='请把要查询的uid给派蒙哦~') diff --git a/utils/alias_handler.py b/utils/alias_handler.py index 6f21c87..634e22a 100644 --- a/utils/alias_handler.py +++ b/utils/alias_handler.py @@ -58,13 +58,10 @@ def get_match_alias(msg: str, type: str = 'roles', single_to_dict: bool = False) for role_id, alias in alias_list.items(): match_list = difflib.get_close_matches(msg, alias, cutoff=0.6, n=3) if msg in match_list: - if single_to_dict: - return {alias[0]: role_id} - else: - return alias[0] + return {alias[0]: role_id} if single_to_dict else alias[0] elif match_list: if len(match_list) == 1: - return alias[0] + return {alias[0]: role_id} if single_to_dict else alias[0] possible[alias[0]] = role_id return possible elif type == 'weapons':