Answer the question
In order to leave comments, you need to log in
How to remember separately the text and image that you sent to the telegram bot?
I have a bot and I need it to save the text and photo to the database in one variable (I have this), I have absolutely no idea how to do this, here is the code that remembers the picture and it was sent in the document format, but for some reason into the variable " a" the text that I send along with the picture is not saved
@bot.message_handler(content_types=["document"])
def handle_docs_audio(message):
try:
a = message.text
chat_id = message.chat.id
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'C:/new_project/images' + message.document.file_name
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, "Пожалуй, я сохраню это")
print(a)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question