Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
When sending a photo, you can get its file_id and next time send only it, for example:
files = {}
if photo_name in files:
file_id = files[photo_name]
bot.send_photo(message.chat.id, file_id)
else:
with open(photo_name, "rb") as f:
bot.send_chat_action(message.chat.id, "upload_photo")
r = bot.send_photo(message.chat.id, f)
file_id = r.photo[0].file_id
files[photo_name] = file_id
@bot.message_handler(content_types=['photo'])
def image_message(message):
file_id = message.photo[0].file_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question