From 1b9dc42250f34b5f919e419ca8ae995a2dd2f13e Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Sat, 16 May 2026 23:19:12 +0200 Subject: [PATCH] fix: bot trigger matched against message body only, not sender name Channel messages have the format "sender_name: body". The trigger was being searched across the whole string, so a nick containing the trigger word would fire a reply even with an unrelated message. Now the match skips past the ": " separator and only checks the message body. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/MyMeshBot.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/MyMeshBot.h b/examples/companion_radio/MyMeshBot.h index 673af4cf..0742bcd1 100644 --- a/examples/companion_radio/MyMeshBot.h +++ b/examples/companion_radio/MyMeshBot.h @@ -40,10 +40,15 @@ void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) { millis() - _bot_last_reply_ms > 10000UL)) return; + // Skip "sender_name: " prefix so the trigger is only matched against the message body. + const char* msg = text; + const char* sep = strstr(text, ": "); + if (sep) msg = sep + 2; + const char* tr = _prefs.bot_trigger; int tlen = strlen(tr); bool matched = false; - for (const char* t = text; *t && !matched; t++) { + for (const char* t = msg; *t && !matched; t++) { int i = 0; while (i < tlen && tolower((uint8_t)t[i]) == tolower((uint8_t)tr[i])) i++; if (i == tlen) matched = true;