From a7bd0f29575d48553295ae968145cf2e9ebb4b5b Mon Sep 17 00:00:00 2001 From: h4nz4 Date: Mon, 9 Mar 2026 19:21:51 +0100 Subject: [PATCH] feat(telegram): support HTTP(S) URLs for media in TelegramChannel Fixes #1792 --- nanobot/channels/telegram.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.py index 34c4a3b..9ec3c0e 100644 --- a/nanobot/channels/telegram.py +++ b/nanobot/channels/telegram.py @@ -354,7 +354,18 @@ class TelegramChannel(BaseChannel): "audio": self._app.bot.send_audio, }.get(media_type, self._app.bot.send_document) param = "photo" if media_type == "photo" else media_type if media_type in ("voice", "audio") else "document" - with open(media_path, 'rb') as f: + + # Telegram Bot API accepts HTTP(S) URLs directly for media params. + if media_path.startswith(("http://", "https://")): + await sender( + chat_id=chat_id, + **{param: media_path}, + reply_parameters=reply_params, + **thread_kwargs, + ) + continue + + with open(media_path, "rb") as f: await sender( chat_id=chat_id, **{param: f},