fix: separate DM and channel bot reply cooldown timers

Single shared _bot_last_reply_ms caused a DM reply to block the
channel bot for 10s and vice versa. Split into _bot_last_dm_reply_ms
and _bot_last_ch_reply_ms so each cooldown is independent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-16 23:26:31 +02:00
parent 44b2519df4
commit 5d41812784
3 changed files with 8 additions and 6 deletions

View File

@@ -5,7 +5,7 @@
void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
if (from.type != ADV_TYPE_CHAT) return;
if (!(_prefs.bot_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_dm[0] &&
millis() - _bot_last_reply_ms > 10000UL))
millis() - _bot_last_dm_reply_ms > 10000UL))
return;
const char* tr = _prefs.bot_trigger;
@@ -27,7 +27,7 @@ void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
&sensors, (float)board.getBattMilliVolts() / 1000.0f);
uint32_t expected_ack, est_timeout;
if (sendMessage(from, ts, 0, expanded, expected_ack, est_timeout) != MSG_SEND_FAILED) {
_bot_last_reply_ms = millis();
_bot_last_dm_reply_ms = millis();
#ifdef DISPLAY_CLASS
if (_ui) _ui->addDMMsg(from.id.pub_key, true, expanded);
#endif
@@ -37,7 +37,7 @@ void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) {
if (!(_prefs.bot_channel_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_ch[0] &&
channel_idx == _prefs.bot_channel_idx &&
millis() - _bot_last_reply_ms > 10000UL))
millis() - _bot_last_ch_reply_ms > 10000UL))
return;
// Skip "sender_name: " prefix so the trigger is only matched against the message body.
@@ -67,7 +67,7 @@ void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text) {
&sensors, (float)board.getBattMilliVolts() / 1000.0f);
int rlen = strlen(expanded);
if (sendGroupMessage(ts, ch.channel, _prefs.node_name, expanded, rlen)) {
_bot_last_reply_ms = millis();
_bot_last_ch_reply_ms = millis();
#ifdef DISPLAY_CLASS
if (_ui) {
char with_sender[240]; // node_name(32) + ": "(2) + expanded(200) + margin