mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-03-03 04:13:53 +08:00
Fix nickname matching bug
This commit is contained in:
parent
89f49bde41
commit
ecb48c8ffa
@ -95,10 +95,11 @@ async def handle_natural_language(bot: NoneBot, ctx: Context_T) -> bool:
|
|||||||
nicknames = (bot.config.NICKNAME,)
|
nicknames = (bot.config.NICKNAME,)
|
||||||
else:
|
else:
|
||||||
nicknames = filter(lambda n: n, bot.config.NICKNAME)
|
nicknames = filter(lambda n: n, bot.config.NICKNAME)
|
||||||
m = re.search(rf'^{"|".join(nicknames)}([\s,,]|$)',
|
nickname_regex = '|'.join(nicknames)
|
||||||
msg, re.IGNORECASE)
|
m = re.search(rf'^({nickname_regex})([\s,,]|$)', msg, re.IGNORECASE)
|
||||||
if m:
|
if m:
|
||||||
logger.debug(f'User is calling me {m.group(1)}')
|
nickname = m.group(1)
|
||||||
|
logger.debug(f'User is calling me {nickname}')
|
||||||
ctx['to_me'] = True
|
ctx['to_me'] = True
|
||||||
msg = msg[m.end():]
|
msg = msg[m.end():]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user