From ecd40f267ecf790bad39ec69b19123eefbfdd2b2 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Dec 2017 01:27:13 +0100 Subject: [PATCH] Add send_voice method --- pyrogram/client/client.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 8fedf818..31698c71 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -650,3 +650,30 @@ class Client: random_id=self.rnd_id() ) ) + + def send_voice(self, + chat_id: int or str, + voice: str, + caption: str = "", + duration: int = 0, + disable_notification: bool = None, + reply_to_message_id: int = None): + return self.send( + functions.messages.SendMedia( + peer=self.resolve_peer(chat_id), + media=types.InputMediaUploadedDocument( + mime_type=mimetypes.types_map.get("." + voice.split(".")[-1], "audio/mpeg"), + file=self.save_file(voice), + caption=caption, + attributes=[ + types.DocumentAttributeAudio( + voice=True, + duration=duration + ) + ] + ), + silent=disable_notification or None, + reply_to_msg_id=reply_to_message_id, + random_id=self.rnd_id() + ) + )