weixin_clawbot 0.3.0
weixin_clawbot: ^0.3.0 copied to clipboard
A pure Dart package for binding WeChat via QR code and receiving/sending messages through the WeChat iLink Bot API (OpenClaw ClawBot). Works with both SDKs: Dart servers/CLIs and Flutter mobile/deskto [...]
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.3.0 - 2026-10-10 #
Changed #
- 包改为纯 Dart 核心,单包声明双 SDK(Breaking):移除
flutter/shared_preferences/qr_flutter依赖 —— Dart 服务器(如 REST 后端)可直接 依赖本包调用 iLink Bot API(绑定、收发消息、CDN 媒体下载解密)。pubspecenvironment保留flutter:声明,pub.dev 显示 Dart + Flutter 双 SDK 徽章, Flutter 项目照常依赖。 - Flutter 登录 UI 移到 example(Breaking):
QrLoginWidget/showQrLoginDialog不再从package:weixin_clawbot导出,需要时复制example/lib/qr_login_widget.dart(依赖qr_flutter)到你的应用, 行为与 0.2.0 一致。 AccountStore持久化后端可插拔(AccountStorage接口):- 原生平台 / Dart 服务器:JSON 文件
~/.weixin_clawbot/accounts.json(可用AccountStore(storage: ...)注入自定义后端); - Web:浏览器 localStorage,读写兼容 0.2.x
shared_preferences的flutter.weixin_clawbot_accounts旧键; - 不再依赖
shared_preferences,纯 Dart 服务器开箱即用。
- 原生平台 / Dart 服务器:JSON 文件
- SDK 下限提升到 Dart
>=3.4.0(Web 存储后端需要package:web)。
0.2.0 - 2026-10-10 #
Added #
- README 增加源码仓库地址与官方参考致谢(Tencent/openclaw-weixin)。
- 扫码绑定对齐官方
waitForWeixinLogin状态机:need_verifycode:手机微信显示配对数字时,UI 弹出输入框(QrVerifyCodeRequiredEvent+QrLoginSession.submitVerifyCode),以&verify_code=提交后继续登录;scaned_but_redirect:IDC 重定向自动切换轮询域名(Web 端经代理/redirect/<host>);binded_redirect/verify_code_blocked:明确的终止提示事件;get_bot_qrcode改为 POST +local_token_list(携带本机已存 bot token,可判定已绑定)。
- 接收图片:完整解析
image_item(CdnMedia下载参数 + AES 密钥,WeixinMessage.imageItem)。 WeixinClawbot.downloadImage()/downloadMedia():从微信 CDN 下载并按 AES-128-ECB + PKCS7 解密入站媒体,支持image_item.aeskey(hex)与media.aes_key(base64)两种密钥形态,与官方 openclaw-weixin 接收逻辑一致。- Flutter Web:CDN 请求经
<proxyBaseUrl>/cdn转发,proxy_server.dart已支持。 - example:消息气泡直接渲染入站图片(下载解密 →
Image.memory)。
Fixed #
- Flutter Web 接收图片失败("图片下载失败"):服务端常直接下发
media.full_url, 原实现会让浏览器直连 CDN(无 CORS 头,必被拦截)。现在full_url与自拼 URL 一样经本地代理转发——代理新增/cdnfull/<host>/<path>路由 (白名单weixin.qq.com/qq.com及子域)。 image_item.aeskey非法(奇数长度/非 hex/非 16 字节)时回退media.aes_key或按明文下载,与官方 Node 侧宽松语义一致,不再让整次下载抛异常。- example 图片气泡显示具体错误详情并支持点击重试;无下载参数时显示
[图片]占位而非发起注定失败的请求。
0.1.0 - 2026-05-08 #
Added #
WeixinClawbot门面类:统一管理账号、连接与消息收发。- QR 扫码绑定流程(
startQrLogin、QrLoginWidget、showQrLoginDialog)。 - HTTP 长轮询接收微信消息(
connect→Stream<WeixinMessage>)。 - 发送文本消息(
sendText),自动携带context_token。 AccountStore:使用shared_preferences跨重启持久化账号凭证。- Flutter Web 支持:通过
proxyBaseUrl绕过浏览器 CORS 限制,配套proxy_server.dart。 - 完整示例应用(
example/)演示绑定、接收、发送全流程。