🐛 change matcher check-run

This commit is contained in:
yanyongyu
2021-02-01 11:42:05 +08:00
parent b140ebd149
commit f6c24ec92f
2 changed files with 26 additions and 40 deletions

View File

@ -282,7 +282,8 @@ def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule:
根据正则表达式进行匹配。
可以通过 ``state["_matched"]`` 获取正则表达式匹配成功的文本。
可以通过 ``state["_matched"]`` ``state["_matched_groups"]`` ``state["_matched_dict"]``
获取正则表达式匹配成功的文本。
:参数:
@ -302,9 +303,13 @@ def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule:
matched = pattern.search(str(event.get_message()))
if matched:
state["_matched"] = matched.group()
state["_matched_groups"] = matched.groups()
state["_matched_dict"] = matched.groupdict()
return True
else:
state["_matched"] = None
state["_matched_groups"] = None
state["_matched_dict"] = None
return False
return Rule(_regex)