Answer the question
In order to leave comments, you need to log in
How to accept multiple photos in a telegram bot?
The task before me was:
To accept on the side of the bot several photos that the user sends.
At first, I managed to accept only one photo.
Used pyTelegramBotApi
As a result, this is what happened:
@bot.message_handler(content_types=['photo'])
def handle_docs_photo(message):
try:
chat_id = message.chat.id
file_info_1 = bot.get_file(message.photo[-1].file_id)
bot.send_message(message.chat.id, file_info_1)
downloaded_file = bot.download_file(file_info_1.file_path)
src = dir + '\\' + file_info_1.file_path.split('/')[-1]
bot.send_message(message.chat.id, src)
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
except Exception as e:
bot.reply_to(message, e)
Answer the question
In order to leave comments, you need to log in
if I send one photo without compression, then nothing happens
if I send for example 4 photos, then the function def handle_docs_photo(message): saves one photo less each time, in this case 3 photos
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question