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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user