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
Merge remote-tracking branch 'origin/main' into pr-2531
Xubin Ren722ffe0654b0
diff --cc nanobot/channels/whatsapp.pyindex c4c011304,1b46d6e97..a7fd82654--- a/nanobot/channels/whatsapp.py+++ b/nanobot/channels/whatsapp.py@@@ -51,7 -75,18 +75,19 @@@ class WhatsAppChannel(BaseChannel)self._ws = Noneself._connected = Falseself._processed_message_ids: OrderedDict[str, None] = OrderedDict()+ self._lid_to_phone: dict[str, str] = {}+ self._bridge_token: str | None = None++ def _effective_bridge_token(self) -> str:+ """Resolve the bridge token, generating a local secret when needed."""+ if self._bridge_token is not None:+ return self._bridge_token+ configured = self.config.bridge_token.strip()+ if configured:+ self._bridge_token = configured+ else:+ self._bridge_token = _load_or_create_bridge_token(_bridge_token_path())+ return self._bridge_tokenasync def login(self, force: bool = False) -> bool:"""@@@ -198,37 -228,10 +229,29 @@@if not was_mentioned:return- user_id = pn if pn else sender- sender_id = user_id.split("@")[0] if "@" in user_id else user_id- logger.info("Sender {}", sender)+ # Classify by JID suffix: @s.whatsapp.net = phone, @lid.whatsapp.net = LID+ # The bridge's pn/sender fields don't consistently map to phone/LID across versions.+ raw_a = pn or ""+ raw_b = sender or ""+ id_a = raw_a.split("@")[0] if "@" in raw_a else raw_a+ id_b = raw_b.split("@")[0] if "@" in raw_b else raw_b++ phone_id = ""+ lid_id = ""+ for raw, extracted in [(raw_a, id_a), (raw_b, id_b)]:+ if "@s.whatsapp.net" in raw:+ phone_id = extracted+ elif "@lid.whatsapp.net" in raw:+ lid_id = extracted+ elif extracted and not phone_id:+ phone_id = extracted # best guess for bare values++ if phone_id and lid_id:+ self._lid_to_phone[lid_id] = phone_id+ sender_id = phone_id or self._lid_to_phone.get(lid_id, "") or lid_id or id_a or id_b++ logger.info("Sender phone={} lid={} → sender_id={}", phone_id or "(empty)", lid_id or "(empty)", sender_id)- # Handle voice transcription if it's a voice message- if content == "[Voice Message]":- logger.info(- "Voice message received from {}, but direct download from bridge is not yet supported.",- sender_id,- )- content = "[Voice Message: Transcription not available for WhatsApp yet]"-# Extract media paths (images/documents/videos downloaded by the bridge)media_paths = data.get("media") or []