From 61f2d7c968a089caf714ed943cab0c8eae86b268 Mon Sep 17 00:00:00 2001 From: zeroone2numeral2 Date: Sun, 25 Nov 2018 16:56:39 +0000 Subject: [PATCH 1/3] Added web_page attribute to Message object --- pyrogram/client/ext/utils.py | 4 ++++ pyrogram/client/types/messages_and_media/message.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py index a543e6b5..9cce212d 100644 --- a/pyrogram/client/ext/utils.py +++ b/pyrogram/client/ext/utils.py @@ -327,6 +327,7 @@ def parse_messages( video_note = None sticker = None document = None + web_page = None media = message.media @@ -574,6 +575,8 @@ def parse_messages( file_size=doc.size, date=doc.date ) + elif isinstance(media, types.MessageMediaWebPage): + web_page = True else: media = None @@ -621,6 +624,7 @@ def parse_messages( video_note=video_note, sticker=sticker, document=document, + web_page=web_page, views=message.views, via_bot=parse_user(users.get(message.via_bot_id, None)), outgoing=message.out, diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 404ad39d..19bdd067 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -134,6 +134,9 @@ class Message(Object): venue (:obj:`Venue `, *optional*): Message is a venue, information about the venue. + web_page (``bool``, *optional*): + Message was sent with a webpage preview. + new_chat_members (List of :obj:`User `, *optional*): New members that were added to the group or supergroup and information about them (the bot itself may be one of these members). @@ -246,6 +249,7 @@ class Message(Object): contact=None, location=None, venue=None, + web_page=None, new_chat_members: list = None, left_chat_member=None, new_chat_title: str = None, @@ -297,6 +301,7 @@ class Message(Object): self.contact = contact # flags.22?Contact self.location = location # flags.23?Location self.venue = venue # flags.24?Venue + self.web_page = web_page self.new_chat_members = new_chat_members # flags.25?Vector self.left_chat_member = left_chat_member # flags.26?User self.new_chat_title = new_chat_title # flags.27?string From 2d1a7871ea068165093b3d047be05a1dad2268c5 Mon Sep 17 00:00:00 2001 From: zeroone2numeral2 Date: Sun, 25 Nov 2018 17:05:59 +0000 Subject: [PATCH 2/3] Added Filters.web_page --- pyrogram/client/filters/filters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 6042173f..9ae15239 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -118,6 +118,9 @@ class Filters: venue = create("Venue", lambda _, m: bool(m.venue)) """Filter messages that contain :obj:`Venue ` objects.""" + web_page = create("WebPage", lambda _, m: m.web_page) + """Filter messages sent with a webpage preview.""" + private = create("Private", lambda _, m: bool(m.chat and m.chat.type == "private")) """Filter messages sent in private chats.""" From ac8fc58a06f80eb75c30a3d8db2a061f5eb34929 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 8 Dec 2018 16:41:30 +0100 Subject: [PATCH 3/3] Add a note hinting about basic support for web pages --- pyrogram/client/types/messages_and_media/message.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 19bdd067..2c7a97ff 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -136,6 +136,9 @@ class Message(Object): web_page (``bool``, *optional*): Message was sent with a webpage preview. + **Note:** Support for web pages is still basic; a simple boolean is set in case the message contains a + web page preview. In future versions this property could turn into a full web page object that contains + more details. new_chat_members (List of :obj:`User `, *optional*): New members that were added to the group or supergroup and information about them