mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
Allow no space nor comma between nickname and message body
This commit is contained in:
parent
0fd3cc0365
commit
fdc7327a0c
@ -115,7 +115,7 @@ async def handle_natural_language(bot: NoneBot, ctx: Context_T) -> bool:
|
||||
else:
|
||||
nicknames = filter(lambda n: n, bot.config.NICKNAME)
|
||||
nickname_regex = '|'.join(nicknames)
|
||||
m = re.search(rf'^({nickname_regex})([\s,,]|$)', msg, re.IGNORECASE)
|
||||
m = re.search(rf'^({nickname_regex})([\s,,]*|$)', msg, re.IGNORECASE)
|
||||
if m:
|
||||
nickname = m.group(1)
|
||||
logger.debug(f'User is calling me {nickname}')
|
||||
|
Loading…
Reference in New Issue
Block a user