将 OpenClaw AI 助手接入个人微信,实现自动回复功能。
- 💬 自动回复:私聊和群聊自动回复
- 🔗 引用消息支持:正确处理微信引用/回复消息
- 🚀 开机自启:支持 Windows 开机自动启动
- 📝 简单易用:一键启动脚本,无需复杂配置
- 🎭 灵活配置:支持任何 OpenClaw Agent 人格
- 操作系统: Windows 10/11
- Python: 3.8 或更高版本
- 微信: PC 版微信(版本 3.7.0.30 测试通过)
- OpenClaw: 已安装并配置好 AI 模型
git clone https://github.com/DSeaStar/openclaw-wechat-bot.git
cd openclaw-wechat-botpip install -r requirements.txt确保 OpenClaw 已安装并启用 HTTP API:
{
"gateway": {
"port": 18789,
"auth": {
"mode": "token",
"token": "your_token_here"
},
"http": {
"endpoints": {
"chatCompletions": { "enabled": true }
}
}
}
}复制配置示例并修改:
cp config.example.json config.json编辑 config.json,填入你的 OpenClaw Token。
- 下载 ComWeChatRobot 对应微信版本的 DLL
- 确保微信版本与 DLL 版本匹配(当前支持微信 3.7.0.30)
- 将
CWeChatRobot.exe和 DLL 文件放在项目目录的com/子文件夹中
-
登录微信(PC 版)
-
一键启动所有服务:
start_wechat_bot.bat
-
完成! AI 助手现在会自动回复消息了。
如果需要查看日志,可以分别启动各个组件:
# 1. 启动 OpenClaw Gateway
openclaw gateway
# 2. 启动 HTTP Server(新窗口)
python http_server.py
# 3. 启动 Bridge(新窗口)
python openclaw_bridge.py运行状态检查脚本:
check_status.batstop_wechat_bot.bat- 私聊:直接发送消息,AI 自动回复
- 群聊:默认回复所有消息(可配置触发词)
- 引用消息:支持微信引用/回复格式
编辑 OpenClaw 的 agent 配置,可以是任何角色:
{
"agents": {
"list": [
{
"id": "main",
"identity": {
"name": "Your AI Name",
"theme": "Your AI description",
"emoji": "🤖"
}
}
]
}
}运行以下命令添加到开机启动:
# 复制到 Windows 启动文件夹
copy autostart_wechat_bot.bat "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\"详细说明见 AUTOSTART_SETUP.md
openclaw-wechat-bot/
├── openclaw_bridge.py # 核心桥接器(微信 ↔ OpenClaw)
├── http_server.py # HTTP API 服务器
├── openclaw_adapter.py # OpenClaw 适配器
├── start_wechat_bot.bat # 一键启动脚本
├── check_status.bat # 状态检查脚本
├── stop_wechat_bot.bat # 停止服务脚本
├── autostart_wechat_bot.bat # 开机自动启动脚本
├── requirements.txt # Python 依赖
├── config.example.json # 配置示例
├── README.md # 本文件
├── LICENSE # MIT 许可证
└── docs/
└── AUTOSTART_SETUP.md # 自动启动设置指南
- 检查微信是否在线
- 运行
check_status.bat查看服务状态 - 检查
bridge.log日志文件 - 确认 OpenClaw Gateway 正常运行
如果遇到 "API rate limit reached" 错误:
- 等待几分钟后重试
- 或更换 AI 模型提供商
某些消息类型(如引用消息)可能需要特殊处理,查看 bridge.log 中的原始消息格式。
如果遇到 COM 初始化错误:
- 确保微信已登录
- 以管理员身份运行脚本
- 重启微信和脚本
- ✨ 初始版本发布
- ✨ 支持私聊和群聊自动回复
- ✨ 支持引用消息
- ✨ 添加开机自动启动功能
欢迎提交 Issue 和 Pull Request!
本项目采用 MIT License 许可证。
免责声明:
- 本项目仅供学习和个人使用
- 请勿用于商业用途
- 使用本项目请遵守当地法律法规
- OpenClaw - AI 助手框架
- ComWeChatRobot - 微信 COM 接口
Made with ❤️ by Sea_Star