821cf12ade
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>
1.4 KiB
1.4 KiB
2026-06-13 子机离线告警独立 Telegram 通道
摘要
设置页「告警通知项目」下新增可选的离线专用 Bot:子机离线告警可发往另一 Telegram 机器人/群组,其它告警仍走默认 Bot。
动机
离线告警量大或受众不同,需与 CPU/内存等资源告警分流,避免主告警群被淹没。
变更
- 新 settings:
telegram_offline_bot_token、telegram_offline_chat_id(二者均配置时离线告警专用;否则回退默认 Bot)。 resolve_offline_telegram_credentials()+send_telegram_offline_alert路由。- API:
POST /settings/telegram/offline/test、GET /settings/telegram/offline/chats、POST /settings/telegram/offline/reveal-token。 - 设置页:「子机离线告警专用 Bot(可选)」配置区。
涉及文件
server/config.pyserver/infrastructure/telegram/__init__.pyserver/api/settings.pyfrontend/src/pages/SettingsPage.vuefrontend/src/types/api.tstests/test_telegram_offline_channel.py
迁移 / 重启
- 后端:拉取后
supervisorctl restart nexus(新 API 端点)。 - 前端:重新
vite build部署web/app/。 - 无 DB 迁移;首次保存写入
settings表。
验证
- 设置页配置离线专用 Token + Chat ID →「测试离线通道」收到消息。
- 仅配置默认 Bot、不填离线专用 → 子机离线仍走默认群。
pytest tests/test_telegram_offline_channel.py通过。