mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 06:22:42 +00:00
feat: add sessions tools and send policy
This commit is contained in:
29
src/auto-reply/send-policy.ts
Normal file
29
src/auto-reply/send-policy.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export type SendPolicyOverride = "allow" | "deny";
|
||||
|
||||
export function normalizeSendPolicyOverride(
|
||||
raw?: string | null,
|
||||
): SendPolicyOverride | undefined {
|
||||
const value = raw?.trim().toLowerCase();
|
||||
if (!value) return undefined;
|
||||
if (value === "allow" || value === "on") return "allow";
|
||||
if (value === "deny" || value === "off") return "deny";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function parseSendPolicyCommand(raw?: string): {
|
||||
hasCommand: boolean;
|
||||
mode?: SendPolicyOverride | "inherit";
|
||||
} {
|
||||
if (!raw) return { hasCommand: false };
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) return { hasCommand: false };
|
||||
const match = trimmed.match(/^\/?send\b(?:\s+([a-zA-Z]+))?/i);
|
||||
if (!match) return { hasCommand: false };
|
||||
const token = match[1]?.trim().toLowerCase();
|
||||
if (!token) return { hasCommand: true };
|
||||
if (token === "inherit" || token === "default" || token === "reset") {
|
||||
return { hasCommand: true, mode: "inherit" };
|
||||
}
|
||||
const mode = normalizeSendPolicyOverride(token);
|
||||
return { hasCommand: true, mode };
|
||||
}
|
||||
Reference in New Issue
Block a user