mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
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:
@@ -853,7 +853,8 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
||||
_cli_rescue = false;
|
||||
offline_queue_len = 0;
|
||||
app_target_ver = 0;
|
||||
_bot_last_reply_ms = 0;
|
||||
_bot_last_dm_reply_ms = 0;
|
||||
_bot_last_ch_reply_ms = 0;
|
||||
_next_auto_advert_ms = 0;
|
||||
clearPendingReqs();
|
||||
next_ack_idx = 0;
|
||||
|
||||
@@ -234,7 +234,8 @@ private:
|
||||
uint8_t *sign_data;
|
||||
uint32_t sign_data_len;
|
||||
unsigned long dirty_contacts_expiry;
|
||||
unsigned long _bot_last_reply_ms;
|
||||
unsigned long _bot_last_dm_reply_ms;
|
||||
unsigned long _bot_last_ch_reply_ms;
|
||||
unsigned long _next_auto_advert_ms;
|
||||
|
||||
TransportKey send_scope;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user