feat(telegram): add location/geo support

Forward static location pins as [location: lat, lon] content so the
agent can respond to geo messages and pass coordinates to MCP tools.

Closes HKUDS/nanobot#2909
This commit is contained in:
kronk307
2026-04-08 02:32:19 +08:00
committed by Xubin Ren
parent c7d10de253
commit e21ba5f667
2 changed files with 55 additions and 2 deletions
+8 -2
View File
@@ -316,10 +316,10 @@ class TelegramChannel(BaseChannel):
)
self._app.add_handler(MessageHandler(filters.Regex(r"^/help(?:@\w+)?$"), self._on_help))
# Add message handler for text, photos, voice, documents
# Add message handler for text, photos, voice, documents, and locations
self._app.add_handler(
MessageHandler(
(filters.TEXT | filters.PHOTO | filters.VOICE | filters.AUDIO | filters.Document.ALL)
(filters.TEXT | filters.PHOTO | filters.VOICE | filters.AUDIO | filters.Document.ALL | filters.LOCATION)
& ~filters.COMMAND,
self._on_message
)
@@ -884,6 +884,12 @@ class TelegramChannel(BaseChannel):
if message.caption:
content_parts.append(message.caption)
# Location content
if message.location:
lat = message.location.latitude
lon = message.location.longitude
content_parts.append(f"[location: {lat}, {lon}]")
# Download current message media
current_media_paths, current_media_parts = await self._download_message_media(
message, add_failure_content=True