From c3bd8ebf57d73dc91d5658bfd45c5b75dd7fe010 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 28 Oct 2020 13:45:54 +0800 Subject: [PATCH] :construction: change result store --- nonebot/rule.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nonebot/rule.py b/nonebot/rule.py index 6694c2b2..4bb4063d 100644 --- a/nonebot/rule.py +++ b/nonebot/rule.py @@ -236,7 +236,7 @@ def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule: :说明: 根据正则表达式进行匹配。 - 可以通过 ``state["matched"]`` 获取正则表达式匹配成功的文本。 + 可以通过 ``state["_matched"]`` 获取正则表达式匹配成功的文本。 :参数: * ``regex: str``: 正则表达式 * ``flags: Union[int, re.RegexFlag]``: 正则标志 @@ -251,9 +251,10 @@ def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule: async def _regex(bot: Bot, event: Event, state: dict) -> bool: matched = pattern.search(str(event.message)) if matched: - state["matched"] = matched.group() + state["_matched"] = matched.group() return True else: + state["_matched"] = None return False return Rule(_regex)