From b4bc7deba0de5e21101542473315e671a08ccc44 Mon Sep 17 00:00:00 2001 From: Furoin Date: Thu, 8 Nov 2018 17:11:43 +0300 Subject: [PATCH 1/3] added Filters.user("me") --- pyrogram/client/filters/filters.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 57e48948..9105543c 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -288,9 +288,9 @@ class Filters: def __init__(self, users: int or str or list = None): users = [] if users is None else users if type(users) is list else [users] super().__init__( - {i.lower().strip("@") if type(i) is str else i for i in users} + {"me" if i in ["me", "self"] else i.lower().strip("@") if type(i) is str else i for i in users} if type(users) is list else - {users.lower().strip("@") if type(users) is str else users} + {"me" if users in ["me", "self"] else users.lower().strip("@") if type(users) is str else users} ) def __call__(self, message): @@ -298,7 +298,9 @@ class Filters: message.from_user and (message.from_user.id in self or (message.from_user.username - and message.from_user.username.lower() in self)) + and message.from_user.username.lower() in self) + or ("me" in self + and message.from_user.is_self)) ) # noinspection PyPep8Naming From 803f36412f1f4b34cbfe713ffff0ec3f5fb8569c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 8 Nov 2018 20:24:54 +0100 Subject: [PATCH 2/3] Update Filters.user docstrings --- pyrogram/client/filters/filters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 9105543c..53081a04 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -282,6 +282,7 @@ class Filters: Args: users (``int`` | ``str`` | ``list``): Pass one or more user ids/usernames to filter users. + For you yourself, "me" or "self" can be used as well. Defaults to None (no users). """ From 80726784e57a4e424a84eb0745a3e44b6364bf0a Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 8 Nov 2018 20:25:35 +0100 Subject: [PATCH 3/3] Fix Filters.chat docstrings using unusual double quotes --- pyrogram/client/filters/filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 53081a04..6042173f 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -314,7 +314,7 @@ class Filters: Args: chats (``int`` | ``str`` | ``list``): Pass one or more chat ids/usernames to filter chats. - For your personal cloud (Saved Messages) you can simply use “me” or “self”. + For your personal cloud (Saved Messages) you can simply use "me" or "self". Defaults to None (no chats). """