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 media_type = enums.MessageMediaType.DOCUMENT
elif isinstance(media, raw.types.MessageMediaWebPage): elif isinstance(media, raw.types.MessageMediaWebPage):
if isinstance(media.webpage, raw.types.WebPage): 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 media_type = enums.MessageMediaType.WEB_PAGE
else: else:
media = None media = None

View File

@ -81,16 +81,17 @@ class WebPage(Object):
Whether the webpage preview is large. Whether the webpage preview is large.
force_large_media (``bool``, *optional*): force_large_media (``bool``, *optional*):
If True, media in the link preview will be larger. Whether the webpage preview is forced large.
Ignored if the URL isn't explicitly specified or media size change isn't supported for the preview.
force_small_media (``bool``, *optional*): force_small_media (``bool``, *optional*):
If True, media in the link preview will be smaller. Whether the webpage preview is forced small.
Ignored if the URL isn't explicitly specified or media size change isn't supported for the preview.
manual (``bool``, *optional*): manual (``bool``, *optional*):
Whether the webpage preview was changed by the user. Whether the webpage preview was changed by the user.
safe (``bool``, *optional*):
Whether the webpage preview is safe.
duration (``int``, *optional*): duration (``int``, *optional*):
Unknown at the time of writing. Unknown at the time of writing.
@ -122,6 +123,7 @@ class WebPage(Object):
force_large_media: bool = None, force_large_media: bool = None,
force_small_media: bool = None, force_small_media: bool = None,
manual: bool = None, manual: bool = None,
safe: bool = None,
duration: int = None, duration: int = None,
author: str = None author: str = None
): ):
@ -147,6 +149,7 @@ class WebPage(Object):
self.force_large_media = force_large_media self.force_large_media = force_large_media
self.force_small_media = force_small_media self.force_small_media = force_small_media
self.manual = manual self.manual = manual
self.safe = safe
self.duration = duration self.duration = duration
self.author = author self.author = author
@ -156,7 +159,8 @@ class WebPage(Object):
webpage: "raw.types.WebPage", webpage: "raw.types.WebPage",
force_large_media: bool = None, force_large_media: bool = None,
force_small_media: bool = None, force_small_media: bool = None,
manual: bool = None manual: bool = None,
safe: bool = None
) -> "WebPage": ) -> "WebPage":
audio = None audio = None
document = None document = None
@ -214,6 +218,7 @@ class WebPage(Object):
force_large_media=force_large_media, force_large_media=force_large_media,
force_small_media=force_small_media, force_small_media=force_small_media,
manual=manual, manual=manual,
safe=safe,
duration=webpage.duration, duration=webpage.duration,
author=webpage.author author=webpage.author
) )