Answer the question
In order to leave comments, you need to log in
How to specify the name of the audio to be sent to the TG bot (aiogram)?
*Хэндлер*
*Функция*:
await mybot.send_message(message.chat.id, 'Получаю аудио...')
rand_1_to_3 = random.randint(0, 2)
if rand_1_to_3 == 0:
await mybot.send_audio(message.chat.id, open('settings/first_relax.mp3', 'rb', audioname='The Chords — Sh-boom'))
elif rand_1_to_3 == 1:
await mybot.send_audio(message.chat.id, open('settings/second_relax.mp3', 'rb', audioname='J.S. Bach – Orchestral Suite No. 3 in D Major, BWV 1068 - II. Air'))
elif rand_1_to_3 == 2:
await mybot.send_audio(message.chat.id, open('settings/third_relax.mp3', 'rb', audioname='Erik Satie – Gymnopédie No.3'))
Answer the question
In order to leave comments, you need to log in
In order to understand how the function works, I advise you to look at the documentation of the library from which this function is.
In this case, you need to pass to the send_audio method not a file descriptor, but an object from the aiogram FSInputFile framework
A very strange question, the answer to which lies on the surface .
If such things cause difficulties, I advise you to roll back a little in learning programming in general. Read books, do simpler tasks. For some reason, everyone immediately climbs into bots, although they have a mediocre idea of \u200b\u200bbasic concepts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question