refactor: tidy directive parsing + queue status

This commit is contained in:
Peter Steinberger
2026-01-08 03:40:39 +01:00
parent e657e59b46
commit 8aa3efb9e8
7 changed files with 342 additions and 211 deletions

View File

@@ -1,3 +1,5 @@
import { normalizeCommandBody } from "./commands-registry.js";
export type GroupActivationMode = "mention" | "always";
export function normalizeGroupActivation(
@@ -16,11 +18,9 @@ export function parseActivationCommand(raw?: string): {
if (!raw) return { hasCommand: false };
const trimmed = raw.trim();
if (!trimmed) return { hasCommand: false };
const match = trimmed.match(
/^\/activation(?:\s*:\s*([a-zA-Z]+)?\s*|\s+([a-zA-Z]+)\s*)?$/i,
);
const normalized = normalizeCommandBody(trimmed);
const match = normalized.match(/^\/activation(?:\s+([a-zA-Z]+))?\s*$/i);
if (!match) return { hasCommand: false };
const token = match[1] ?? match[2];
const mode = normalizeGroupActivation(token);
const mode = normalizeGroupActivation(match[1]);
return { hasCommand: true, mode };
}