mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-10-31 06:56:39 +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"] |     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 |         # check if the user is calling me with my nickname | ||||||
|         if isinstance(bot.config.NICKNAME, str) or \ |         if isinstance(bot.config.nickname, str) or \ | ||||||
|                 not isinstance(bot.config.NICKNAME, Iterable): |                 not isinstance(bot.config.nickname, Iterable): | ||||||
|             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) | ||||||
|         nickname_regex = "|".join(nicknames) |         nickname_regex = "|".join(nicknames) | ||||||
|         m = re.search(rf"^({nickname_regex})([\s,,]*|$)", first_text, |         m = re.search(rf"^({nickname_regex})([\s,,]*|$)", first_text, | ||||||
|                       re.IGNORECASE) |                       re.IGNORECASE) | ||||||
|   | |||||||
| @@ -211,10 +211,10 @@ class Config(BaseConfig): | |||||||
|  |  | ||||||
|         SUPER_USERS=[12345789] |         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 | DEBUG=true | ||||||
|  |  | ||||||
| SUPERUSERS=[123123123] | SUPERUSERS=[123123123] | ||||||
|  | NICKNAME=["bot"] | ||||||
|  |  | ||||||
| COMMAND_START=["", "/", "#"] | COMMAND_START=["", "/", "#"] | ||||||
| COMMAND_SEP=["/", "."] | COMMAND_SEP=["/", "."] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user