2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Refactor regex filter

This commit is contained in:
Dan 2019-07-22 13:31:50 +02:00
parent af1bb3b0a7
commit 776557f60b

View File

@ -273,11 +273,15 @@ class Filters:
RegEx flags. RegEx flags.
""" """
def f(_, m): def func(flt, message):
m.matches = [i for i in _.p.finditer(m.text or m.caption or "")] text = message.text or message.caption
return bool(m.matches)
return create(f, "RegexFilter", p=re.compile(pattern, flags)) if text:
message.matches = list(flt.p.finditer(text)) or None
return bool(message.matches)
return create(func, "RegexFilter", p=re.compile(pattern, flags))
# noinspection PyPep8Naming # noinspection PyPep8Naming
class user(Filter, set): class user(Filter, set):