mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
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.
This commit is contained in:
parent
77f99c4ff4
commit
8b1ff55f53
1 changed files with 5 additions and 0 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue