mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-24 13:05:41 +00:00
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:
@@ -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()}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user