skip to Main Content

I have bot which can takes photo with caption, so I need to forward this whole message to some group, also, this bot can already forward messages with text only, how can I do this with telebot and python?

2

Answers


  1. Chosen as BEST ANSWER

    I found answer: @bot.message_handler(content_types=['photo', 'text'], func=lambda message: True)

    And also I create check, if message is photo by:

        if message.photo:
            photo = message.photo[-1]
            file_id = photo.file_id
            file_info = bot.get_file(file_id)
            downloaded_file = bot.download_file(file_info.file_path)
            bot.send_photo(group_chat_id, downloaded_file, caption=message.caption)
    

  2. The method you’re looking for is Telebot.send_photo(chat_id, photo, caption), you can check the documentation here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search