support bot, simplex-chat-nodejs: fix bot command parsing (#6964)

ciBotCommand's regex was unanchored, so a customer message like
"follow/read blog posts?" parsed as a /read command and the Grok
handler silently dropped the message. Anchor the regex with ^ so a
command requires `/` at the start of the (trimmed) message.

In the support bot, filter customer command parsing by the registered
keyword set: any unknown `/word` from a customer (e.g. /help) is now
routed as plain text instead of being silently dropped by Grok. This
also makes /grok when Grok is disabled behave consistently as text,
removing the previous ad-hoc workaround.
This commit is contained in:
sh
2026-05-12 08:52:50 +00:00
committed by GitHub
parent 78f987a448
commit 8841c73fb2
5 changed files with 109 additions and 12 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ export interface BotCommand {
export function ciBotCommand(chatItem: T.ChatItem): BotCommand | undefined {
const msg = ciContentText(chatItem)?.trim()
if (msg) {
const r = msg.match(/\/([^\s]+)(.*)/)
const r = msg.match(/^\/([^\s]+)(.*)/)
if (r && r.length >= 3) {
return {keyword: r[1], params: r[2].trim()}
}