Handle media files (voice messages, audio, images, documents) on Telegram Channel

This commit is contained in:
Darye
2026-02-16 16:29:03 +01:00
parent 1207b89adb
commit 23b7e1ef5e
2 changed files with 65 additions and 11 deletions

View File

@@ -52,6 +52,11 @@ class MessageTool(Tool):
"chat_id": {
"type": "string",
"description": "Optional: target chat/user ID"
},
"media": {
"type": "array",
"items": {"type": "string"},
"description": "Optional: list of file paths to attach (images, audio, documents)"
}
},
"required": ["content"]
@@ -62,6 +67,7 @@ class MessageTool(Tool):
content: str,
channel: str | None = None,
chat_id: str | None = None,
media: list[str] | None = None,
**kwargs: Any
) -> str:
channel = channel or self._default_channel
@@ -76,11 +82,13 @@ class MessageTool(Tool):
msg = OutboundMessage(
channel=channel,
chat_id=chat_id,
content=content
content=content,
media=media or []
)
try:
await self._send_callback(msg)
return f"Message sent to {channel}:{chat_id}"
media_info = f" with {len(media)} attachments" if media else ""
return f"Message sent to {channel}:{chat_id}{media_info}"
except Exception as e:
return f"Error sending message: {str(e)}"