← Back to PRs

#8985: fix(telegram): preserve forum topic context for pairing auto-replies

by lailoo open 2026-02-04 17:55 View on GitHub →
channel: telegram stale
## Summary When a new user sends a message in a Telegram forum topic, the pairing auto-reply was being sent to the General channel instead of the original topic. ## Root Cause In `bot-message-context.ts`, the `bot.api.sendMessage` call for pairing replies did not pass `message_thread_id`, causing the reply to go to the root of the forum group. ## Fix Pass `message_thread_id` to `sendMessage` when sending pairing replies: ```typescript bot.api.sendMessage( chatId, pairingMessage, messageThreadId ? { message_thread_id: messageThreadId } : undefined, ) ``` ## Testing - Code review: `messageThreadId` is already extracted from the incoming message at line 159 - Lint passes - This is a minimal, low-risk change (1 line addition) Fixes #8820 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change updates the Telegram DM pairing auto-reply path to include `message_thread_id` when replying, so that if the inbound message originated from a forum topic the pairing response is posted back into the same topic instead of the forum’s root/General channel. The update is localized to the `dmPolicy === "pairing"` unauthorized-sender branch in `src/telegram/bot-message-context.ts`, and it mirrors the existing thread-awareness patterns elsewhere in this file (e.g., typing actions using `buildTypingThreadParams(replyThreadId)`). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is a small, targeted parameter addition to a single Telegram API call and aligns with Telegram forum semantics; no broader behavior changes were introduced in the commit diff. - No files require special attention <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs