mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 15:45:01 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -28,7 +28,9 @@ const BACKSPACE_CHAR = "\u0008";
|
||||
export const CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
|
||||
|
||||
function normalizeMentionPattern(pattern: string): string {
|
||||
if (!pattern.includes(BACKSPACE_CHAR)) return pattern;
|
||||
if (!pattern.includes(BACKSPACE_CHAR)) {
|
||||
return pattern;
|
||||
}
|
||||
return pattern.split(BACKSPACE_CHAR).join("\\b");
|
||||
}
|
||||
|
||||
@@ -37,7 +39,9 @@ function normalizeMentionPatterns(patterns: string[]): string[] {
|
||||
}
|
||||
|
||||
function resolveMentionPatterns(cfg: OpenClawConfig | undefined, agentId?: string): string[] {
|
||||
if (!cfg) return [];
|
||||
if (!cfg) {
|
||||
return [];
|
||||
}
|
||||
const agentConfig = agentId ? resolveAgentConfig(cfg, agentId) : undefined;
|
||||
const agentGroupChat = agentConfig?.groupChat;
|
||||
if (agentGroupChat && Object.hasOwn(agentGroupChat, "mentionPatterns")) {
|
||||
@@ -69,9 +73,13 @@ export function normalizeMentionText(text: string): string {
|
||||
}
|
||||
|
||||
export function matchesMentionPatterns(text: string, mentionRegexes: RegExp[]): boolean {
|
||||
if (mentionRegexes.length === 0) return false;
|
||||
if (mentionRegexes.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const cleaned = normalizeMentionText(text ?? "");
|
||||
if (!cleaned) return false;
|
||||
if (!cleaned) {
|
||||
return false;
|
||||
}
|
||||
return mentionRegexes.some((re) => re.test(cleaned));
|
||||
}
|
||||
|
||||
@@ -93,7 +101,9 @@ export function matchesMentionWithExplicit(params: {
|
||||
if (hasAnyMention && explicitAvailable) {
|
||||
return explicit || params.mentionRegexes.some((re) => re.test(cleaned));
|
||||
}
|
||||
if (!cleaned) return explicit;
|
||||
if (!cleaned) {
|
||||
return explicit;
|
||||
}
|
||||
return explicit || params.mentionRegexes.some((re) => re.test(cleaned));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user