Merge pull request #146 from draix/fix/monitor-restart-after-hot-reload
Fix monitor restart after channel hot reload by aborting in-flight getUpdates long-poll requests.
Co-authored-by: Cursor cursoragent@cursor.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
WeChat
简体中文
OpenClaw’s WeChat channel plugin, supporting login authorization via QR code scanning.
Compatibility
latestlegacyPrerequisites
OpenClaw must be installed (the
openclawCLI needs to be available).Check your version:
openclaw --versionQuick Install
Manual Installation
If the quick install doesn’t work, follow these steps manually:
1. Install the plugin
2. Enable the plugin
3. QR code login
A QR code will appear in the terminal. Scan it with your phone and confirm the authorization. Once confirmed, the login credentials will be saved locally automatically — no further action is needed.
4. Restart the gateway
Adding More WeChat Accounts
Each QR code login creates a new account entry, supporting multiple WeChat accounts online simultaneously.
Multi-Account Context Isolation
By default, DMs can share one session bucket. For multiple logged-in WeChat accounts, isolate by account + channel + sender:
Custom BotAgent (optional)
Every outbound request to the WeChat backend carries a self-declared
bot_agentidentifier — analogous to an HTTPUser-Agent— used for log attribution and monitoring aggregation. The default isOpenClaw. Declaring your own app name makes it much easier to trace your traffic in backend logs.Add one line to
openclaw.json:Format (UA-style):
Name/Versiontokens, space-separated(comment)OpenClawif nothing valid remainsExamples that pass through unchanged:
MyBot/1.2.0MyBot/1.2.0 (region=cn;env=prod)MyBot/1.2.0 LangChain/0.3.5MyBot/1.2.0-rc.1+build.5Note:
bot_agentis for observability only — it is not used for authentication or routing. All registered agents on this plugin instance currently share the samebotAgentdeclaration; per-agent overrides may be added in a future version if needed.Backend API Protocol
This plugin communicates with the backend gateway via HTTP JSON API. Developers integrating with their own backend need to implement the following interfaces.
All endpoints use
POSTwith JSON request and response bodies. Common request headers:Content-Typeapplication/jsonAuthorizationTypeilink_bot_tokenAuthorizationBearer <token>(obtained after login)X-WECHAT-UINEndpoint List
getupdatessendmessagegetuploadurlgetconfigsendtypinggetUpdates
Long-polling endpoint. The server responds when new messages arrive or on timeout.
Request body:
get_updates_bufstringResponse body:
retnumber0= successerrcodenumber?-14= session timeout)errmsgstring?msgsWeixinMessage[]get_updates_bufstringlongpolling_timeout_msnumber?sendMessage
Send a message to a user.
Request body:
getUploadUrl
Get CDN upload pre-signed parameters. Call this endpoint before uploading a file to obtain
upload_paramandthumb_upload_param.Request body:
media_typenumber1= IMAGE,2= VIDEO,3= FILErawsizenumberrawfilemd5stringfilesizenumberthumb_rawsizenumber?thumb_rawfilemd5string?thumb_filesizenumber?Response body:
getConfig
Get account configuration, including the typing ticket.
Request body:
Response body:
sendTyping
Send or cancel the typing status indicator.
Request body:
statusnumber1= typing,2= cancel typingMessage Structure
WeixinMessage
seqnumber?message_idnumber?from_user_idstring?to_user_idstring?create_time_msnumber?session_idstring?message_typenumber?1= USER,2= BOTmessage_statenumber?0= NEW,1= GENERATING,2= FINISHitem_listMessageItem[]?context_tokenstring?MessageItem
typenumber1TEXT,2IMAGE,3VOICE,4FILE,5VIDEOtext_item{ text: string }?image_itemImageItem?voice_itemVoiceItem?file_itemFileItem?video_itemVideoItem?ref_msgRefMessage?CDN Media Reference (CDNMedia)
All media types (image/voice/file/video) are transferred via CDN using AES-128-ECB encryption:
encrypt_query_paramstring?aes_keystring?CDN Upload Flow
getUploadUrlto getupload_param(andthumb_upload_param)encrypt_query_paramto construct aCDNMediareference, include it in theMessageItem, and sendUninstall
Troubleshooting
“requires OpenClaw >=2026.3.22” error
Your OpenClaw version is too old for this plugin version. Check with:
Install the legacy plugin line instead:
Channel shows “OK” but doesn’t connect
Ensure
plugins.entries.openclaw-weixin.enabledistruein~/.openclaw/openclaw.json: