mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 22:41:36 +00:00
fix(mentions): check mentionPatterns even when explicit mention is available
This commit is contained in:
committed by
Ayaan Zaidi
parent
fcc53bcf1b
commit
22b59d24ce
@@ -4,7 +4,7 @@ import { matchesMentionWithExplicit } from "./mentions.js";
|
||||
describe("matchesMentionWithExplicit", () => {
|
||||
const mentionRegexes = [/\bclawd\b/i];
|
||||
|
||||
it("prefers explicit mentions when other mentions are present", () => {
|
||||
it("checks mentionPatterns even when explicit mention is available", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "@clawd hello",
|
||||
mentionRegexes,
|
||||
@@ -14,6 +14,19 @@ describe("matchesMentionWithExplicit", () => {
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when explicit is false and no regex match", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "<@999999> hello",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -90,7 +90,9 @@ export function matchesMentionWithExplicit(params: {
|
||||
const explicit = params.explicit?.isExplicitlyMentioned === true;
|
||||
const explicitAvailable = params.explicit?.canResolveExplicit === true;
|
||||
const hasAnyMention = params.explicit?.hasAnyMention === true;
|
||||
if (hasAnyMention && explicitAvailable) return explicit;
|
||||
if (hasAnyMention && explicitAvailable) {
|
||||
return explicit || params.mentionRegexes.some((re) => re.test(cleaned));
|
||||
}
|
||||
if (!cleaned) return explicit;
|
||||
return explicit || params.mentionRegexes.some((re) => re.test(cleaned));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user