mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 23:24:30 +00:00
refactor(auto-reply): share standard set/unset slash parsing
This commit is contained in:
23
src/auto-reply/reply/commands-setunset-standard.ts
Normal file
23
src/auto-reply/reply/commands-setunset-standard.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { parseSlashCommandWithSetUnset } from "./commands-setunset.js";
|
||||
|
||||
export function parseStandardSetUnsetSlashCommand<T>(params: {
|
||||
raw: string;
|
||||
slash: string;
|
||||
invalidMessage: string;
|
||||
usageMessage: string;
|
||||
onKnownAction: (action: string, args: string) => T | undefined;
|
||||
onSet?: (path: string, value: unknown) => T;
|
||||
onUnset?: (path: string) => T;
|
||||
onError?: (message: string) => T;
|
||||
}): T | null {
|
||||
return parseSlashCommandWithSetUnset<T>({
|
||||
raw: params.raw,
|
||||
slash: params.slash,
|
||||
invalidMessage: params.invalidMessage,
|
||||
usageMessage: params.usageMessage,
|
||||
onKnownAction: params.onKnownAction,
|
||||
onSet: params.onSet ?? ((path, value) => ({ action: "set", path, value }) as T),
|
||||
onUnset: params.onUnset ?? ((path) => ({ action: "unset", path }) as T),
|
||||
onError: params.onError ?? ((message) => ({ action: "error", message }) as T),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user