From 80f8010d50b17f7cb68b0ad5b2f5ba184293a451 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 10 Nov 2020 18:43:47 +0100 Subject: [PATCH] Add support for pinned messages in search_messages --- pyrogram/methods/messages/search_messages.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyrogram/methods/messages/search_messages.py b/pyrogram/methods/messages/search_messages.py index 8744fe81..9389c9df 100644 --- a/pyrogram/methods/messages/search_messages.py +++ b/pyrogram/methods/messages/search_messages.py @@ -41,6 +41,7 @@ class Filters: MENTION = raw.types.InputMessagesFilterMyMentions() LOCATION = raw.types.InputMessagesFilterGeo() CONTACT = raw.types.InputMessagesFilterContacts() + PINNED = raw.types.InputMessagesFilterPinned() POSSIBLE_VALUES = list(map(lambda x: x.lower(), filter(lambda x: not x.startswith("__"), Filters.__dict__.keys()))) @@ -135,6 +136,7 @@ class SearchMessages(Scaffold): - ``"mention"``: Search for messages containing mentions to yourself. - ``"location"``: Search for location messages. - ``"contact"``: Search for contact messages. + - ``"pinned"``: Search for pinned messages. limit (``int``, *optional*): Limits the number of messages to be retrieved. @@ -153,8 +155,12 @@ class SearchMessages(Scaffold): for message in app.search_messages("pyrogramchat", query="dan", limit=333): print(message.text) - # Search for photos sent by @haskell in @pyrogramchat - for message in app.search_messages("pyrogramchat", "", filter="photo" limit=333, from_user="haskell"): + # Search for pinned messages in @pyrogramchat + for message in app.search_messages("pyrogramchat", filter="pinned"): + print(message.text) + + # Search for messages containing "hi" sent by @haskell in @pyrogramchat + for message in app.search_messages("pyrogramchat", "hi", from_user="haskell"): print(message.text) """ current = 0