From 793ecc2ab5640fb350064e6731668381aaef31d7 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 10 Apr 2018 16:24:39 +0200 Subject: [PATCH] Add user filter --- pyrogram/client/filters/filters.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 36046185..1a70f130 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -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} + ) + )