From 8b1ff55f5382052a5d98246659136e632af13697 Mon Sep 17 00:00:00 2001 From: roytian1217 <373119611@qq.com> Date: Wed, 22 Apr 2026 15:12:07 +0800 Subject: [PATCH] fix(wecom): strip @mention prefix in group chats for slash command recognition In WeCom group chats, messages sent as "@BotName /command" arrive with the @mention prefix intact. This causes is_command() to return False since the text does not start with "/". Strip the leading @mention in group messages before creating the MessageEvent, mirroring the existing behavior in the Telegram adapter. --- gateway/platforms/wecom.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway/platforms/wecom.py b/gateway/platforms/wecom.py index a6506d18a..7ba0fa21b 100644 --- a/gateway/platforms/wecom.py +++ b/gateway/platforms/wecom.py @@ -508,6 +508,11 @@ class WeComAdapter(BasePlatformAdapter): self._remember_chat_req_id(chat_id, self._payload_req_id(payload)) text, reply_text = self._extract_text(body) + # Strip leading @mention in group chats so slash commands like + # "@BotName /approve" are correctly recognized as "/approve". + # Mirrors what the Telegram adapter does (re.sub @botname). + if is_group and text: + text = re.sub(r"^@\S+\s*", "", text).strip() media_urls, media_types = await self._extract_media(body) message_type = self._derive_message_type(body, text, media_types) has_reply_context = bool(reply_text and (text or media_urls))