mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 15:13:43 +00:00
fix(telegram): exclude forum topic system messages from implicitMention
When a Telegram Forum topic is created by the bot, Telegram generates a system message with from.id=botId and empty text. Every subsequent user message in that topic has reply_to_message pointing to this system message, causing the implicitMention check to fire and bypassing requireMention for every single message. Add a guard that recognises system messages (is_bot=true with no text) and excludes them from implicit mention detection, so that only genuine replies to bot messages trigger the bypass. Closes #32256 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
bb60687b89
commit
8fdd1d2f05
@@ -471,9 +471,15 @@ export const buildTelegramMessageContext = async ({
|
||||
return null;
|
||||
}
|
||||
// Reply-chain detection: replying to a bot message acts like an implicit mention.
|
||||
// Exclude forum-topic system messages (auto-generated "Topic created" messages by the
|
||||
// bot that have empty text) so that every message inside a bot-created topic does not
|
||||
// incorrectly bypass requireMention (#32256).
|
||||
const botId = primaryCtx.me?.id;
|
||||
const replyFromId = msg.reply_to_message?.from?.id;
|
||||
const implicitMention = botId != null && replyFromId === botId;
|
||||
const replyToBotMessage = botId != null && replyFromId === botId;
|
||||
const isReplyToSystemMessage =
|
||||
replyToBotMessage && msg.reply_to_message?.from?.is_bot === true && !msg.reply_to_message?.text;
|
||||
const implicitMention = replyToBotMessage && !isReplyToSystemMessage;
|
||||
const canDetectMention = Boolean(botUsername) || mentionRegexes.length > 0;
|
||||
const mentionGate = resolveMentionGatingWithBypass({
|
||||
isGroup,
|
||||
|
||||
Reference in New Issue
Block a user