From 7732464b2b46d5d1692ccaeafbcaed9062c304e8 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 3 Oct 2026 14:31:32 -0700 Subject: [PATCH] refactor(bridges): split the sender before the DM and mapping guards, as before Codex review of 9b86cd63: ChannelBridgeBase ran the DM guard and the channel lookup before parsing "sender: message", but both bridges evaluated `':' in text` first. A non-string text (None, an int) on a DM or unmapped channel used to log "Error handling mesh channel message" with exc_info and now logged a DEBUG skip instead. The split runs first again. The bridge replay now includes None, int, bytes and list texts; it differs from the pre-bridge code on 9b86cd63 and matches it after this commit. --- .../service_plugins/channel_bridge_utils.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/service_plugins/channel_bridge_utils.py b/modules/service_plugins/channel_bridge_utils.py index 805251f..4ccde98 100644 --- a/modules/service_plugins/channel_bridge_utils.py +++ b/modules/service_plugins/channel_bridge_utils.py @@ -150,6 +150,17 @@ class ChannelBridgeBase(BaseServicePlugin): channel_name = self.bot.channel_manager.get_channel_name(channel_idx) text = payload.get('text', '') + # Sender is embedded in the text ("sender: message"). Split before the + # guards below, as before: a text that can't be split fails here, logged + # as an error, even for a DM or an unmapped channel. + if ':' in text and not text.startswith('http'): + parts = text.split(':', 1) + sender_name = parts[0].strip() + message_text = parts[1].strip() if len(parts) > 1 else text + else: + sender_name = 'Unknown' + message_text = text + # NEVER bridge DMs (double-check for safety) if not channel_name or channel_name.lower() in ('dm', 'direct', 'private'): self.logger.debug("Ignoring DM (DMs are never bridged)") @@ -160,15 +171,6 @@ class ChannelBridgeBase(BaseServicePlugin): self.logger.debug(f"Channel '{channel_name}' not configured for {self.bridge_label} bridge") return - # Sender is embedded in the text ("sender: message") - if ':' in text and not text.startswith('http'): - parts = text.split(':', 1) - sender_name = parts[0].strip() - message_text = parts[1].strip() if len(parts) > 1 else text - else: - sender_name = 'Unknown' - message_text = text - message_text = self._prepare_message_text(message_text) # Profanity filter: drop (don't bridge), censor (replace with ****), or off