Answer the question
In order to leave comments, you need to log in
Sending audio telegram bot?
The goal is to teach the bot to send already uploaded materials (photos, audio, video, documents).
I searched on the Internet and found this offer below
"User from another resource"
In general, I advise you to upload these same .mp3 files to Telegram and save its id through some bot and send it if necessary to send music - this way you will make it easier for yourself and for Telegram servers :)
How to do it? How I would do it:
Open the @ShowJSONBot bot (or any other that will return JSON messages to you)
Send him an .mp3 file
That's it, your file in Telegram! The bot will return JSON to you, in which you will find the file_unique_id parameter.
This file_unique_id will need to be sent like this:
bot.send_audio(message.chat.id, 31279387129.....)
{
"update_id": 926407447,
"message": {
"message_id": 469072,
"from": {
"id": 0000000,
"is_bot": false,
"first_name": "It",
"last_name": "noName",
"username": "noname",
"language_code": "ru"
},
"chat": {
"id": 000000,
"first_name": "It",
"last_name": "noname",
"username": "noname",
"type": "private"
},
"date": 1607419059,
"audio": {
"duration": 117,
"file_name": "music.mp3",
"mime_type": "audio/mpeg3",
"title": "music 123",
"performer": "music music",
"file_id": "CQACAgIAAxkBAAEHKFBfz0Syt38QjrY2v23C2My7fCkXugACcAgAAv_DeUripPA4_jLPqh4E",
"file_unique_id": "AgADcAgAAv_DeUo",
"file_size": 4683662
}
}
}
if message.text.lower() == "песня":
bot.send_audio(message.chat.id, AgADcAgAAv_DeUo)
import json
Answer the question
In order to leave comments, you need to log in
Well, first of all, there are not enough quotes.
Secondly, you need to send file_id
And thirdly, file_id is unique for each bot, so sending a file to one bot, you cannot copy the received ID and send it to another bot
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question