X
X
XWR2021-08-02 22:51:57
Python
XWR, 2021-08-02 22:51:57

Sending video to aiogram in python?

Hello, I want to send a video through the bot, but it doesn’t work.
The bot is written on the aiogram library.

Here is the code:

@dp.message_handler(commands=['test'])
async def cmd_image(message: types.Message):
    await message.answer_video('/storage/emulated/0/Movies/3e36b80b873e29689147792373da5934.mp4')

I will be glad if you help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-08-03
@XWR

Try like this:

@dp.message_handler(commands=['test'])
async def cmd_image(message: types.Message):
    with open('/storage/emulated/0/Movies/3e36b80b873e29689147792373da5934.mp4', 'rb') as video:
        await message.answer_video(video)

But it's even better to upload the video to the Telegram server in advance and send the file_id of this video

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question