mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-28 00:56:19 +00:00
Add send_audio method
This commit is contained in:
parent
a5d1b7f480
commit
60dc1e577c
@ -20,6 +20,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
@ -256,6 +257,8 @@ class Client:
|
|||||||
self.rnd_id = self.session.msg_id
|
self.rnd_id = self.session.msg_id
|
||||||
self.get_dialogs()
|
self.get_dialogs()
|
||||||
|
|
||||||
|
mimetypes.init()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.session.stop()
|
self.session.stop()
|
||||||
|
|
||||||
@ -563,3 +566,35 @@ class Client:
|
|||||||
random_id=self.rnd_id()
|
random_id=self.rnd_id()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def send_audio(self,
|
||||||
|
chat_id: int or str,
|
||||||
|
audio: str,
|
||||||
|
caption: str = "",
|
||||||
|
duration: int = 0,
|
||||||
|
performer: str = None,
|
||||||
|
title: str = None,
|
||||||
|
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["." + audio.split(".")[-1]],
|
||||||
|
file=self.save_file(audio),
|
||||||
|
caption=caption,
|
||||||
|
attributes=[
|
||||||
|
types.DocumentAttributeAudio(
|
||||||
|
duration=duration,
|
||||||
|
performer=performer,
|
||||||
|
title=title
|
||||||
|
),
|
||||||
|
types.DocumentAttributeFilename(os.path.basename(audio))
|
||||||
|
]
|
||||||
|
),
|
||||||
|
silent=disable_notification or None,
|
||||||
|
reply_to_msg_id=reply_to_message_id,
|
||||||
|
random_id=self.rnd_id()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user