feat: improve gateway services and auto-reply commands
This commit is contained in:
@@ -290,6 +290,21 @@ export function listChatCommands(): ChatCommandDefinition[] {
|
||||
return [...CHAT_COMMANDS];
|
||||
}
|
||||
|
||||
export function isCommandEnabled(
|
||||
cfg: ClawdbotConfig,
|
||||
commandKey: string,
|
||||
): boolean {
|
||||
if (commandKey === "config") return cfg.commands?.config === true;
|
||||
if (commandKey === "debug") return cfg.commands?.debug === true;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function listChatCommandsForConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
): ChatCommandDefinition[] {
|
||||
return CHAT_COMMANDS.filter((command) => isCommandEnabled(cfg, command.key));
|
||||
}
|
||||
|
||||
export function listNativeCommandSpecs(): NativeCommandSpec[] {
|
||||
return CHAT_COMMANDS.filter(
|
||||
(command) => command.scope !== "text" && command.nativeName,
|
||||
@@ -300,6 +315,18 @@ export function listNativeCommandSpecs(): NativeCommandSpec[] {
|
||||
}));
|
||||
}
|
||||
|
||||
export function listNativeCommandSpecsForConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
): NativeCommandSpec[] {
|
||||
return listChatCommandsForConfig(cfg)
|
||||
.filter((command) => command.scope !== "text" && command.nativeName)
|
||||
.map((command) => ({
|
||||
name: command.nativeName ?? command.key,
|
||||
description: command.description,
|
||||
acceptsArgs: Boolean(command.acceptsArgs),
|
||||
}));
|
||||
}
|
||||
|
||||
export function findCommandByNativeName(
|
||||
name: string,
|
||||
): ChatCommandDefinition | undefined {
|
||||
|
||||
Reference in New Issue
Block a user