Skip to content

Commit

Permalink
Add missing attributes to the WebPage type
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Jan 2, 2024
1 parent cce4c29 commit aaf2509
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,14 @@ async def _parse(
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
Expand Down
15 changes: 10 additions & 5 deletions pyrogram/types/messages_and_media/web_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -122,6 +123,7 @@ def __init__(
force_large_media: bool = None,
force_small_media: bool = None,
manual: bool = None,
safe: bool = None,
duration: int = None,
author: str = None
):
Expand All @@ -147,6 +149,7 @@ def __init__(
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

Expand All @@ -156,7 +159,8 @@ def _parse(
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
Expand Down Expand Up @@ -214,6 +218,7 @@ def _parse(
force_large_media=force_large_media,
force_small_media=force_small_media,
manual=manual,
safe=safe,
duration=webpage.duration,
author=webpage.author
)

0 comments on commit aaf2509

Please sign in to comment.