🚧 change result store

This commit is contained in:
Ju4tCode
2020-10-28 13:45:54 +08:00
committed by GitHub
parent 47f491039c
commit c3bd8ebf57

View File

@ -236,7 +236,7 @@ def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule:
:说明: :说明:
根据正则表达式进行匹配。 根据正则表达式进行匹配。
可以通过 ``state["matched"]`` 获取正则表达式匹配成功的文本。 可以通过 ``state["_matched"]`` 获取正则表达式匹配成功的文本。
:参数: :参数:
* ``regex: str``: 正则表达式 * ``regex: str``: 正则表达式
* ``flags: Union[int, re.RegexFlag]``: 正则标志 * ``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: async def _regex(bot: Bot, event: Event, state: dict) -> bool:
matched = pattern.search(str(event.message)) matched = pattern.search(str(event.message))
if matched: if matched:
state["matched"] = matched.group() state["_matched"] = matched.group()
return True return True
else: else:
state["_matched"] = None
return False return False
return Rule(_regex) return Rule(_regex)