mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
fix(hooks): track thread ownership mentions case-insensitively
This commit is contained in:
@@ -306,5 +306,24 @@ describe("thread-ownership plugin", () => {
|
||||
expect(result).toBeUndefined();
|
||||
expect(globalThis.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("tracks agent-name mentions case-insensitively", async () => {
|
||||
await hooks.message_received(
|
||||
{
|
||||
content: "hey @testbot help",
|
||||
threadId: "8888.0002",
|
||||
metadata: { channelId: "C789" },
|
||||
},
|
||||
{ channelId: "slack", conversationId: "C789" },
|
||||
);
|
||||
|
||||
const result = await hooks.message_sending(
|
||||
{ content: "On it!", replyToId: "8888.0002", metadata: { channelId: "C789" }, to: "C789" },
|
||||
{ channelId: "slack", conversationId: "C789" },
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(globalThis.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,6 +91,7 @@ export default definePluginEntry({
|
||||
}
|
||||
|
||||
const text = event.content ?? "";
|
||||
const normalizedText = text.toLowerCase();
|
||||
const threadTs =
|
||||
resolveThreadToken(event.threadId) ||
|
||||
resolveThreadToken(event.metadata?.threadId) ||
|
||||
@@ -104,7 +105,7 @@ export default definePluginEntry({
|
||||
}
|
||||
|
||||
const mentioned =
|
||||
(agentName && text.includes(`@${agentName}`)) ||
|
||||
(agentName && normalizedText.includes(`@${agentName.toLowerCase()}`)) ||
|
||||
(botUserId && text.includes(`<@${botUserId}>`));
|
||||
if (mentioned) {
|
||||
cleanExpiredMentions();
|
||||
|
||||
Reference in New Issue
Block a user