mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 22:10:21 +00:00
fix(telegram): exclude plugin commands from setMyCommands when native=false (openclaw#15164) thanks @Glucksberg
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test Co-authored-by: Glucksberg <80581902+Glucksberg@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -23,7 +23,7 @@ vi.mock("../pairing/pairing-store.js", () => ({
|
||||
}));
|
||||
|
||||
describe("registerTelegramNativeCommands (plugin auth)", () => {
|
||||
it("caps menu registration at 100 while leaving hidden plugin handlers available", () => {
|
||||
it("does not register plugin commands in menu when native=false but keeps handlers available", () => {
|
||||
const specs = Array.from({ length: 101 }, (_, i) => ({
|
||||
name: `cmd_${i}`,
|
||||
description: `Command ${i}`,
|
||||
@@ -73,14 +73,8 @@ describe("registerTelegramNativeCommands (plugin auth)", () => {
|
||||
opts: { token: "token" },
|
||||
});
|
||||
|
||||
const registered = setMyCommands.mock.calls[0]?.[0] as Array<{
|
||||
command: string;
|
||||
description: string;
|
||||
}>;
|
||||
expect(registered).toHaveLength(100);
|
||||
expect(registered[0]).toEqual({ command: "cmd_0", description: "Command 0" });
|
||||
expect(registered[99]).toEqual({ command: "cmd_99", description: "Command 99" });
|
||||
expect(log).toHaveBeenCalledWith(expect.stringContaining("registering first 100"));
|
||||
expect(setMyCommands).not.toHaveBeenCalled();
|
||||
expect(log).not.toHaveBeenCalledWith(expect.stringContaining("registering first 100"));
|
||||
expect(Object.keys(handlers)).toHaveLength(101);
|
||||
});
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ export const registerTelegramNativeCommands = ({
|
||||
command: command.name,
|
||||
description: command.description,
|
||||
})),
|
||||
...pluginCatalog.commands,
|
||||
...(nativeEnabled ? pluginCatalog.commands : []),
|
||||
...customCommands,
|
||||
];
|
||||
const { commandsToRegister, totalCommands, maxCommands, overflowCount } =
|
||||
@@ -357,7 +357,7 @@ export const registerTelegramNativeCommands = ({
|
||||
// Keep hidden commands callable by registering handlers for the full catalog.
|
||||
syncTelegramMenuCommands({ bot, runtime, commandsToRegister });
|
||||
|
||||
if (commandsToRegister.length > 0) {
|
||||
if (commandsToRegister.length > 0 || pluginCatalog.commands.length > 0) {
|
||||
if (typeof (bot as unknown as { command?: unknown }).command !== "function") {
|
||||
logVerbose("telegram: bot.command unavailable; skipping native handlers");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user