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

Fixes #1792
This commit is contained in:
h4nz4
2026-03-09 19:21:51 +01:00
committed by Xubin Ren
parent 728d4e88a9
commit a7bd0f2957

View File

@@ -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},