name: wechat-send-text
向指定 wxid(好友或群聊)发送一条文字消息。这是 WeChat 技能中最常用的一个。
Step 1:(推荐)先调用 wechat-check-online 技能确认账号在线。
Step 2:从用户请求里提取两个参数:
toWxid:接收方 wxid(好友形如 wxid_abc123;群聊形如 12345@chatroom)content:要发送的文字内容如果用户没给出明确的 wxid,先问清楚。不要猜。
Step 3:用 exec/bash 工具执行:
API_BASE=$(node -e "console.log(JSON.parse(require('fs').readFileSync(require('path').join(require('os').homedir(),'.openclaw','wechat-credentials.json'),'utf8')).wechatApiBase)")
curl -s --max-time 15 -X POST "$API_BASE/message/send-text" \
-H "Content-Type: application/json" \
-d '{"toWxid":"<替换为真实wxid>","content":"<替换为真实内容>","ats":""}'
注意:
<替换为...>要真的替换为实际值。JSON 里的双引号和特殊字符需要转义;如果content含特殊字符,用 bash 的 heredoc 或jq -n构造 payload。
群聊中 @ 某人时,ats 字段传被 @ 的 wxid(多个用英文逗号)。
Step 4:解析响应。后端返回:
{ "ret": 200, "msg": "发送成功" }
ret == 200 → 回复用户:"已发送。"msg 报给用户wechat-send-text 当成 shell 命令 exec