Answer the question
In order to leave comments, you need to log in
Python telegram bot: how to send audio?
I am currently writing a bot for a telegram in python, the essence of which is sending music in the form of audio files. But, I don't know how to make it send music and how to write code for this. I reviewed everything on the Telegram Bot API website and on others too, but I didn’t find anything. Please help, and if possible, explain everything in as much detail as possible. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
What's wrong with the documentation?
https://core.telegram.org/bots/api#sendaudio
params = {'chat_id': user_id}
files = {'audio': open(audio_name, 'rb')}
requests.post('https://api.telegram.org/botxx:xx/sendAudio', data=params, files=files)
PyTelegramBotApi has a send_audio method like called.
audio = open('audio.mp3', 'rb')
bot.send_audio(chat_id, audio)
If you want to send as a file then -
audio = open('audio.mp3', 'rb')
bot.send_document(chat_id, audio)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question