fix: normalize telegram command mentions

This commit is contained in:
Ayaan Zaidi
2026-01-11 21:06:04 +05:30
parent 933c157092
commit 68f6f3f0bd
5 changed files with 65 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import {
listChatCommandsForConfig,
listNativeCommandSpecs,
listNativeCommandSpecsForConfig,
normalizeCommandBody,
shouldHandleTextCommands,
} from "./commands-registry.js";
@@ -92,4 +93,26 @@ describe("commands registry", () => {
}),
).toBe(true);
});
it("normalizes telegram-style command mentions for the current bot", () => {
expect(
normalizeCommandBody("/help@clawdbot", { botUsername: "clawdbot" }),
).toBe("/help");
expect(
normalizeCommandBody("/help@clawdbot args", {
botUsername: "clawdbot",
}),
).toBe("/help args");
expect(
normalizeCommandBody("/help@clawdbot: args", {
botUsername: "clawdbot",
}),
).toBe("/help args");
});
it("keeps telegram-style command mentions for other bots", () => {
expect(
normalizeCommandBody("/help@otherbot", { botUsername: "clawdbot" }),
).toBe("/help@otherbot");
});
});