alfem / telegram-downloader-bot

A Telegram bot for file downloading automation
Other
129 stars 50 forks source link

How to download photo #5

Closed renrayut closed 5 years ago

renrayut commented 5 years ago

this script can download attach file only . please help guide to download send as photo.

alfem commented 5 years ago

Now you can share photos with the bot and it will download them. Try the new version.

renrayut commented 5 years ago

Dear Alfem thanks you for reply . but it still got error Traceback (most recent call last): File "telegram-bot.py", line 116, in photo=photos[-1] IndexError: list index out of range

or i need to update something more? please guide thanks you

renrayut commented 5 years ago

this error show after download send photo done then try to send as attach file it got this error.

renrayut commented 5 years ago

it working , i just add this line :

PHOTO MESSAGES

        try:
            today = date.today()                
            photos=update.message.photo # a list of different available sizes
            if photos:                    
                photo=photos[-1]
                d4 = today.strftime("%b-%d-%Y")
                name="{}-{}-{}x{}.jpg".format(d4,update.update_id,photo.width,photo.height)
                #bot.send_message(chat_id=TELEGRAM_CHAT_ID, text="Downloading photo %s (%i bytes)" %(name, photo.file_size))
                tfile=bot.getFile(photo.file_id)
                filenames.append(name)          
                urls.append(tfile.file_path)          
        except AttributeError:
            print "Error in photo message"
            pass
renrayut commented 5 years ago

thanks you for your script