From cf6928fd5db25eb39dcc0cd03af223f1468cfa16 Mon Sep 17 00:00:00 2001 From: Mr Simon C Date: Mon, 9 Sep 2024 22:40:06 +0100 Subject: [PATCH] match user prompts exactly not partially (#2245) --- server/utils/chats/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/utils/chats/index.js b/server/utils/chats/index.js index 387b70ce7..067b968ce 100644 --- a/server/utils/chats/index.js +++ b/server/utils/chats/index.js @@ -25,7 +25,10 @@ async function grepCommand(message, user = null) { // Allows multiple commands in one message let updatedMessage = message; for (const preset of userPresets) { - const regex = new RegExp(preset.command, "g"); + const regex = new RegExp( + `(?:\\b\\s|^)(${preset.command})(?:\\b\\s|$)`, + "g" + ); updatedMessage = updatedMessage.replace(regex, preset.prompt); }