Skip to content

Your lightweight open-source personal agent.

feat(telegram): support HTTP(S) URLs for media in TelegramChannel

h4nz4a7bd0f29575d
diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.py
index 34c4a3b74..9ec3c0e8f 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},