From fcb1c5d3160697d4e49db673a38bf89a26401a8e Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Thu, 1 Apr 2021 20:05:31 +0800 Subject: [PATCH] :ambulance: fix matcher got recursion --- nonebot/matcher.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nonebot/matcher.py b/nonebot/matcher.py index 771fcc65..399ae8a4 100644 --- a/nonebot/matcher.py +++ b/nonebot/matcher.py @@ -418,6 +418,7 @@ class Matcher(metaclass=MatcherMeta): def _decorator(func: T_Handler) -> T_Handler: if not hasattr(cls.handlers[-1], "__wrapped__"): parser = cls.handlers.pop() + func_handler = Handler(func) @wraps(func) async def wrapper(bot: "Bot", event: "Event", state: T_State, @@ -427,12 +428,14 @@ class Matcher(metaclass=MatcherMeta): if "_current_key" in state: del state["_current_key"] - func_handler = cls.append_handler(wrapper) + wrapper_handler = cls.append_handler(wrapper) - getter_handler.update_signature(bot=func_handler.bot_type, - event=func_handler.event_type) - parser_handler.update_signature(bot=func_handler.bot_type, - event=func_handler.event_type) + getter_handler.update_signature( + bot=wrapper_handler.bot_type, + event=wrapper_handler.event_type) + parser_handler.update_signature( + bot=wrapper_handler.bot_type, + event=wrapper_handler.event_type) return func