V
V
Vladimir2021-09-15 19:53:15
Python
Vladimir, 2021-09-15 19:53:15

How to make the telegram bot respond to incoming images?

Already taught him to reply to messages. But I can't figure out from the photo what code is needed? I read about getfiles and give_photo but nothing works(

@bot.message_handler(content_types=['text', 'photo', 'files'])

def give_photo(message):
   bot.send_message(message.chat.id, "ОТВЕТ")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2021-09-15
Batkovich @Podkovally

For the pyTelegramBotAPI library:

import telebot

@bot.message_handler(content_types=['text', 'photo', 'files'])
def give_photo(message):
    if message.content_type == 'photo':
        bot.send_message(message.chat.id, text="ОТВЕТ")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question