fix: forward thread_id metadata for Telegram forum topic routing
Replies in Telegram forum topics (supergroups with topics) now land in the correct topic thread instead of 'General'. - base.py: build thread_id metadata from event.source, pass to all send/media calls; add metadata param to send_typing, send_image, send_animation, send_voice, send_video, send_document, send_image_file, _keep_typing - telegram.py: extract thread_id from metadata and pass as message_thread_id to all Bot API calls (send_photo, send_voice, send_audio, send_animation, send_chat_action) - run.py: pass thread_id metadata to progress/streaming send calls - discord/slack/whatsapp/homeassistant: update send_typing signature Based on the fix proposed by @Bitstreamono in PR #656.
This commit is contained in:
parent
2a062e2f45
commit
a630ca15de
2 changed files with 17 additions and 6 deletions
|
|
@ -2656,6 +2656,8 @@ class GatewayRunner:
|
|||
|
||||
# Background task to send progress messages
|
||||
# Accumulates tool lines into a single message that gets edited
|
||||
_progress_metadata = {"thread_id": source.thread_id} if source.thread_id else None
|
||||
|
||||
async def send_progress_messages():
|
||||
if not progress_queue:
|
||||
return
|
||||
|
|
@ -2685,15 +2687,15 @@ class GatewayRunner:
|
|||
# Platform doesn't support editing — stop trying,
|
||||
# send just this new line as a separate message
|
||||
can_edit = False
|
||||
await adapter.send(chat_id=source.chat_id, content=msg)
|
||||
await adapter.send(chat_id=source.chat_id, content=msg, metadata=_progress_metadata)
|
||||
else:
|
||||
if can_edit:
|
||||
# First tool: send all accumulated text as new message
|
||||
full_text = "\n".join(progress_lines)
|
||||
result = await adapter.send(chat_id=source.chat_id, content=full_text)
|
||||
result = await adapter.send(chat_id=source.chat_id, content=full_text, metadata=_progress_metadata)
|
||||
else:
|
||||
# Editing unsupported: send just this line
|
||||
result = await adapter.send(chat_id=source.chat_id, content=msg)
|
||||
result = await adapter.send(chat_id=source.chat_id, content=msg, metadata=_progress_metadata)
|
||||
if result.success and result.message_id:
|
||||
progress_msg_id = result.message_id
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue