mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-05 03:36:13 +00:00
feat(bot): room-server target, tab-carousel UI, per-target independence
Auto-Reply Bot gains a third target (room servers, alongside DM and
channel), new {name}/{hops} reply placeholders, and a DM all/favourites
allow-list. BotScreen is redesigned as a circular tab carousel (Direct /
Channel / Room / Other, same interaction as Nearby Nodes' filter tabs)
instead of one long scrolling list, which also exposed and fixed a
leftover coupling where Channel/Room trigger-replies and their !command
handling secretly depended on the DM tab's Enable/Commands toggles —
each target's Enable and Commands are now fully independent.
- NodePrefs: bot_room_enabled/prefix/trigger/reply, bot_dm_scope,
bot_commands_ch/bot_commands_room (bot_commands_enabled repurposed as
DM-only). SCHEMA_SENTINEL 0xC0DE001D -> 0xC0DE001F; sizeof unchanged
at 2712 (new bytes absorbed existing padding, verified via a
standalone host compile + offsetof check).
- DataStore: persists all new fields; seeds bot_commands_ch/room from
the old shared bot_commands_enabled on upgrade so existing
channel/room command behaviour isn't silently lost.
- MyMeshBot: tryBotReplyRoom/tryBotRoomCommand mirror the channel bot's
shape but post via sendMessage (room relays to members itself);
requires an existing login session with that room, same as a manual
post would. botDmSenderAllowed() gates DM trigger-reply/commands on
the favourites bit when bot_dm_scope=Fav.
- MsgExpand: {name}/{hops} as optional trailing params (default
nullptr/-1, no existing caller affected) — deliberately not exposed
on the general compose keyboard, only on bot Reply fields.
- QuickMsgScreen/UITask: room-target picker (mirrors the channel
picker), routing through the existing room-login prompt when there's
no saved password yet.
- BotScreen: tab carousel (LEFT/RIGHT switches tabs, UP/DOWN moves
rows, Enter is now the only way to change a value); Enable split out
of Channel/Room's combo row; Quiet Hours gained a stepper sub-mode;
Commands moved from a shared toggle into each tab.
- docs/tools_screen.md updated for the new tab layout and behaviour.
Not build-verified — no PlatformIO toolchain in this environment.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -294,16 +294,24 @@ public:
|
||||
uint16_t botReplyCount() const { return _bot_reply_count; }
|
||||
|
||||
private:
|
||||
void tryBotReplyDM(const ContactInfo& from, const char* text);
|
||||
void tryBotReplyChannel(uint8_t channel_idx, const char* text);
|
||||
void tryBotReplyDM(const ContactInfo& from, const char* text, uint8_t hops);
|
||||
void tryBotReplyChannel(uint8_t channel_idx, const char* text, uint8_t hops);
|
||||
void tryBotReplyRoom(const ContactInfo& from, const uint8_t* sender_prefix, const char* text, uint8_t hops);
|
||||
bool tryBotCommand(const ContactInfo& from, const char* text, uint8_t hops); // DM commands
|
||||
bool tryBotChannelCommand(uint8_t channel_idx, const char* text, uint8_t hops); // channel commands
|
||||
bool botCommandReply(const char* cmd, uint8_t hops, uint32_t ts, char* out, int out_len); // one command → reply text
|
||||
int botScanCommands(const char* body, uint8_t hops, uint32_t ts, char* out, int out_len); // scan "!word"s → combined reply, returns count
|
||||
bool tryBotRoomCommand(const ContactInfo& from, const uint8_t* sender_prefix, const char* text, uint8_t hops); // room commands
|
||||
bool botCommandReply(const char* cmd, uint8_t hops, uint32_t ts, char* out, int out_len, const char* sender_name); // one command → reply text
|
||||
int botScanCommands(const char* body, uint8_t hops, uint32_t ts, char* out, int out_len, const char* sender_name); // scan "!word"s → combined reply, returns count
|
||||
bool botTriggerMatches(const char* trigger, const char* body, bool allow_wildcard) const;
|
||||
bool botInQuietHours() const; // true when auto-replies should stay silent
|
||||
bool botDmAllowed(const uint8_t* pubkey); // per-contact DM throttle: ok to reply?
|
||||
void botDmRecord(const uint8_t* pubkey); // remember we just replied to this contact
|
||||
// DM allow-list gate (bot_dm_scope): true unless scope is favourites-only
|
||||
// and `from` isn't starred. Shared by the DM trigger-reply and command paths.
|
||||
bool botDmSenderAllowed(const ContactInfo& from) const;
|
||||
// Resolves a room post's signed author prefix to a display name for {name};
|
||||
// falls back to a generic label when the poster isn't a known contact.
|
||||
void botRoomSenderName(const uint8_t* sender_prefix, char* out, int out_len);
|
||||
|
||||
void writeOKFrame();
|
||||
void writeErrFrame(uint8_t err_code);
|
||||
@@ -379,6 +387,7 @@ private:
|
||||
uint32_t sign_data_len;
|
||||
unsigned long dirty_contacts_expiry;
|
||||
unsigned long _bot_last_ch_reply_ms;
|
||||
unsigned long _bot_last_room_reply_ms;
|
||||
unsigned long _next_auto_advert_ms;
|
||||
|
||||
// Per-contact DM reply throttle: a small ring of the most recent recipients so
|
||||
|
||||
Reference in New Issue
Block a user