mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
Bot: add DM contact target alongside channel
The bot can now reply to a specific DM contact instead of a channel. UI (BotScreen): item 1 cycles through all channels followed by all DM contacts (ADV_TYPE_CHAT). The label switches between "Channel" / "Contact" and the value shows the channel or contact name. Left/right/enter navigate the combined list. Logic (MyMesh::onMessageRecv): when bot_target_type==1, match the trigger against incoming DM text and reply via sendMessage(). A 4-byte pubkey prefix identifies the target; all-zero prefix matches any DM sender. Persistence: bot_target_type and bot_dm_pubkey[4] appended to prefs with backward-compat read guard (old firmware defaults to channel mode). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -258,6 +258,10 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
|
||||
file.read((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
||||
file.read((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
||||
file.read((uint8_t *)_prefs.bot_reply, sizeof(_prefs.bot_reply));
|
||||
if (file.available()) {
|
||||
file.read((uint8_t *)&_prefs.bot_target_type, sizeof(_prefs.bot_target_type));
|
||||
file.read((uint8_t *)_prefs.bot_dm_pubkey, sizeof(_prefs.bot_dm_pubkey));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,6 +326,8 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
|
||||
file.write((uint8_t *)&_prefs.bot_channel_idx, sizeof(_prefs.bot_channel_idx));
|
||||
file.write((uint8_t *)_prefs.bot_trigger, sizeof(_prefs.bot_trigger));
|
||||
file.write((uint8_t *)_prefs.bot_reply, sizeof(_prefs.bot_reply));
|
||||
file.write((uint8_t *)&_prefs.bot_target_type, sizeof(_prefs.bot_target_type));
|
||||
file.write((uint8_t *)_prefs.bot_dm_pubkey, sizeof(_prefs.bot_dm_pubkey));
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user