From 557054cb8b2da9223241d395d408c90ee6610f37 Mon Sep 17 00:00:00 2001 From: Muchan Date: Thu, 19 Nov 2020 20:53:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(message):=20=E4=BC=A0=E9=80=92matcher?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E7=9A=84StopPropagation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot/message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nonebot/message.py b/nonebot/message.py index 90af9a96..ffd26b81 100644 --- a/nonebot/message.py +++ b/nonebot/message.py @@ -149,6 +149,8 @@ async def _run_matcher(Matcher: Type[Matcher], bot: Bot, event: Event, try: logger.debug(f"Running matcher {matcher}") await matcher.run(bot, event, state) + except StopPropagation as e: + exception = e except Exception as e: logger.opt(colors=True, exception=e).error( f"Running matcher {matcher} failed." @@ -166,7 +168,7 @@ async def _run_matcher(Matcher: Type[Matcher], bot: Bot, event: Event, "Error when running RunPostProcessors" ) - if matcher.block: + if matcher.block or isinstance(exception, StopPropagation): raise StopPropagation