From f6788bdf02126172abdfb9bf43971a9d1b31f6af Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Tue, 2 Jan 2024 14:22:30 +0300 Subject: [PATCH] Add missing attributes to the WebPage type --- pyrogram/types/messages_and_media/message.py | 9 ++++++++- pyrogram/types/messages_and_media/web_page.py | 15 ++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index ad3cad89..93b38fa5 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -939,7 +939,14 @@ class Message(Object, Update): media_type = enums.MessageMediaType.DOCUMENT elif isinstance(media, raw.types.MessageMediaWebPage): if isinstance(media.webpage, raw.types.WebPage): - web_page = types.WebPage._parse(client, media.webpage, media.force_large_media, media.force_small_media, media.manual) + web_page = types.WebPage._parse( + client, + media.webpage, + getattr(media, "force_large_media", None), + getattr(media, "force_small_media", None), + getattr(media, "manual", None), + getattr(media, "safe", None) + ) media_type = enums.MessageMediaType.WEB_PAGE else: media = None diff --git a/pyrogram/types/messages_and_media/web_page.py b/pyrogram/types/messages_and_media/web_page.py index 42fa34ac..9cf55478 100644 --- a/pyrogram/types/messages_and_media/web_page.py +++ b/pyrogram/types/messages_and_media/web_page.py @@ -81,16 +81,17 @@ class WebPage(Object): Whether the webpage preview is large. force_large_media (``bool``, *optional*): - If True, media in the link preview will be larger. - Ignored if the URL isn't explicitly specified or media size change isn't supported for the preview. + Whether the webpage preview is forced large. force_small_media (``bool``, *optional*): - If True, media in the link preview will be smaller. - Ignored if the URL isn't explicitly specified or media size change isn't supported for the preview. + Whether the webpage preview is forced small. manual (``bool``, *optional*): Whether the webpage preview was changed by the user. + safe (``bool``, *optional*): + Whether the webpage preview is safe. + duration (``int``, *optional*): Unknown at the time of writing. @@ -122,6 +123,7 @@ class WebPage(Object): force_large_media: bool = None, force_small_media: bool = None, manual: bool = None, + safe: bool = None, duration: int = None, author: str = None ): @@ -147,6 +149,7 @@ class WebPage(Object): self.force_large_media = force_large_media self.force_small_media = force_small_media self.manual = manual + self.safe = safe self.duration = duration self.author = author @@ -156,7 +159,8 @@ class WebPage(Object): webpage: "raw.types.WebPage", force_large_media: bool = None, force_small_media: bool = None, - manual: bool = None + manual: bool = None, + safe: bool = None ) -> "WebPage": audio = None document = None @@ -214,6 +218,7 @@ class WebPage(Object): force_large_media=force_large_media, force_small_media=force_small_media, manual=manual, + safe=safe, duration=webpage.duration, author=webpage.author )