mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:31:24 +00:00
fix(telegram): pass parentPeer for forum topic binding inheritance (#9789)
Fixes #9545 and #9351. When a message comes from a Telegram forum topic, the peer ID includes the topic suffix (e.g., `-1001234567890:topic:99`). Users configure bindings with the base group ID, which previously did not match. This adds `parentPeer` to `resolveAgentRoute()` calls for forum groups, enabling binding inheritance from the parent group to all topics. - Extract `buildTelegramParentPeer()` helper in bot/helpers.ts - Pass parentPeer in bot-message-context.ts, bot-handlers.ts, bot-native-commands.ts, and bot.ts (reaction handler) - Add tests for forum topic routing and topic precedence
This commit is contained in:
@@ -99,6 +99,24 @@ export function buildTelegramGroupFrom(chatId: number | string, messageThreadId?
|
||||
return `telegram:group:${buildTelegramGroupPeerId(chatId, messageThreadId)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build parentPeer for forum topic binding inheritance.
|
||||
* When a message comes from a forum topic, the peer ID includes the topic suffix
|
||||
* (e.g., `-1001234567890:topic:99`). To allow bindings configured for the base
|
||||
* group ID to match, we provide the parent group as `parentPeer` so the routing
|
||||
* layer can fall back to it when the exact peer doesn't match.
|
||||
*/
|
||||
export function buildTelegramParentPeer(params: {
|
||||
isGroup: boolean;
|
||||
resolvedThreadId?: number;
|
||||
chatId: number | string;
|
||||
}): { kind: "group"; id: string } | undefined {
|
||||
if (!params.isGroup || params.resolvedThreadId == null) {
|
||||
return undefined;
|
||||
}
|
||||
return { kind: "group", id: String(params.chatId) };
|
||||
}
|
||||
|
||||
export function buildSenderName(msg: Message) {
|
||||
const name =
|
||||
[msg.from?.first_name, msg.from?.last_name].filter(Boolean).join(" ").trim() ||
|
||||
|
||||
Reference in New Issue
Block a user