2026-01-08 03:22:14 +01:00
|
|
|
import { listChatCommands, normalizeCommandBody } from "./commands-registry.js";
|
2026-01-05 01:31:36 +01:00
|
|
|
|
|
|
|
|
export function hasControlCommand(text?: string): boolean {
|
|
|
|
|
if (!text) return false;
|
|
|
|
|
const trimmed = text.trim();
|
|
|
|
|
if (!trimmed) return false;
|
2026-01-08 03:22:14 +01:00
|
|
|
const normalizedBody = normalizeCommandBody(trimmed);
|
|
|
|
|
if (!normalizedBody) return false;
|
|
|
|
|
const lowered = normalizedBody.toLowerCase();
|
2026-01-06 14:17:56 -06:00
|
|
|
for (const command of listChatCommands()) {
|
|
|
|
|
for (const alias of command.textAliases) {
|
|
|
|
|
const normalized = alias.trim().toLowerCase();
|
|
|
|
|
if (!normalized) continue;
|
|
|
|
|
if (lowered === normalized) return true;
|
|
|
|
|
if (command.acceptsArgs && lowered.startsWith(normalized)) {
|
2026-01-08 03:22:14 +01:00
|
|
|
const nextChar = normalizedBody.charAt(normalized.length);
|
2026-01-06 14:17:56 -06:00
|
|
|
if (nextChar && /\s/.test(nextChar)) return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2026-01-05 01:31:36 +01:00
|
|
|
}
|