diff --git a/none/natural_language.py b/none/natural_language.py index dc2d7fa6..72576576 100644 --- a/none/natural_language.py +++ b/none/natural_language.py @@ -80,8 +80,12 @@ async def handle_natural_language(bot: NoneBot, ctx: Dict[str, Any]) -> bool: """ msg = str(ctx['message']) if bot.config.NICKNAME: - # check if the user is calling to me with my nickname - m = re.search(rf'^{bot.config.NICKNAME}[\s,,]+', msg) + # check if the user is calling me with my nickname + if not isinstance(bot.config.NICKNAME, Iterable): + nicknames = (bot.config.NICKNAME,) + else: + nicknames = filter(lambda n: n, bot.config.NICKNAME) + m = re.search(rf'^({"|".join(nicknames)})[\s,,]+', msg) if m: ctx['to_me'] = True msg = msg[m.end():] diff --git a/none_demo/config.py b/none_demo/config.py index 7eaf9195..8feaebe2 100644 --- a/none_demo/config.py +++ b/none_demo/config.py @@ -6,6 +6,6 @@ HOST = '0.0.0.0' SECRET = 'abc' SUPERUSERS = {1002647525} -NICKNAME = '奶茶' +NICKNAME = {'奶茶', '小奶茶'} COMMAND_START = {'', '/', '!', '/', '!', re.compile(r'^>+\s*')} COMMAND_SEP = {'/', '.', re.compile(r'#|::?')}