Files
Nexus/docs/design/specs/2026-06-13-offline-alert-telegram-split-design.md
T
Nexus Agent 821cf12ade fix(terminal,alerts): quick-cmd enter on send and offline Telegram channel
Append CR when executing quick commands (fixes trim stripping saved \r) and
allow optional dedicated Telegram bot for server offline alerts only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 01:45:55 +08:00

42 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 子机离线告警独立 Telegram 通道 — 设计
**日期**: 2026-06-13
**状态**: 已实现
## 背景与目标
运维希望将「子机离线」告警与 CPU/内存等资源告警分流:离线通知可发到专用群/专用 Bot,避免主告警群被大量离线消息淹没。
## 方案对比
| 方案 | 优点 | 缺点 |
|------|------|------|
| A. 新建独立 settings 键 + 发送时路由 | 改动小;与现有 Telegram 配置一致 | 需多配一组 Token/Chat |
| B. 按服务器标签/项目路由 | 更细粒度 | 复杂度高,当前无项目维度 |
| C. 多 Bot 列表 + 规则引擎 | 可扩展 | 过度设计 |
**选定 A**`telegram_offline_bot_token` + `telegram_offline_chat_id`;二者均配置时离线告警走专用通道,否则回退默认 Bot。
## 数据与接口
| settings 键 | Settings 属性 | 说明 |
|-------------|---------------|------|
| `telegram_offline_bot_token` | `TELEGRAM_OFFLINE_BOT_TOKEN` | 敏感,GET 掩码 |
| `telegram_offline_chat_id` | `TELEGRAM_OFFLINE_CHAT_ID` | 明文 |
- `send_telegram_offline_alert``resolve_offline_telegram_credentials()``send_telegram(..., bot_token, chat_id)`
- API`PUT /settings/{key}``POST /settings/telegram/offline/test``GET /settings/telegram/offline/chats``POST /settings/telegram/offline/reveal-token`
- Layer 3 巡检仍仅用默认 `telegram_bot_token`(不同步离线 Bot
## 安全
- Token 入 `SENSITIVE_KEYS`reveal 写审计
- 不改变 `notify_alert_offline` 开关语义
## 验收
1. 配置离线专用 Bot+Chat 后,子机离线 Telegram 发到专用群
2. 未配置离线专用时,离线告警仍走默认 Bot
3. CPU/内存等资源告警始终走默认 Bot
4. 设置页可保存、检测 Chat ID、发送测试消息