Add the parameter has_spoiler to relevant send_* media methods

- send_photo()
- send_video()
- send_animation()
This commit is contained in:
Dan 2022-12-30 15:08:55 +01:00
parent ef29b3c519
commit c707a4baae
3 changed files with 26 additions and 5 deletions

View File

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

View File

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

View File

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