skip to Main Content

How can my telegram bot download photos that users sent to it without Telegram bot Api ? (im using pyTelegramBotAPI)

2

Answers


  1. If you are using pyTelegramBotAPI you can use this code:

    @bot.message_handler(content_types=['photo'])
    def handle_photo(message):
        raw = message.photo[2].file_id
        name = raw+".jpg"
        file_info = bot.get_file(raw)
        downloaded_file = bot.download_file(file_info.file_path)
        with open(name,'wb') as new_file:
            new_file.write(downloaded_file)
    
    Login or Signup to reply.
  2. If your bot use a webhooks, you can use simple php code that will get response json data and can download the photo that was be uploaded by user.
    That way is will be worked without any lib and extention, just simple php. If you want i can help you with this.

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