K
K
Kt0T02021-04-19 12:16:48
Python
Kt0T0, 2021-04-19 12:16:48

How to save Audio to a variable?

Hello, this is the case, so I decided to put the bot into a cart, and now I need the bot to receive the audio message and save it to a variable for further work with it, that's what happened to me, but I can't output the data from the variable to another functions.

@bot.message_handler(commands=['start'])
def handle_message(message):
    sent = bot.send_message(message.chat.id, 'Пришлите аудио файл :')
    bot.register_next_step_handler(sent, save_link)
def save_audio (message):
    sent = bot.send_message(message.chat.id, 'Введите текст под аудио :')
    audio = message.audio.file_id
    bot.register_next_step_handler(sent, audio_description)
def audio_description(message):
  bot.send_audio(message.chat.id, audio)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
o5a, 2021-04-19
@Kt0T0

You can pass additional parameters

bot.register_next_step_handler(sent, audio_description, audio)
...
def audio_description(message, audio):

M
Mikhail Krostelev, 2021-04-19
@twistfire92

And is it intended that you pass the save_link function to register_next_step_handler , and you have the save_audio function declared ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question