Skip to content

fix(wecom): strip @mention prefix in group chats for slash command recognition - #13896

Closed
roytian1217 wants to merge 1 commit into
NousResearch:mainfrom
roytian1217:fix/wecom-group-mention-command
Closed

roytian1217 wants to merge 1 commit into
NousResearch:mainfrom
roytian1217:fix/wecom-group-mention-command

Conversation

@roytian1217

Copy link
Copy Markdown
Contributor

Problem

In WeCom (企业微信) group chats, when a user sends @BotName /approve, the event.text arrives as "@BotName /approve" — starting with @, not /.

This causes is_command() to return False and get_command() to return None, so slash commands like /approve and /deny are not recognized. Instead, the message falls through to the interrupt path, triggering an unintended "⚡ Interrupting current task" response.

Fix

Strip the leading @mention prefix from message text in group chats before creating the MessageEvent. This mirrors the existing behavior in the Telegram adapter (line ~2200 of gateway/run.py).

Changes

  • gateway/platforms/wecom.py: Added 5 lines after _extract_text() to strip @mention prefix via re.sub(r"^@\\S+\\s*", "", text).strip() when is_group is True.

…cognition

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.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Related to PR #11750 and issue #11447 — both address WeCom group @mention stripping. This PR may be a narrower duplicate.

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks @roytian1217! Your fix was cherry-picked and merged via #14477 with your authorship preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants