mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:48:27 +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:
@@ -25,7 +25,11 @@ import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bo
|
||||
import { RegisterTelegramHandlerParams } from "./bot-native-commands.js";
|
||||
import { MEDIA_GROUP_TIMEOUT_MS, type MediaGroupEntry } from "./bot-updates.js";
|
||||
import { resolveMedia } from "./bot/delivery.js";
|
||||
import { buildTelegramGroupPeerId, resolveTelegramForumThreadId } from "./bot/helpers.js";
|
||||
import {
|
||||
buildTelegramGroupPeerId,
|
||||
buildTelegramParentPeer,
|
||||
resolveTelegramForumThreadId,
|
||||
} from "./bot/helpers.js";
|
||||
import { migrateTelegramGroupConfig } from "./group-migration.js";
|
||||
import { resolveTelegramInlineButtonsScope } from "./inline-buttons.js";
|
||||
import {
|
||||
@@ -149,6 +153,11 @@ export const registerTelegramHandlers = ({
|
||||
const peerId = params.isGroup
|
||||
? buildTelegramGroupPeerId(params.chatId, resolvedThreadId)
|
||||
: String(params.chatId);
|
||||
const parentPeer = buildTelegramParentPeer({
|
||||
isGroup: params.isGroup,
|
||||
resolvedThreadId,
|
||||
chatId: params.chatId,
|
||||
});
|
||||
const route = resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "telegram",
|
||||
@@ -157,6 +166,7 @@ export const registerTelegramHandlers = ({
|
||||
kind: params.isGroup ? "group" : "dm",
|
||||
id: peerId,
|
||||
},
|
||||
parentPeer,
|
||||
});
|
||||
const baseSessionKey = route.sessionKey;
|
||||
const dmThreadId = !params.isGroup ? params.messageThreadId : undefined;
|
||||
|
||||
Reference in New Issue
Block a user