From c707a4baaee5cccb79c618f715020983b966b8bf Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:08:55 +0100 Subject: [PATCH] Add the parameter has_spoiler to relevant send_* media methods - send_photo() - send_video() - send_animation() --- pyrogram/methods/messages/send_animation.py | 9 ++++++++- pyrogram/methods/messages/send_photo.py | 13 ++++++++++--- pyrogram/methods/messages/send_video.py | 9 ++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pyrogram/methods/messages/send_animation.py b/pyrogram/methods/messages/send_animation.py index ec85dc05..bac16bac 100644 --- a/pyrogram/methods/messages/send_animation.py +++ b/pyrogram/methods/messages/send_animation.py @@ -39,6 +39,7 @@ class SendAnimation: unsave: bool = False, parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, + has_spoiler: bool = None, duration: int = 0, width: int = 0, height: int = 0, @@ -88,6 +89,9 @@ class SendAnimation: caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): List of special entities that appear in the caption, which can be specified instead of *parse_mode*. + has_spoiler (``bool``, *optional*): + Pass True if the animation needs to be covered with a spoiler animation. + duration (``int``, *optional*): Duration of sent animation in seconds. @@ -180,6 +184,7 @@ class SendAnimation: mime_type=self.guess_mime_type(animation) or "video/mp4", file=file, thumb=thumb, + spoiler=has_spoiler, attributes=[ raw.types.DocumentAttributeVideo( supports_streaming=True, @@ -193,7 +198,8 @@ class SendAnimation: ) elif re.match("^https?://", animation): media = raw.types.InputMediaDocumentExternal( - url=animation + url=animation, + spoiler=has_spoiler ) else: media = utils.get_input_media_from_file_id(animation, FileType.ANIMATION) @@ -204,6 +210,7 @@ class SendAnimation: mime_type=self.guess_mime_type(file_name or animation.name) or "video/mp4", file=file, thumb=thumb, + spoiler=has_spoiler, attributes=[ raw.types.DocumentAttributeVideo( supports_streaming=True, diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py index 994f0c93..61298a5c 100644 --- a/pyrogram/methods/messages/send_photo.py +++ b/pyrogram/methods/messages/send_photo.py @@ -37,6 +37,7 @@ class SendPhoto: caption: str = "", parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, + has_spoiler: bool = None, ttl_seconds: int = None, disable_notification: bool = None, reply_to_message_id: int = None, @@ -78,6 +79,9 @@ class SendPhoto: caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): List of special entities that appear in the caption, which can be specified instead of *parse_mode*. + has_spoiler (``bool``, *optional*): + Pass True if the photo needs to be covered with a spoiler animation. + ttl_seconds (``int``, *optional*): Self-Destruct Timer. If you set a timer, the photo will self-destruct in *ttl_seconds* @@ -149,12 +153,14 @@ class SendPhoto: file = await self.save_file(photo, progress=progress, progress_args=progress_args) media = raw.types.InputMediaUploadedPhoto( file=file, - ttl_seconds=ttl_seconds + ttl_seconds=ttl_seconds, + spoiler=has_spoiler, ) elif re.match("^https?://", photo): media = raw.types.InputMediaPhotoExternal( url=photo, - ttl_seconds=ttl_seconds + ttl_seconds=ttl_seconds, + spoiler=has_spoiler ) else: media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds) @@ -162,7 +168,8 @@ class SendPhoto: file = await self.save_file(photo, progress=progress, progress_args=progress_args) media = raw.types.InputMediaUploadedPhoto( file=file, - ttl_seconds=ttl_seconds + ttl_seconds=ttl_seconds, + spoiler=has_spoiler ) while True: diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py index c2053064..e869dd17 100644 --- a/pyrogram/methods/messages/send_video.py +++ b/pyrogram/methods/messages/send_video.py @@ -38,6 +38,7 @@ class SendVideo: caption: str = "", parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, + has_spoiler: bool = None, ttl_seconds: int = None, duration: int = 0, width: int = 0, @@ -85,6 +86,9 @@ class SendVideo: caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): List of special entities that appear in the caption, which can be specified instead of *parse_mode*. + has_spoiler (``bool``, *optional*): + Pass True if the video needs to be covered with a spoiler animation. + ttl_seconds (``int``, *optional*): Self-Destruct Timer. If you set a timer, the video will self-destruct in *ttl_seconds* @@ -185,6 +189,7 @@ class SendVideo: mime_type=self.guess_mime_type(video) or "video/mp4", file=file, ttl_seconds=ttl_seconds, + spoiler=has_spoiler, thumb=thumb, attributes=[ raw.types.DocumentAttributeVideo( @@ -199,7 +204,8 @@ class SendVideo: elif re.match("^https?://", video): media = raw.types.InputMediaDocumentExternal( url=video, - ttl_seconds=ttl_seconds + ttl_seconds=ttl_seconds, + spoiler=has_spoiler ) else: media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds) @@ -210,6 +216,7 @@ class SendVideo: mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4", file=file, ttl_seconds=ttl_seconds, + spoiler=has_spoiler, thumb=thumb, attributes=[ raw.types.DocumentAttributeVideo(