Uncategorized

How to get a video file from a user in a bot written on python-telegram-bot library?


I’ve got a simple bot written on python-telegram-bot library.

It asks a user several questions and finally asks to upload a video.
I tried a code that allows to upload a photo and it works fine.
The code for uploading photo is like this

async def file_data(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
    user = update.message.from_user
    photo_file = await update.message.photo[-1].get_file()
    await photo_file.download_to_drive("user_photo.jpg")
    await update.message.reply_text(f"Photo has been uploaded")
    
#This is how the handler executing the function above looks like    
FILE: [MessageHandler(filters.PHOTO & ~filters.COMMAND, file_data), CommandHandler("skip", skip_file), CommandHandler("cancel", cancel)],

But how ho implement uploading a video?
Help me please



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *