mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-10-31 06:56:39 +00:00 
			
		
		
		
	🐛 fix got handler running more than once
This commit is contained in:
		| @@ -456,7 +456,8 @@ class Matcher(metaclass=MatcherMeta): | ||||
|         parser_handler = cls.append_handler(_key_parser) | ||||
|  | ||||
|         def _decorator(func: T_Handler) -> T_Handler: | ||||
|             if not hasattr(cls.handlers[-1], "__wrapped__"): | ||||
|             print("deco", key, hasattr(cls.handlers[-1].func, "__wrapped__")) | ||||
|             if not hasattr(cls.handlers[-1].func, "__wrapped__"): | ||||
|                 parser = cls.handlers.pop() | ||||
|                 func_handler = Handler(func) | ||||
|  | ||||
|   | ||||
| @@ -405,10 +405,14 @@ def on_command(cmd: Union[str, Tuple[str, ...]], | ||||
|  | ||||
|     async def _strip_cmd(bot: "Bot", event: "Event", state: T_State): | ||||
|         message = event.get_message() | ||||
|         if len(message) < 1: | ||||
|             return | ||||
|         segment = message.pop(0) | ||||
|         segment_text = str(segment).lstrip() | ||||
|         if not segment_text.startswith(state["_prefix"]["raw_command"]): | ||||
|             return | ||||
|         new_message = message.__class__( | ||||
|             str(segment).lstrip() | ||||
|             [len(state["_prefix"]["raw_command"]):].lstrip())  # type: ignore | ||||
|             segment_text[len(state["_prefix"]["raw_command"]):].lstrip()) | ||||
|         for new_segment in reversed(new_message): | ||||
|             message.insert(0, new_segment) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user