diff --git a/config.example.yaml b/config.example.yaml index 7db9780..ca5afd7 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -10,6 +10,7 @@ bot: owner: "" # Owner's callsign (optional) respond_to_mentions: true # Respond when name is mentioned respond_to_dms: true # Respond to direct messages + filter_bbs_protocols: true # Ignore advBBS sync/notification messages # === MESHTASTIC CONNECTION === connection: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index afb62ec..8586bf1 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -17,6 +17,7 @@ bot: owner: "" respond_to_mentions: true respond_to_dms: true + filter_bbs_protocols: true connection: type: tcp diff --git a/meshai/config.py b/meshai/config.py index b1bc443..d7241d8 100644 --- a/meshai/config.py +++ b/meshai/config.py @@ -19,6 +19,7 @@ class BotConfig: owner: str = "" respond_to_mentions: bool = True respond_to_dms: bool = True + filter_bbs_protocols: bool = True @dataclass diff --git a/meshai/router.py b/meshai/router.py index a208e97..0be458f 100644 --- a/meshai/router.py +++ b/meshai/router.py @@ -33,6 +33,14 @@ class RouteResult: query: Optional[str] = None # For LLM, the cleaned query +# advBBS protocol and notification prefixes to ignore +ADVBBS_PREFIXES = ( + "MAILREQ|", "MAILACK|", "MAILNAK|", "MAILDAT|", "MAILDLV|", + "BOARDREQ|", "BOARDACK|", "BOARDNAK|", "BOARDDAT|", "BOARDDLV|", + "advBBS|", + "[MAIL]", +) + # Patterns that suggest prompt injection attempts _INJECTION_PATTERNS = [ re.compile(r"ignore\s+(all\s+)?previous", re.IGNORECASE), @@ -80,6 +88,12 @@ class MessageRouter: if message.sender_id == self.connector.my_node_id: return False + # Ignore advBBS protocol and notification messages + if self.config.bot.filter_bbs_protocols: + if any(message.text.startswith(p) for p in ADVBBS_PREFIXES): + logger.debug(f"Ignoring advBBS message from {message.sender_id}: {message.text[:40]}...") + return False + # Check if DM — conversational mode only, skip !commands # (let MeshMonitor or other bots handle bang commands in DMs) if message.is_dm: