diff --git a/src/agents/tools/discord-actions.ts b/src/agents/tools/discord-actions.ts index fa78d63a17d..bf5a7a2989d 100644 --- a/src/agents/tools/discord-actions.ts +++ b/src/agents/tools/discord-actions.ts @@ -1,5 +1,6 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import type { OpenClawConfig } from "../../config/config.js"; +import { resolveDiscordAccount } from "../../discord/accounts.js"; import { createActionGate, readStringParam } from "./common.js"; import { handleDiscordGuildAction } from "./discord-actions-guild.js"; import { handleDiscordMessagingAction } from "./discord-actions-messaging.js"; @@ -59,7 +60,9 @@ export async function handleDiscordAction( cfg: OpenClawConfig, ): Promise> { const action = readStringParam(params, "action", { required: true }); - const isActionEnabled = createActionGate(cfg.channels?.discord?.actions); + const accountId = readStringParam(params, "accountId"); + const account = resolveDiscordAccount({ cfg, accountId }); + const isActionEnabled = createActionGate(account.config.actions); if (messagingActions.has(action)) { return await handleDiscordMessagingAction(action, params, isActionEnabled); diff --git a/src/agents/tools/telegram-actions.ts b/src/agents/tools/telegram-actions.ts index 6fa2e97d41d..269d439144b 100644 --- a/src/agents/tools/telegram-actions.ts +++ b/src/agents/tools/telegram-actions.ts @@ -1,5 +1,6 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import type { OpenClawConfig } from "../../config/config.js"; +import { resolveTelegramAccount } from "../../telegram/accounts.js"; import type { TelegramButtonStyle, TelegramInlineButtons } from "../../telegram/button-types.js"; import { resolveTelegramInlineButtonsScope, @@ -87,7 +88,8 @@ export async function handleTelegramAction( ): Promise> { const action = readStringParam(params, "action", { required: true }); const accountId = readStringParam(params, "accountId"); - const isActionEnabled = createActionGate(cfg.channels?.telegram?.actions); + const account = resolveTelegramAccount({ cfg, accountId }); + const isActionEnabled = createActionGate(account.config.actions); if (action === "react") { // Check reaction level first diff --git a/src/channels/plugins/actions/discord.ts b/src/channels/plugins/actions/discord.ts index fedcb9eab23..9815145bd8d 100644 --- a/src/channels/plugins/actions/discord.ts +++ b/src/channels/plugins/actions/discord.ts @@ -1,3 +1,4 @@ +import type { DiscordActionConfig } from "../../../config/types.discord.js"; import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { createActionGate } from "../../../agents/tools/common.js"; import { listEnabledDiscordAccounts } from "../../../discord/accounts.js"; @@ -11,7 +12,10 @@ export const discordMessageActions: ChannelMessageActionAdapter = { if (accounts.length === 0) { return []; } - const gate = createActionGate(cfg.channels?.discord?.actions); + // Union of all accounts' action gates (any account enabling an action makes it available) + const gates = accounts.map((a) => createActionGate(a.config.actions)); + const gate = (key: keyof DiscordActionConfig, defaultValue = true) => + gates.some((g) => g(key, defaultValue)); const actions = new Set(["send"]); if (gate("polls")) { actions.add("poll"); diff --git a/src/channels/plugins/actions/telegram.ts b/src/channels/plugins/actions/telegram.ts index 792482e217b..5e29b53f226 100644 --- a/src/channels/plugins/actions/telegram.ts +++ b/src/channels/plugins/actions/telegram.ts @@ -1,3 +1,4 @@ +import type { TelegramActionConfig } from "../../../config/types.telegram.js"; import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { createActionGate, @@ -46,7 +47,10 @@ export const telegramMessageActions: ChannelMessageActionAdapter = { if (accounts.length === 0) { return []; } - const gate = createActionGate(cfg.channels?.telegram?.actions); + // Union of all accounts' action gates (any account enabling an action makes it available) + const gates = accounts.map((a) => createActionGate(a.config.actions)); + const gate = (key: keyof TelegramActionConfig, defaultValue = true) => + gates.some((g) => g(key, defaultValue)); const actions = new Set(["send"]); if (gate("reactions")) { actions.add("react");