fix: relax slash command parsing
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import { listChatCommands } from "./commands-registry.js";
|
||||
import { listChatCommands, normalizeCommandBody } from "./commands-registry.js";
|
||||
|
||||
export function hasControlCommand(text?: string): boolean {
|
||||
if (!text) return false;
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return false;
|
||||
const lowered = trimmed.toLowerCase();
|
||||
const normalizedBody = normalizeCommandBody(trimmed);
|
||||
if (!normalizedBody) return false;
|
||||
const lowered = normalizedBody.toLowerCase();
|
||||
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)) {
|
||||
const nextChar = trimmed.charAt(normalized.length);
|
||||
const nextChar = normalizedBody.charAt(normalized.length);
|
||||
if (nextChar && /\s/.test(nextChar)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user