1.8 KiB
1.8 KiB
WeChat-Nanobot Bridge 快速开始
1. 安装依赖(Python)
cd /home/ubuntu/nanocode/weixin-nanobot-bridge
# 安装 Python 依赖
pip3 install flask flask-cors requests python-dotenv pydantic
2. 安装依赖(Node.js - 可选)
# 如果需要连接微信,安装 Node.js 依赖
npm install axios
# 安装 weixin-agent-sdk(需要从 npm 或源码安装)
# npm install weixin-agent-sdk
3. 启动 Bridge 服务
# 快速启动
python3 src/server.py
# 或使用脚本
./scripts/start.sh
服务将在 http://localhost:5000 启动。
4. 测试
# 在另一个终端测试
./scripts/test.sh
# 或使用 curl
curl http://localhost:5000/health
curl -X POST http://localhost:5000/chat \
-H "Content-Type: application/json" \
-d '{"conversationId": "test", "text": "你好"}'
5. 模拟运行(不连接微信)
node nanobot-adapter.js --simulate
6. 连接微信(需要 weixin-agent-sdk)
# 1. 确保 bridge 已启动
# 2. 启动适配器
export NANOBOT_BRIDGE_URL=http://localhost:5000/chat
node nanobot-adapter.js --weixin
# 3. 扫码登录微信
常见问题
Flask 未安装
pip3 install flask flask-cors
端口被占用
# 查看占用
lsof -i :5000
# 修改端口
# 编辑 config/config.json,修改 server.port
测试失败
# 查看日志
tail -f logs/server.log
项目状态
| 组件 | 状态 |
|---|---|
| HTTP API | ✅ 可用 |
| 会话管理 | ✅ 可用 |
| 安全控制 | ✅ 可用 |
| 模拟适配器 | ✅ 可用 |
| 微信连接 | ⚠️ 需 weixin-agent-sdk |
下一步
- 测试基础 API 是否正常
- 配置 nanobot 路径(如果不在 PATH)
- 尝试模拟运行
- 用小号测试微信连接