mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-01 23:05:15 +00:00
Add user filter
This commit is contained in:
@@ -73,3 +73,17 @@ class Filters:
|
||||
"Regex", lambda _, m: bool(_.p.search(m.text or "")),
|
||||
p=re.compile(pattern, flags)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def user(user: int or str or list()):
|
||||
return build(
|
||||
"User",
|
||||
lambda _, m: bool(m.from_user
|
||||
and (m.from_user.id in _.u
|
||||
or m.from_user.username.lower() in _.u)),
|
||||
u=(
|
||||
{user.lower().strip("@") if type(user) is str else user}
|
||||
if not isinstance(user, list)
|
||||
else {i.lower().strip("@") if type(i) is str else i for i in user}
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user