Answer the question
In order to leave comments, you need to log in
How to send a photo via telebot?
There was a problem with send_photo. I don't understand how the message.photo list works. What do the elements of this list mean? Why can select [-1] element?
I decided to test the code so that the number of elements of the message.photo list is displayed, for one photo the bot sends either 2 or 3, how is this possible if I threw off one photo?
@bot.message_handler(content_types=['photo'])
def gg(message):
bot.send_message(message.chat.id, str(len(message.photo)))
Answer the question
In order to leave comments, you need to log in
-1 element is the last one (often when they don't know the length of the list and want to take the last one - write exactly minus one),
Send a photo via telebot:
photo = open('путь_к_фото', 'rb')
bot.send_photo(chat_id, photo)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question