mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 18:26:11 +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:
co-authored by
Claude Sonnet 4.6
parent
571a56e418
commit
9650ba685b
@@ -853,7 +853,8 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
|||||||
_cli_rescue = false;
|
_cli_rescue = false;
|
||||||
offline_queue_len = 0;
|
offline_queue_len = 0;
|
||||||
app_target_ver = 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;
|
_next_auto_advert_ms = 0;
|
||||||
clearPendingReqs();
|
clearPendingReqs();
|
||||||
next_ack_idx = 0;
|
next_ack_idx = 0;
|
||||||
|
|||||||
@@ -234,7 +234,8 @@ private:
|
|||||||
uint8_t *sign_data;
|
uint8_t *sign_data;
|
||||||
uint32_t sign_data_len;
|
uint32_t sign_data_len;
|
||||||
unsigned long dirty_contacts_expiry;
|
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;
|
unsigned long _next_auto_advert_ms;
|
||||||
|
|
||||||
TransportKey send_scope;
|
TransportKey send_scope;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
||||||
if (from.type != ADV_TYPE_CHAT) return;
|
if (from.type != ADV_TYPE_CHAT) return;
|
||||||
if (!(_prefs.bot_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_dm[0] &&
|
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;
|
return;
|
||||||
|
|
||||||
const char* tr = _prefs.bot_trigger;
|
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);
|
&sensors, (float)board.getBattMilliVolts() / 1000.0f);
|
||||||
uint32_t expected_ack, est_timeout;
|
uint32_t expected_ack, est_timeout;
|
||||||
if (sendMessage(from, ts, 0, expanded, expected_ack, est_timeout) != MSG_SEND_FAILED) {
|
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
|
#ifdef DISPLAY_CLASS
|
||||||
if (_ui) _ui->addDMMsg(from.id.pub_key, true, expanded);
|
if (_ui) _ui->addDMMsg(from.id.pub_key, true, expanded);
|
||||||
#endif
|
#endif
|
||||||
@@ -37,7 +37,7 @@ void MyMesh::tryBotReplyDM(const ContactInfo& from, const char* text) {
|
|||||||
void MyMesh::tryBotReplyChannel(uint8_t channel_idx, 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] &&
|
if (!(_prefs.bot_channel_enabled && _prefs.bot_trigger[0] && _prefs.bot_reply_ch[0] &&
|
||||||
channel_idx == _prefs.bot_channel_idx &&
|
channel_idx == _prefs.bot_channel_idx &&
|
||||||
millis() - _bot_last_reply_ms > 10000UL))
|
millis() - _bot_last_ch_reply_ms > 10000UL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Skip "sender_name: " prefix so the trigger is only matched against the message body.
|
// 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);
|
&sensors, (float)board.getBattMilliVolts() / 1000.0f);
|
||||||
int rlen = strlen(expanded);
|
int rlen = strlen(expanded);
|
||||||
if (sendGroupMessage(ts, ch.channel, _prefs.node_name, expanded, rlen)) {
|
if (sendGroupMessage(ts, ch.channel, _prefs.node_name, expanded, rlen)) {
|
||||||
_bot_last_reply_ms = millis();
|
_bot_last_ch_reply_ms = millis();
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
if (_ui) {
|
if (_ui) {
|
||||||
char with_sender[240]; // node_name(32) + ": "(2) + expanded(200) + margin
|
char with_sender[240]; // node_name(32) + ": "(2) + expanded(200) + margin
|
||||||
|
|||||||
Reference in New Issue
Block a user