mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Add the parameter has_spoiler to relevant send_* media methods
- send_photo() - send_video() - send_animation()
This commit is contained in:
parent
ef29b3c519
commit
c707a4baae
@ -39,6 +39,7 @@ class SendAnimation:
|
|||||||
unsave: bool = False,
|
unsave: bool = False,
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
height: int = 0,
|
height: int = 0,
|
||||||
@ -88,6 +89,9 @@ class SendAnimation:
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
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*.
|
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 (``int``, *optional*):
|
||||||
Duration of sent animation in seconds.
|
Duration of sent animation in seconds.
|
||||||
|
|
||||||
@ -180,6 +184,7 @@ class SendAnimation:
|
|||||||
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
|
spoiler=has_spoiler,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
supports_streaming=True,
|
supports_streaming=True,
|
||||||
@ -193,7 +198,8 @@ class SendAnimation:
|
|||||||
)
|
)
|
||||||
elif re.match("^https?://", animation):
|
elif re.match("^https?://", animation):
|
||||||
media = raw.types.InputMediaDocumentExternal(
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
url=animation
|
url=animation,
|
||||||
|
spoiler=has_spoiler
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
media = utils.get_input_media_from_file_id(animation, FileType.ANIMATION)
|
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",
|
mime_type=self.guess_mime_type(file_name or animation.name) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
|
spoiler=has_spoiler,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
supports_streaming=True,
|
supports_streaming=True,
|
||||||
|
@ -37,6 +37,7 @@ class SendPhoto:
|
|||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
ttl_seconds: int = None,
|
ttl_seconds: int = None,
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
@ -78,6 +79,9 @@ class SendPhoto:
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
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*.
|
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*):
|
ttl_seconds (``int``, *optional*):
|
||||||
Self-Destruct Timer.
|
Self-Destruct Timer.
|
||||||
If you set a timer, the photo will self-destruct in *ttl_seconds*
|
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)
|
file = await self.save_file(photo, progress=progress, progress_args=progress_args)
|
||||||
media = raw.types.InputMediaUploadedPhoto(
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
file=file,
|
file=file,
|
||||||
ttl_seconds=ttl_seconds
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler,
|
||||||
)
|
)
|
||||||
elif re.match("^https?://", photo):
|
elif re.match("^https?://", photo):
|
||||||
media = raw.types.InputMediaPhotoExternal(
|
media = raw.types.InputMediaPhotoExternal(
|
||||||
url=photo,
|
url=photo,
|
||||||
ttl_seconds=ttl_seconds
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds)
|
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)
|
file = await self.save_file(photo, progress=progress, progress_args=progress_args)
|
||||||
media = raw.types.InputMediaUploadedPhoto(
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
file=file,
|
file=file,
|
||||||
ttl_seconds=ttl_seconds
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler
|
||||||
)
|
)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -38,6 +38,7 @@ class SendVideo:
|
|||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Optional["enums.ParseMode"] = None,
|
parse_mode: Optional["enums.ParseMode"] = None,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
ttl_seconds: int = None,
|
ttl_seconds: int = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
@ -85,6 +86,9 @@ class SendVideo:
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
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*.
|
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*):
|
ttl_seconds (``int``, *optional*):
|
||||||
Self-Destruct Timer.
|
Self-Destruct Timer.
|
||||||
If you set a timer, the video will self-destruct in *ttl_seconds*
|
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",
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
ttl_seconds=ttl_seconds,
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
@ -199,7 +204,8 @@ class SendVideo:
|
|||||||
elif re.match("^https?://", video):
|
elif re.match("^https?://", video):
|
||||||
media = raw.types.InputMediaDocumentExternal(
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
url=video,
|
url=video,
|
||||||
ttl_seconds=ttl_seconds
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds)
|
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",
|
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
ttl_seconds=ttl_seconds,
|
ttl_seconds=ttl_seconds,
|
||||||
|
spoiler=has_spoiler,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user