2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +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.
"""
def f(_, m):
m.matches = [i for i in _.p.finditer(m.text or m.caption or "")]
return bool(m.matches)
def func(flt, message):
text = message.text or message.caption
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
class user(Filter, set):