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:
Jakub
2026-07-10 20:16:59 +02:00
co-authored by Claude Sonnet 5
parent dfb993de53
commit afd7c0ee78
11 changed files with 744 additions and 181 deletions
+14 -3
View File
@@ -683,7 +683,7 @@ void MyMesh::onMessageRecv(const ContactInfo &from, mesh::Packet *pkt, uint32_t
// bitfield for transport packets, so it must not be used directly.)
uint8_t hops = pkt ? pkt->getPathHashCount() : 0;
if (!tryBotCommand(from, text, hops)) // commands take priority; fall through to trigger reply
tryBotReplyDM(from, text);
tryBotReplyDM(from, text, hops);
}
void MyMesh::onCommandDataRecv(const ContactInfo &from, mesh::Packet *pkt, uint32_t sender_timestamp,
@@ -709,6 +709,15 @@ void MyMesh::onSignedMessageRecv(const ContactInfo &from, mesh::Packet *pkt, uin
const char* who = (sc && sc->name[0]) ? sc->name : from.name;
_ui->onSharedLocation(nullptr, who, loc_lat, loc_lon, sender_timestamp, false);
}
// Room-server auto-reply bot — only ever fires for the room server contact
// itself (signed posts are how a room relays its members' messages back to
// us); a defensive type check lives in tryBotReplyRoom/tryBotRoomCommand too.
if (from.type == ADV_TYPE_ROOM) {
uint8_t hops = pkt ? pkt->getPathHashCount() : 0;
if (!tryBotRoomCommand(from, sender_prefix, text, hops)) // commands take priority
tryBotReplyRoom(from, sender_prefix, text, hops);
}
}
void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packet *pkt, uint32_t timestamp,
@@ -782,8 +791,9 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
#endif
// hop count for !hops (see onMessageRecv); not the wire path_len above.
if (!tryBotChannelCommand(channel_idx, text, pkt->getPathHashCount())) // commands take priority
tryBotReplyChannel(channel_idx, text);
uint8_t ch_hops = pkt->getPathHashCount();
if (!tryBotChannelCommand(channel_idx, text, ch_hops)) // commands take priority
tryBotReplyChannel(channel_idx, text, ch_hops);
}
void MyMesh::onChannelDataRecv(const mesh::GroupChannel &channel, mesh::Packet *pkt, uint16_t data_type,
@@ -1528,6 +1538,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
offline_queue_len = 0;
app_target_ver = 0;
_bot_last_ch_reply_ms = 0;
_bot_last_room_reply_ms = 0;
memset(_bot_dm_log, 0, sizeof(_bot_dm_log));
_bot_reply_count = 0;
_next_auto_advert_ms = 0;