mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 23:24:44 +02:00
Add advBBS protocol message filter to router
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2a857bcb70
commit
247074afd1
4 changed files with 17 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ bot:
|
|||
owner: ""
|
||||
respond_to_mentions: true
|
||||
respond_to_dms: true
|
||||
filter_bbs_protocols: true
|
||||
|
||||
connection:
|
||||
type: tcp
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class BotConfig:
|
|||
owner: str = ""
|
||||
respond_to_mentions: bool = True
|
||||
respond_to_dms: bool = True
|
||||
filter_bbs_protocols: bool = True
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue