fix(telegram): hide disabled send actions from discovery (#117241)

Co-authored-by: Peter Steinberger <steipete@macos.shared>
This commit is contained in:
Peter Steinberger
2026-08-01 00:15:17 -07:00
committed by GitHub
parent 6b43acf062
commit 08fc4f5a06
2 changed files with 38 additions and 1 deletions
@@ -127,6 +127,7 @@ describe("telegramMessageActions", () => {
{
name: "configured telegram enables poll",
cfg: { channels: { telegram: { botToken: "tok" } } } as OpenClawConfig,
expectSend: true,
expectPoll: true,
expectTopicEdit: true,
},
@@ -140,6 +141,7 @@ describe("telegramMessageActions", () => {
},
},
} as OpenClawConfig,
expectSend: false,
expectPoll: false,
expectTopicEdit: true,
},
@@ -153,6 +155,7 @@ describe("telegramMessageActions", () => {
},
},
} as OpenClawConfig,
expectSend: true,
expectPoll: false,
expectTopicEdit: true,
},
@@ -180,6 +183,29 @@ describe("telegramMessageActions", () => {
},
},
} as OpenClawConfig,
expectSend: true,
expectPoll: false,
expectTopicEdit: true,
},
{
name: "all account send gates disabled hide send",
cfg: {
channels: {
telegram: {
accounts: {
first: {
botToken: "tok-first",
actions: { sendMessage: false },
},
second: {
botToken: "tok-second",
actions: { sendMessage: false },
},
},
},
},
} as OpenClawConfig,
expectSend: false,
expectPoll: false,
expectTopicEdit: true,
},
@@ -190,6 +216,11 @@ describe("telegramMessageActions", () => {
telegramMessageActions.describeMessageTool?.({
cfg: testCase.cfg,
})?.actions ?? [];
if (testCase.expectSend) {
expect(actions, testCase.name).toContain("send");
} else {
expect(actions, testCase.name).not.toContain("send");
}
if (testCase.expectPoll) {
expect(actions, testCase.name).toContain("poll");
} else {
@@ -267,6 +298,7 @@ describe("telegramMessageActions", () => {
work: {
botToken: "tok-work",
actions: {
sendMessage: false,
reactions: true,
poll: false,
},
@@ -287,8 +319,10 @@ describe("telegramMessageActions", () => {
accountId: "work",
})?.actions ?? [];
expect(defaultActions).toContain("send");
expect(defaultActions).toContain("poll");
expect(defaultActions).not.toContain("react");
expect(workActions).not.toContain("send");
expect(workActions).toContain("react");
expect(workActions).not.toContain("poll");
});
+4 -1
View File
@@ -170,7 +170,10 @@ function describeTelegramMessageTool({
schema: null,
};
}
const actions = new Set<ChannelMessageActionName>(["send"]);
const actions = new Set<ChannelMessageActionName>();
if (discovery.isEnabled("sendMessage")) {
actions.add("send");
}
if (discovery.pollEnabled) {
actions.add("poll");
}