Add advBBS protocol message filter to router

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-02-23 21:28:20 +00:00
commit 247074afd1
4 changed files with 17 additions and 0 deletions

View file

@ -10,6 +10,7 @@ bot:
owner: "" # Owner's callsign (optional) owner: "" # Owner's callsign (optional)
respond_to_mentions: true # Respond when name is mentioned respond_to_mentions: true # Respond when name is mentioned
respond_to_dms: true # Respond to direct messages respond_to_dms: true # Respond to direct messages
filter_bbs_protocols: true # Ignore advBBS sync/notification messages
# === MESHTASTIC CONNECTION === # === MESHTASTIC CONNECTION ===
connection: connection:

View file

@ -17,6 +17,7 @@ bot:
owner: "" owner: ""
respond_to_mentions: true respond_to_mentions: true
respond_to_dms: true respond_to_dms: true
filter_bbs_protocols: true
connection: connection:
type: tcp type: tcp

View file

@ -19,6 +19,7 @@ class BotConfig:
owner: str = "" owner: str = ""
respond_to_mentions: bool = True respond_to_mentions: bool = True
respond_to_dms: bool = True respond_to_dms: bool = True
filter_bbs_protocols: bool = True
@dataclass @dataclass

View file

@ -33,6 +33,14 @@ class RouteResult:
query: Optional[str] = None # For LLM, the cleaned query 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 # Patterns that suggest prompt injection attempts
_INJECTION_PATTERNS = [ _INJECTION_PATTERNS = [
re.compile(r"ignore\s+(all\s+)?previous", re.IGNORECASE), 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: if message.sender_id == self.connector.my_node_id:
return False 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 # Check if DM — conversational mode only, skip !commands
# (let MeshMonitor or other bots handle bang commands in DMs) # (let MeshMonitor or other bots handle bang commands in DMs)
if message.is_dm: if message.is_dm: