Skip to content

Commit 6cb883a

Browse files
committed
Added support for send animation and send video note that can be played once
1 parent aebf7e3 commit 6cb883a

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

pyrogram/methods/messages/send_animation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async def send_animation(
5151
partial_reply: str = None,
5252
schedule_date: datetime = None,
5353
protect_content: bool = None,
54+
ttl_seconds: int = None,
5455
reply_markup: Union[
5556
"types.InlineKeyboardMarkup",
5657
"types.ReplyKeyboardMarkup",
@@ -117,6 +118,12 @@ async def send_animation(
117118
Sends the message silently.
118119
Users will receive a notification with no sound.
119120
121+
ttl_seconds (``int``, *optional*):
122+
Self-Destruct Timer.
123+
If you set a timer, the animation will self-destruct in *ttl_seconds*
124+
seconds after it was viewed.
125+
126+
120127
reply_to_message_id (``int``, *optional*):
121128
If the message is a reply, ID of the original message.
122129
@@ -181,6 +188,9 @@ async def progress(current, total):
181188
print(f"{current * 100 / total:.1f}%")
182189
183190
await app.send_animation("me", "animation.gif", progress=progress)
191+
192+
# Send self-destructing animation message
193+
await app.send_animation("me", "animation.gif", ttl_seconds=10)
184194
"""
185195
file = None
186196

@@ -203,7 +213,8 @@ async def progress(current, total):
203213
),
204214
raw.types.DocumentAttributeFilename(file_name=file_name or os.path.basename(animation)),
205215
raw.types.DocumentAttributeAnimated()
206-
]
216+
],
217+
ttl_seconds=ttl_seconds
207218
)
208219
elif re.match("^https?://", animation):
209220
media = raw.types.InputMediaDocumentExternal(
@@ -229,7 +240,8 @@ async def progress(current, total):
229240
),
230241
raw.types.DocumentAttributeFilename(file_name=file_name or animation.name),
231242
raw.types.DocumentAttributeAnimated()
232-
]
243+
],
244+
ttl_seconds=ttl_seconds
233245
)
234246

235247
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id, partial_reply)

pyrogram/methods/messages/send_video_note.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async def send_video_note(
4242
message_thread_id: int = None,
4343
partial_reply: str = None,
4444
schedule_date: datetime = None,
45+
ttl_seconds: int = None,
4546
protect_content: bool = None,
4647
reply_markup: Union[
4748
"types.InlineKeyboardMarkup",
@@ -101,6 +102,11 @@ async def send_video_note(
101102
protect_content (``bool``, *optional*):
102103
Protects the contents of the sent message from forwarding and saving.
103104
105+
ttl_seconds (``int``, *optional*):
106+
Self-Destruct Timer.
107+
If you set a timer, the video note will self-destruct in *ttl_seconds*
108+
seconds after it was viewed.
109+
104110
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
105111
Additional interface options. An object for an inline keyboard, custom reply keyboard,
106112
instructions to remove reply keyboard or to force a reply from the user.
@@ -140,6 +146,9 @@ async def send_video_note(
140146
141147
# Set video note length
142148
await app.send_video_note("me", "video_note.mp4", length=25)
149+
150+
# Send self-destructing video note message
151+
await app.send_video_note("me", "video_note.mp4", ttl_seconds=10)
143152
"""
144153
file = None
145154

@@ -159,7 +168,8 @@ async def send_video_note(
159168
w=length,
160169
h=length
161170
)
162-
]
171+
],
172+
ttl_seconds=ttl_seconds
163173
)
164174
else:
165175
media = utils.get_input_media_from_file_id(video_note, FileType.VIDEO_NOTE)
@@ -177,7 +187,8 @@ async def send_video_note(
177187
w=length,
178188
h=length
179189
)
180-
]
190+
],
191+
ttl_seconds=ttl_seconds
181192
)
182193

183194
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id, partial_reply)

0 commit comments

Comments
 (0)