mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-10-30 22:46:40 +00:00 
			
		
		
		
	🐛 fix nickname
This commit is contained in:
		| @@ -182,13 +182,13 @@ def _check_nickname(bot: "Bot", event: "Event"): | ||||
|  | ||||
|     first_text = first_msg_seg.data["text"] | ||||
|  | ||||
|     if bot.config.NICKNAME: | ||||
|     if bot.config.nickname: | ||||
|         # check if the user is calling me with my nickname | ||||
|         if isinstance(bot.config.NICKNAME, str) or \ | ||||
|                 not isinstance(bot.config.NICKNAME, Iterable): | ||||
|             nicknames = (bot.config.NICKNAME,) | ||||
|         if isinstance(bot.config.nickname, str) or \ | ||||
|                 not isinstance(bot.config.nickname, Iterable): | ||||
|             nicknames = (bot.config.nickname,) | ||||
|         else: | ||||
|             nicknames = filter(lambda n: n, bot.config.NICKNAME) | ||||
|             nicknames = filter(lambda n: n, bot.config.nickname) | ||||
|         nickname_regex = "|".join(nicknames) | ||||
|         m = re.search(rf"^({nickname_regex})([\s,,]*|$)", first_text, | ||||
|                       re.IGNORECASE) | ||||
|   | ||||
| @@ -211,10 +211,10 @@ class Config(BaseConfig): | ||||
|  | ||||
|         SUPER_USERS=[12345789] | ||||
|     """ | ||||
|     nickname: Union[str, Set[str]] = "" | ||||
|     nickname: Set[str] = set() | ||||
|     """ | ||||
|     - 类型: ``Union[str, Set[str]]`` | ||||
|     - 默认值: ``""`` | ||||
|     - 类型: ``Set[str]`` | ||||
|     - 默认值: ``set()`` | ||||
|     - 说明: | ||||
|       机器人昵称。 | ||||
|     """ | ||||
|   | ||||
| @@ -4,6 +4,7 @@ PORT=2333 | ||||
| DEBUG=true | ||||
|  | ||||
| SUPERUSERS=[123123123] | ||||
| NICKNAME=["bot"] | ||||
|  | ||||
| COMMAND_START=["", "/", "#"] | ||||
| COMMAND_SEP=["/", "."] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user