feat: extend Telegram dock commands and config hashing (#929)

Thanks @grp06.

Co-authored-by: George Pickett <gpickett00@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-15 05:25:35 +00:00
parent a2f0d335f4
commit 54fb59b8f3
9 changed files with 49 additions and 18 deletions

View File

@@ -27,6 +27,18 @@ function defineChatCommand(command: DefineChatCommandInput): ChatCommandDefiniti
};
}
type ChannelDock = ReturnType<typeof listChannelDocks>[number];
function defineDockCommand(dock: ChannelDock): ChatCommandDefinition {
return defineChatCommand({
key: `dock:${dock.id}`,
nativeName: `dock_${dock.id}`,
description: `Switch to ${dock.id} for replies.`,
textAliases: [`/dock-${dock.id}`, `/dock_${dock.id}`],
acceptsArgs: false,
});
}
function registerAlias(commands: ChatCommandDefinition[], key: string, ...aliases: string[]): void {
const command = commands.find((entry) => entry.key === key);
if (!command) {
@@ -238,15 +250,7 @@ export const CHAT_COMMANDS: ChatCommandDefinition[] = (() => {
}),
...listChannelDocks()
.filter((dock) => dock.capabilities.nativeCommands)
.map((dock) =>
defineChatCommand({
key: `dock:${dock.id}`,
nativeName: `dock-${dock.id}`,
description: `Switch to ${dock.id} for replies.`,
textAlias: `/dock-${dock.id}`,
acceptsArgs: false,
}),
),
.map((dock) => defineDockCommand(dock)),
];
registerAlias(commands, "status", "/usage");

View File

@@ -113,4 +113,8 @@ describe("commands registry", () => {
"/help@otherbot",
);
});
it("normalizes dock command aliases", () => {
expect(normalizeCommandBody("/dock_telegram")).toBe("/dock-telegram");
});
});