From ebb3fd272f2138e5ed7d9dec1af41975d145c0d2 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Sun, 15 Feb 2026 10:45:34 -0500 Subject: [PATCH] telegram: scope plugin-command media roots by route --- src/telegram/bot-native-commands.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index 548c8b115e1..73041e3bf32 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -638,13 +638,25 @@ export const registerTelegramNativeCommands = ({ if (!auth) { return; } - const { senderId, commandAuthorized, isGroup, isForum } = auth; + const { senderId, commandAuthorized, isGroup, isForum, resolvedThreadId } = auth; const messageThreadId = (msg as { message_thread_id?: number }).message_thread_id; const threadSpec = resolveTelegramThreadSpec({ isGroup, isForum, messageThreadId, }); + const parentPeer = buildTelegramParentPeer({ isGroup, resolvedThreadId, chatId }); + const route = resolveAgentRoute({ + cfg, + channel: "telegram", + accountId, + peer: { + kind: isGroup ? "group" : "direct", + id: isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId), + }, + parentPeer, + }); + const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId); const from = isGroup ? buildTelegramGroupFrom(chatId, threadSpec.id) : `telegram:${chatId}`; @@ -666,9 +678,9 @@ export const registerTelegramNativeCommands = ({ const tableMode = resolveMarkdownTableMode({ cfg, channel: "telegram", - accountId, + accountId: route.accountId, }); - const chunkMode = resolveChunkMode(cfg, "telegram", accountId); + const chunkMode = resolveChunkMode(cfg, "telegram", route.accountId); await deliverReplies({ replies: [result], @@ -676,6 +688,7 @@ export const registerTelegramNativeCommands = ({ token: opts.token, runtime, bot, + mediaLocalRoots, replyToMode, textLimit, thread: threadSpec,