From 6bf63eb9c6ef54349bee0f8bb4a0e7590753ceb0 Mon Sep 17 00:00:00 2001 From: linuztx Date: Thu, 26 Mar 2026 09:57:34 +0800 Subject: [PATCH] feat: detect replies to bot messages in group chats --- plugins/_whatsapp_integration/README.md | 2 +- .../_whatsapp_integration/default_config.yaml | 2 +- .../_whatsapp_integration/helpers/handler.py | 6 ++--- .../_whatsapp_integration/webui/config.html | 2 +- .../whatsapp-bridge/bridge.js | 26 +++++++++++++++---- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/plugins/_whatsapp_integration/README.md b/plugins/_whatsapp_integration/README.md index 86e5b2ec0..711ef6423 100644 --- a/plugins/_whatsapp_integration/README.md +++ b/plugins/_whatsapp_integration/README.md @@ -23,7 +23,7 @@ The WhatsApp session persists across restarts in `usr/whatsapp/sessions/`. No re |---------|-------------|---------| | `enabled` | Enable bridge and polling | `false` | | `mode` | `dedicated` (separate number) or `self-chat` (personal number) | `dedicated` | -| `allow_group` | Respond in group chats when mentioned | `false` | +| `allow_group` | Respond in group chats when mentioned or replied to | `false` | | `bridge_port` | Local HTTP port for bridge | `3100` | | `poll_interval_seconds` | Poll frequency (min 2) | `3` | | `allowed_users` | Phone numbers without + prefix | `[]` (all) | diff --git a/plugins/_whatsapp_integration/default_config.yaml b/plugins/_whatsapp_integration/default_config.yaml index 242fe364a..35700c7d5 100644 --- a/plugins/_whatsapp_integration/default_config.yaml +++ b/plugins/_whatsapp_integration/default_config.yaml @@ -5,7 +5,7 @@ mode: dedicated bridge_port: 3100 poll_interval_seconds: 3 allow_group: false -# allow_group: respond in group chats when mentioned +# allow_group: respond in group chats when mentioned or replied to allowed_users: [] # Example: ["34652029134", "1234567890"] project: "" diff --git a/plugins/_whatsapp_integration/helpers/handler.py b/plugins/_whatsapp_integration/helpers/handler.py index 17f9953de..38d3006bd 100644 --- a/plugins/_whatsapp_integration/helpers/handler.py +++ b/plugins/_whatsapp_integration/helpers/handler.py @@ -69,13 +69,13 @@ async def _dispatch_message(config: dict, msg: dict) -> None: chat_id = msg.get("chatId", "") is_group = msg.get("isGroup", False) - # Group filtering: skip unless allow_group enabled AND bot was mentioned + # Group filtering: skip unless allow_group enabled AND bot was mentioned or replied to if is_group: if not config.get("allow_group", False): PrintStyle.debug(f"WhatsApp: skipping group message (allow_group disabled)") return - if not msg.get("mentionedMe", False): - PrintStyle.debug(f"WhatsApp: skipping group message (not mentioned)") + if not msg.get("mentionedMe", False) and not msg.get("repliedToMe", False): + PrintStyle.debug(f"WhatsApp: skipping group message (not mentioned or replied to)") return # Show typing indicator immediately so user sees activity diff --git a/plugins/_whatsapp_integration/webui/config.html b/plugins/_whatsapp_integration/webui/config.html index 0ce4ec2d7..8ca6ff9d9 100644 --- a/plugins/_whatsapp_integration/webui/config.html +++ b/plugins/_whatsapp_integration/webui/config.html @@ -131,7 +131,7 @@
Allow Group
-
Respond in group chats when mentioned
+
Respond in group chats when mentioned or replied to