From 02fcd26be5150cfb0920df70a232d58d145a5c00 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 14 Dec 2022 13:36:45 +0100 Subject: [PATCH] Updated Working with Files and Media (markdown) --- Working-with-Files-and-Media.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Working-with-Files-and-Media.md b/Working-with-Files-and-Media.md index 3fc3f77..612995b 100644 --- a/Working-with-Files-and-Media.md +++ b/Working-with-Files-and-Media.md @@ -1,3 +1,7 @@ +Bots interacting with users in plain text messages is often times not enough for a pleasant user experience. +Providing the users with images, videos, fives and other media is therefore a common use case for bot programmers and the Bot API provides several ways to do this. +On this wiki page, we explain how files and media are handled in the `python-telegram-bot` framework. + ## Sending files If you want to send a file (e.g. send a document or a photo) with the bot, you have three options: @@ -36,13 +40,13 @@ Let's have a look at how sending a document can be done. In these examples, we'l 2. Sending an HTTP URL ```python - await bot.send_document(chat_id=chat_id, document='https://python-telegram-bot.org/static/testfiles/telegram.gif')) + await bot.send_document(chat_id=chat_id, document='https://python-telegram-bot.org/static/testfiles/telegram.gif') ``` 3. Sending by `file_id`: ```python - await bot.send_document(chat_id=chat_id, document=file_id)) + await bot.send_document(chat_id=chat_id, document=file_id) ``` Two further notes on this: @@ -73,6 +77,8 @@ media_1 = InputMediaDocument(media='https://python-telegram-bot.org/static/testf media_1 = InputMediaDocument(media=file_id, ...) ``` +> Note that for the `InputMedia*` classes, passing a file path only works if your bot is running in [local mode](docs.python-telegram-bot.org/telegram.bot.html#telegram.Bot.params.local_mode). + ### Sending files via inline mode You may want to allow users to send media via your bots inline mode. This works a little bit different than posting media via `send_*`. Most notably, you can't upload files for inline mode! You must provide either an HTTP URL or a `file_id`.