mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
Refactor regex filter
This commit is contained in:
parent
af1bb3b0a7
commit
776557f60b
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user