# iotlcm-bot V1 独立飞书应用机器人:读取 Worker 终态 Run JSON,渲染并发送全量同步结果卡片。 ## V1 范围 - 只接受当前版本 `version=1` 且包含 `run` 和非空 `rounds` 的归档 JSON。 - 不兼容旧版 `rounds=[]` 文件。 - 不读取 Redis、Worker HTTP 接口或日志。 - 不实现 Replay、事件回调、卡片按钮和错误聚合。 - 按 `runId` 去重,避免重复发送。 ## 本地验证 ```bash go test ./... go run ./cmd/iotlcm-bot render --file testdata/current-run.json go run ./cmd/iotlcm-bot render --file testdata/current-run.json --json ``` `render` 只渲染通知内容,不调用飞书 API。 ## 本地单次发送 机器人加入测试群,且 YAML 配置已填写 `feishu.appSecret` 和 `feishu.chatId` 后,可以发送指定 Run: ```bash go run ./cmd/iotlcm-bot send --config /path/to/iotlcm-bot.yaml --file /path/to/run.json ``` 发送成功后会写入 `state/sent/.json`;同一 Run 再次执行会跳过。确需重发时使用: ```bash go run ./cmd/iotlcm-bot send --config /path/to/iotlcm-bot.yaml --file /path/to/run.json --force ``` 正常运行时不要使用 `--force`。 ## 已部署容器的发送测试 只验证飞书连接时,无需提供 Run JSON。Bot 容器运行后,发送一条自定义文本: ```bash docker exec iotlcm-bot /usr/local/bin/iotlcm-bot send-text --config /app/config/config.yaml --text "iotlcm-bot 飞书连接测试" ``` `send-text` 不扫描归档、不写 Run 发送标记,可以重复执行。它直接通过飞书消息 API 向配置文件中的群发送文本,不是 HTTP 测试接口。 需要测试完整的 Run 卡片链路时,才使用下面的单次发送命令: ```bash docker exec iotlcm-bot /usr/local/bin/iotlcm-bot send --config /app/config/config.yaml --file /data/full-sync/run-.json ``` 如该 Run 已发送,明确需要再次发送时加 `--force`: ```bash docker exec iotlcm-bot /usr/local/bin/iotlcm-bot send --config /app/config/config.yaml --file /data/full-sync/run-.json --force ``` 发送成功会写入 `/data/state/sent/.json`。检查容器和日志: ```bash docker ps --filter name=iotlcm-bot docker logs --tail 100 iotlcm-bot ``` ## 配置文件 复制 `config.example.yaml` 为未跟踪的 `config.yaml`,填入实际飞书应用凭据和群 ID。 配置加载器直接读取 YAML,不展开环境变量;请勿把真实凭据提交到仓库。 部署时通过只读挂载将配置注入容器,容器内路径可为 `/app/config/config.yaml`。 ## 自动通知 Compose 默认以 `watch` 模式启动 Bot。Bot 每 10 秒扫描挂载的终态 Run JSON,校验通过且未发送过的 Run 会自动发到配置的飞书群。 本地启动方式: ```bash go run ./cmd/iotlcm-bot watch --config /path/to/iotlcm-bot.yaml ``` ## 目录挂载 ```text Worker 宿主归档目录: Bot 只读挂载目录:/data/full-sync Bot 可写状态目录: -> /data/state ```