Skip to content

Commit aebf7e3

Browse files
committed
Added support for voice messages that can be played once
1 parent 3ecfa88 commit aebf7e3

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

pyrogram/methods/messages/send_voice.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def send_voice(
4545
partial_reply: str = None,
4646
schedule_date: datetime = None,
4747
protect_content: bool = None,
48+
ttl_seconds: int = None,
4849
reply_markup: Union[
4950
"types.InlineKeyboardMarkup",
5051
"types.ReplyKeyboardMarkup",
@@ -104,6 +105,11 @@ async def send_voice(
104105
protect_content (``bool``, *optional*):
105106
Protects the contents of the sent message from forwarding and saving.
106107
108+
ttl_seconds (``int``, *optional*):
109+
Self-Destruct Timer.
110+
If you set a timer, the voice message will self-destruct in *ttl_seconds*
111+
seconds after it was viewed.
112+
107113
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
108114
Additional interface options. An object for an inline keyboard, custom reply keyboard,
109115
instructions to remove reply keyboard or to force a reply from the user.
@@ -145,6 +151,10 @@ async def send_voice(
145151
146152
# Set voice note duration
147153
await app.send_voice("me", "voice.ogg", duration=20)
154+
155+
# Send self-destructing voice message
156+
await app.send_voice("me", "voice.ogg", ttl_seconds=10)
157+
148158
"""
149159
file = None
150160

@@ -160,7 +170,8 @@ async def send_voice(
160170
voice=True,
161171
duration=duration
162172
)
163-
]
173+
],
174+
ttl_seconds=ttl_seconds
164175
)
165176
elif re.match("^https?://", voice):
166177
media = raw.types.InputMediaDocumentExternal(
@@ -178,7 +189,8 @@ async def send_voice(
178189
voice=True,
179190
duration=duration
180191
)
181-
]
192+
],
193+
ttl_seconds=ttl_seconds
182194
)
183195

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

0 commit comments

Comments
 (0)