Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(whatsapp): add group_policy to control bot response behavior in groups
flobo3b14d5a0a1d7a
diff --git a/nanobot/channels/whatsapp.py b/nanobot/channels/whatsapp.pyindex b689e3060..6f4271e24 100644--- a/nanobot/channels/whatsapp.py+++ b/nanobot/channels/whatsapp.py@@ -4,7 +4,7 @@ import asyncioimport jsonimport mimetypesfrom collections import OrderedDict-from typing import Any+from typing import Any, Literalfrom loguru import logger@@ -23,6 +23,7 @@ class WhatsAppConfig(Base):bridge_url: str = "ws://localhost:3001"bridge_token: str = ""allow_from: list[str] = Field(default_factory=list)+ group_policy: Literal["open", "mention"] = "open" # "open" responds to all, "mention" only when @mentionedclass WhatsAppChannel(BaseChannel):@@ -138,6 +139,13 @@ class WhatsAppChannel(BaseChannel):self._processed_message_ids.popitem(last=False)# Extract just the phone number or lid as chat_id+ is_group = data.get("isGroup", False)+ was_mentioned = data.get("wasMentioned", False)++ if is_group and getattr(self.config, "group_policy", "open") == "mention":+ if not was_mentioned:+ return+user_id = pn if pn else sendersender_id = user_id.split("@")[0] if "@" in user_id else user_idlogger.info("Sender {}", sender)