Skip to content

Commit c707a4b

Browse files
committed
Add the parameter has_spoiler to relevant send_* media methods
- send_photo() - send_video() - send_animation()
1 parent ef29b3c commit c707a4b

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

pyrogram/methods/messages/send_animation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async def send_animation(
3939
unsave: bool = False,
4040
parse_mode: Optional["enums.ParseMode"] = None,
4141
caption_entities: List["types.MessageEntity"] = None,
42+
has_spoiler: bool = None,
4243
duration: int = 0,
4344
width: int = 0,
4445
height: int = 0,
@@ -88,6 +89,9 @@ async def send_animation(
8889
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
8990
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
9091
92+
has_spoiler (``bool``, *optional*):
93+
Pass True if the animation needs to be covered with a spoiler animation.
94+
9195
duration (``int``, *optional*):
9296
Duration of sent animation in seconds.
9397
@@ -180,6 +184,7 @@ async def progress(current, total):
180184
mime_type=self.guess_mime_type(animation) or "video/mp4",
181185
file=file,
182186
thumb=thumb,
187+
spoiler=has_spoiler,
183188
attributes=[
184189
raw.types.DocumentAttributeVideo(
185190
supports_streaming=True,
@@ -193,7 +198,8 @@ async def progress(current, total):
193198
)
194199
elif re.match("^https?://", animation):
195200
media = raw.types.InputMediaDocumentExternal(
196-
url=animation
201+
url=animation,
202+
spoiler=has_spoiler
197203
)
198204
else:
199205
media = utils.get_input_media_from_file_id(animation, FileType.ANIMATION)
@@ -204,6 +210,7 @@ async def progress(current, total):
204210
mime_type=self.guess_mime_type(file_name or animation.name) or "video/mp4",
205211
file=file,
206212
thumb=thumb,
213+
spoiler=has_spoiler,
207214
attributes=[
208215
raw.types.DocumentAttributeVideo(
209216
supports_streaming=True,

pyrogram/methods/messages/send_photo.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async def send_photo(
3737
caption: str = "",
3838
parse_mode: Optional["enums.ParseMode"] = None,
3939
caption_entities: List["types.MessageEntity"] = None,
40+
has_spoiler: bool = None,
4041
ttl_seconds: int = None,
4142
disable_notification: bool = None,
4243
reply_to_message_id: int = None,
@@ -78,6 +79,9 @@ async def send_photo(
7879
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
7980
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
8081
82+
has_spoiler (``bool``, *optional*):
83+
Pass True if the photo needs to be covered with a spoiler animation.
84+
8185
ttl_seconds (``int``, *optional*):
8286
Self-Destruct Timer.
8387
If you set a timer, the photo will self-destruct in *ttl_seconds*
@@ -149,20 +153,23 @@ async def send_photo(
149153
file = await self.save_file(photo, progress=progress, progress_args=progress_args)
150154
media = raw.types.InputMediaUploadedPhoto(
151155
file=file,
152-
ttl_seconds=ttl_seconds
156+
ttl_seconds=ttl_seconds,
157+
spoiler=has_spoiler,
153158
)
154159
elif re.match("^https?://", photo):
155160
media = raw.types.InputMediaPhotoExternal(
156161
url=photo,
157-
ttl_seconds=ttl_seconds
162+
ttl_seconds=ttl_seconds,
163+
spoiler=has_spoiler
158164
)
159165
else:
160166
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds)
161167
else:
162168
file = await self.save_file(photo, progress=progress, progress_args=progress_args)
163169
media = raw.types.InputMediaUploadedPhoto(
164170
file=file,
165-
ttl_seconds=ttl_seconds
171+
ttl_seconds=ttl_seconds,
172+
spoiler=has_spoiler
166173
)
167174

168175
while True:

pyrogram/methods/messages/send_video.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def send_video(
3838
caption: str = "",
3939
parse_mode: Optional["enums.ParseMode"] = None,
4040
caption_entities: List["types.MessageEntity"] = None,
41+
has_spoiler: bool = None,
4142
ttl_seconds: int = None,
4243
duration: int = 0,
4344
width: int = 0,
@@ -85,6 +86,9 @@ async def send_video(
8586
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
8687
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
8788
89+
has_spoiler (``bool``, *optional*):
90+
Pass True if the video needs to be covered with a spoiler animation.
91+
8892
ttl_seconds (``int``, *optional*):
8993
Self-Destruct Timer.
9094
If you set a timer, the video will self-destruct in *ttl_seconds*
@@ -185,6 +189,7 @@ async def progress(current, total):
185189
mime_type=self.guess_mime_type(video) or "video/mp4",
186190
file=file,
187191
ttl_seconds=ttl_seconds,
192+
spoiler=has_spoiler,
188193
thumb=thumb,
189194
attributes=[
190195
raw.types.DocumentAttributeVideo(
@@ -199,7 +204,8 @@ async def progress(current, total):
199204
elif re.match("^https?://", video):
200205
media = raw.types.InputMediaDocumentExternal(
201206
url=video,
202-
ttl_seconds=ttl_seconds
207+
ttl_seconds=ttl_seconds,
208+
spoiler=has_spoiler
203209
)
204210
else:
205211
media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds)
@@ -210,6 +216,7 @@ async def progress(current, total):
210216
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
211217
file=file,
212218
ttl_seconds=ttl_seconds,
219+
spoiler=has_spoiler,
213220
thumb=thumb,
214221
attributes=[
215222
raw.types.DocumentAttributeVideo(

0 commit comments

Comments
 (0)