fix(wecom): strip @mention prefix in group chats for slash command recognition - #13896
Closed
roytian1217 wants to merge 1 commit into
Closed
roytian1217 wants to merge 1 commit into
roytian1217 wants to merge 1 commit into
Conversation
…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.
Contributor
Collaborator
|
Thanks @roytian1217! Your fix was cherry-picked and merged via #14477 with your authorship preserved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In WeCom (企业微信) group chats, when a user sends
@BotName /approve, theevent.textarrives as"@BotName /approve"— starting with@, not/.This causes
is_command()to returnFalseandget_command()to returnNone, so slash commands like/approveand/denyare not recognized. Instead, the message falls through to the interrupt path, triggering an unintended "⚡ Interrupting current task" response.Fix
Strip the leading
@mentionprefix from message text in group chats before creating theMessageEvent. This mirrors the existing behavior in the Telegram adapter (line ~2200 ofgateway/run.py).Changes
gateway/platforms/wecom.py: Added 5 lines after_extract_text()to strip@mentionprefix viare.sub(r"^@\\S+\\s*", "", text).strip()whenis_groupis True.