feat(telegram): 實作 6 種新訊息模板 (ADR-038)

2026-03-29 ogt: Telegram 訊息模板完整實作

新增訊息類型:
- SentryErrorMessage: Sentry 錯誤通知 (含 Stack Trace)
- ResourceWarnMessage: 資源耗盡警告 (含 CPU/Memory/Disk)
- RepairReportMessage: 自動修復每日報告
- DailySummaryMessage: 每日系統狀態摘要
- DeploySuccessMessage: CD 部署成功通知
- RateLimitMessage: API 限額警告

新增發送方法:
- send_sentry_error()
- send_resource_warning()
- send_repair_report()
- send_daily_summary()
- send_deploy_success()
- send_rate_limit_warning()

新增按鈕:
- Sentry: [🔍 查看詳情] [🔕 靜默 1h]
- Resource: [ 自動擴展] [🔕 靜默 1h]

測試: 14 測試案例全部通過

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-29 21:23:07 +08:00
parent 6416f56748
commit 4707102498
3 changed files with 1070 additions and 23 deletions

View File

@@ -17,12 +17,12 @@
| 4 | Execution Result | `EXEC_RESULT` | 0 顆 | ✅ 已實作 |
| 5 | Heartbeat | `HEARTBEAT` | 0 顆 | ✅ 已實作 |
| 6 | Silence Alert | `SILENCE` | 0 顆 | ✅ 已實作 |
| 7 | Sentry Error | `SENTRY_ERROR` | 2 顆 | 🆕 待實作 |
| 8 | Resource Exhaustion | `RESOURCE_WARN` | 2 顆 | 🆕 待實作 |
| 9 | Auto-Repair Report | `REPAIR_REPORT` | 0 顆 | 🆕 待實作 |
| 10 | Daily Summary | `DAILY_SUMMARY` | 0 顆 | 🆕 待實作 |
| 11 | Deployment Success | `DEPLOY_SUCCESS` | 0 顆 | 🆕 待實作 |
| 12 | Rate Limit Warning | `RATE_LIMIT` | 0 顆 | 🆕 待實作 |
| 7 | Sentry Error | `SENTRY_ERROR` | 2 顆 | ✅ 已實作 |
| 8 | Resource Exhaustion | `RESOURCE_WARN` | 2 顆 | ✅ 已實作 |
| 9 | Auto-Repair Report | `REPAIR_REPORT` | 0 顆 | ✅ 已實作 |
| 10 | Daily Summary | `DAILY_SUMMARY` | 0 顆 | ✅ 已實作 |
| 11 | Deployment Success | `DEPLOY_SUCCESS` | 0 顆 | ✅ 已實作 |
| 12 | Rate Limit Warning | `RATE_LIMIT` | 0 顆 | ✅ 已實作 |
---
@@ -216,11 +216,12 @@ Telegram 已 **2 小時**沒有收到任何訊息!
---
## 🆕 待實作訊息模板
## ✅ 已實作訊息模板 (2026-03-29 新增)
### 7⃣ Sentry Error (SENTRY_ERROR)
**優先級**: P1
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `SentryErrorMessage`
**按鈕配置**:
```
@@ -256,7 +257,8 @@ Telegram 已 **2 小時**沒有收到任何訊息!
### 8⃣ Resource Exhaustion (RESOURCE_WARN)
**優先級**: P1
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `ResourceWarnMessage`
**按鈕配置**:
```
@@ -287,7 +289,8 @@ Telegram 已 **2 小時**沒有收到任何訊息!
### 9⃣ Auto-Repair Report (REPAIR_REPORT)
**優先級**: P2
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `RepairReportMessage`
**按鈕**: 無
@@ -320,7 +323,8 @@ Telegram 已 **2 小時**沒有收到任何訊息!
### 🔟 Daily Summary (DAILY_SUMMARY)
**優先級**: P2
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `DailySummaryMessage`
**按鈕**: 無
@@ -359,7 +363,8 @@ Telegram 已 **2 小時**沒有收到任何訊息!
### 1⃣1⃣ Deployment Success (DEPLOY_SUCCESS)
**優先級**: P3
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `DeploySuccessMessage`
**按鈕**: 無
@@ -388,7 +393,8 @@ Telegram 已 **2 小時**沒有收到任何訊息!
### 1⃣2⃣ Rate Limit Warning (RATE_LIMIT)
**優先級**: P1
**狀態**: **已實作** (2026-03-29)
**檔案**: `telegram_gateway.py` - `RateLimitMessage`
**按鈕**: 無
@@ -454,17 +460,18 @@ Telegram 已 **2 小時**沒有收到任何訊息!
---
## 實作優先級
## 實作狀態
| 優先級 | 訊息類別 | 預估工時 |
|--------|----------|----------|
| 🔴 P1 | SENTRY_ERROR | 2h |
| 🔴 P1 | RESOURCE_WARN | 2h |
| 🔴 P1 | RATE_LIMIT | 1h |
| 🟠 P2 | REPAIR_REPORT | 2h |
| 🟠 P2 | DAILY_SUMMARY | 3h |
| 🟡 P3 | DEPLOY_SUCCESS | 1h |
| **總計** | | **11h** |
| 訊息類別 | 狀態 | 實作日期 |
|----------|------|----------|
| SENTRY_ERROR | ✅ 已實作 | 2026-03-29 |
| RESOURCE_WARN | ✅ 已實作 | 2026-03-29 |
| RATE_LIMIT | ✅ 已實作 | 2026-03-29 |
| REPAIR_REPORT | ✅ 已實作 | 2026-03-29 |
| DAILY_SUMMARY | ✅ 已實作 | 2026-03-29 |
| DEPLOY_SUCCESS | ✅ 已實作 | 2026-03-29 |
**全部 12 種訊息模板已實作完成!**
---
@@ -472,4 +479,5 @@ Telegram 已 **2 小時**沒有收到任何訊息!
| 日期 | 版本 | 內容 |
|------|------|------|
| 2026-03-29 | v1.1 | ✅ 6 種新訊息模板實作完成 (Sentry/Resource/Repair/Daily/Deploy/RateLimit) |
| 2026-03-29 | v1.0 | 初始建立,定義 12 種訊息模板 |