From 1adc8121080ff71f247cee6afac52647cf9c42d9 Mon Sep 17 00:00:00 2001 From: Furoin Date: Tue, 6 Nov 2018 18:36:40 +0300 Subject: [PATCH 1/2] added Filters.chat("me") --- pyrogram/client/filters/filters.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index aeb730a7..037e6bb9 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -287,9 +287,9 @@ class Filters: def __init__(self, chats: int or str or list = None): chats = [] if chats is None else chats if type(chats) is list else [chats] super().__init__( - {i.lower().strip("@") if type(i) is str else i for i in chats} + {"me" if i in ["me", "self"] else i.lower().strip("@") if type(i) is str else i for i in chats} if type(chats) is list else - {chats.lower().strip("@") if type(chats) is str else chats} + {"me" if chats in ["me", "self"] else chats.lower().strip("@") if type(chats) is str else chats} ) def __call__(self, message): @@ -297,7 +297,10 @@ class Filters: message.chat and (message.chat.id in self or (message.chat.username - and message.chat.username.lower() in self)) + and message.chat.username.lower() in self) + or ("me" in self and message.from_user + and message.from_user.is_self + and not message.outgoing)) ) service = create( From 5efd608487f454efaf7a6939355eefd3f49acc10 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 6 Nov 2018 17:40:37 +0100 Subject: [PATCH 2/2] Update Filters.chat 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 037e6bb9..77ebb771 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -281,6 +281,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”. Defaults to None (no chats). """