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 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-16 23:19:12 +02:00
parent 5bc250888f
commit 1b9dc42250

View File

@@ -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;