Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(chat): reject plus-joined stop target prefixes

Afloat6870120faac7
diff --git a/server/host/person-stop.test.ts b/server/host/person-stop.test.ts
index 54c8971fea..d3b7c9ca2c 100644
--- a/server/host/person-stop.test.ts
+++ b/server/host/person-stop.test.ts
@@ -58,7 +58,7 @@ describe("a typed stop", () => {
expect(w.rows).toHaveLength(1);
});
- it.each(["stop @Todo", "stop @Now", "@Adaplease stop", "@Ada.stop stop", "@everyone stop @Todo"])(
+ it.each(["stop @Todo", "stop @Now", "@Adaplease stop", "@Ada.stop stop", "@Ada+Todo stop", "@all+Please stop", "@everyone stop @Todo"])(
"leaves the current turn running when the stop names someone else: %s", async (text) => {
const w = world({ working: ["t", "other"] });
expect(await w.send(text, { busy: true })).toBeNull();
diff --git a/server/room-holds.test.ts b/server/room-holds.test.ts
index 9445ea3a89..48322367d3 100644
--- a/server/room-holds.test.ts
+++ b/server/room-holds.test.ts
@@ -138,6 +138,8 @@ describe("isStopCommand", () => {
"stop @Stop",
"@Adaplease stop",
"@Ada.stop stop",
+ "@Ada+Todo stop",
+ "@all+Please stop",
"@everyoneplease stop",
"/@Ada stop",
"@everyone stop @Todo",
@@ -153,6 +155,7 @@ describe("isStopCommand", () => {
["@Ada-Bot stop", "Ada-Bot"],
["@Ada.Bot stop", "Ada.Bot"],
["@A+Bot stop", "A+Bot"],
+ ["@Ada+Todo stop", "Ada+Todo"],
["@Chris Assistent stop", "Chris Assistent"],
["@Rene\u0301 stop", "René"],
["【@小助手】停止", "小助手"],
diff --git a/server/room-holds.ts b/server/room-holds.ts
index d13fe5c0c9..ad3e54df01 100644
--- a/server/room-holds.ts
+++ b/server/room-holds.ts
@@ -101,7 +101,7 @@ export function isStopCommand(text: string, ownName?: string): boolean {
if (!isMentionBoundary(line, at)) return false;
const name = names.find((candidate) => {
const tail = line.slice(at + 1 + candidate.length);
- return line.startsWith(candidate, at + 1) && !isMentionNameContinuation(tail) && !/^[.-][\p{L}\p{M}\p{N}_]/u.test(tail);
+ return line.startsWith(candidate, at + 1) && !isMentionNameContinuation(tail) && !/^[.+-][\p{L}\p{M}\p{N}_]/u.test(tail);
});
if (!name) return false;
parts.push(line.slice(start, at));