Add missing attributes to the WebPage type

This commit is contained in:
KurimuzonAkuma 2024-01-02 14:22:30 +03:00
parent 5e88c6d028
commit f6788bdf02
2 changed files with 18 additions and 6 deletions

View File

@ -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

View File

@ -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
)