mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
fix bug
This commit is contained in:
parent
e7f26925ed
commit
c417d15ed1
@ -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给派蒙哦~')
|
||||
|
@ -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':
|
||||
|
Loading…
Reference in New Issue
Block a user