mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:28:27 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -12,21 +12,33 @@ export function hasControlCommand(
|
||||
cfg?: OpenClawConfig,
|
||||
options?: CommandNormalizeOptions,
|
||||
): boolean {
|
||||
if (!text) return false;
|
||||
if (!text) {
|
||||
return false;
|
||||
}
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return false;
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
const normalizedBody = normalizeCommandBody(trimmed, options);
|
||||
if (!normalizedBody) return false;
|
||||
if (!normalizedBody) {
|
||||
return false;
|
||||
}
|
||||
const lowered = normalizedBody.toLowerCase();
|
||||
const commands = cfg ? listChatCommandsForConfig(cfg) : listChatCommands();
|
||||
for (const command of commands) {
|
||||
for (const alias of command.textAliases) {
|
||||
const normalized = alias.trim().toLowerCase();
|
||||
if (!normalized) continue;
|
||||
if (lowered === normalized) return true;
|
||||
if (!normalized) {
|
||||
continue;
|
||||
}
|
||||
if (lowered === normalized) {
|
||||
return true;
|
||||
}
|
||||
if (command.acceptsArgs && lowered.startsWith(normalized)) {
|
||||
const nextChar = normalizedBody.charAt(normalized.length);
|
||||
if (nextChar && /\s/.test(nextChar)) return true;
|
||||
if (nextChar && /\s/.test(nextChar)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,10 +50,16 @@ export function isControlCommandMessage(
|
||||
cfg?: OpenClawConfig,
|
||||
options?: CommandNormalizeOptions,
|
||||
): boolean {
|
||||
if (!text) return false;
|
||||
if (!text) {
|
||||
return false;
|
||||
}
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return false;
|
||||
if (hasControlCommand(trimmed, cfg, options)) return true;
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
if (hasControlCommand(trimmed, cfg, options)) {
|
||||
return true;
|
||||
}
|
||||
const normalized = normalizeCommandBody(trimmed, options).trim().toLowerCase();
|
||||
return isAbortTrigger(normalized);
|
||||
}
|
||||
@@ -55,7 +73,9 @@ export function isControlCommandMessage(
|
||||
*/
|
||||
export function hasInlineCommandTokens(text?: string): boolean {
|
||||
const body = text ?? "";
|
||||
if (!body.trim()) return false;
|
||||
if (!body.trim()) {
|
||||
return false;
|
||||
}
|
||||
return /(?:^|\s)[/!][a-z]/i.test(body);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user