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