From 9ea1f77e4164e15519c49a7ccd61863bb349c77f Mon Sep 17 00:00:00 2001 From: OG T Date: Thu, 16 Apr 2026 03:29:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(telegram):=20=E7=A7=BB=E9=99=A4=207=20?= =?UTF-8?q?=E5=80=8B=20ghost=20button=20(3-part/=E7=84=A1handler)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 違規 buttons 一覽: - flywheel_diag / flywheel_dashboard (META告警卡) - pause_1h / ignore (業務告警卡) - postmortem / escalation_ack / dr_manual (升級通知卡) - secops_block_ip / secops_evict (SecOps 卡,spec=nonce 但用 2-part) 所有 buttons 均無 callback handler,點擊無回應 = 鬼魂按鈕 鐵律: 寧可沒按鈕,不可有死按鈕 (feedback_no_ghost_buttons.md) Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/services/telegram_gateway.py | 38 +++++++---------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/apps/api/src/services/telegram_gateway.py b/apps/api/src/services/telegram_gateway.py index 4de6fa98..ce3a754e 100644 --- a/apps/api/src/services/telegram_gateway.py +++ b/apps/api/src/services/telegram_gateway.py @@ -1951,13 +1951,11 @@ class TelegramGateway: if probable_cause: text += f"└─ 可能根因:{html.escape(probable_cause[:100])}\n" + # 2026-04-16 ogt: 移除 flywheel_diag / flywheel_dashboard (3-part ghost button,無 handler) + # 鐵律: 寧可沒按鈕,不可有死按鈕 (feedback_no_ghost_buttons.md) silence_nonce = self._security.generate_callback_nonce(approval_id, "silence") keyboard = { "inline_keyboard": [ - [ - {"text": "🔄 觸發診斷", "callback_data": f"action:flywheel_diag:{incident_id}"}, - {"text": "📊 查看面板", "callback_data": f"action:flywheel_dashboard:{incident_id}"}, - ], [ {"text": "🔕 靜默 1h", "callback_data": silence_nonce}, ], @@ -2011,6 +2009,9 @@ class TelegramGateway: if defense_action: text += f"\n🛡️ 建議防禦動作\n{html.escape(defense_action[:200])}\n" + # 2026-04-16 ogt: 移除 secops_block_ip / secops_evict (spec=nonce 但用了 2-part格式,無 handler) + # secops 高危操作需 multi-sig,現階段無多簽機制,暫移除等補齊 + # 鐵律: 寧可沒按鈕,不可有死按鈕 (feedback_no_ghost_buttons.md) isolate_nonce = self._security.generate_callback_nonce(approval_id, "secops_isolate") auth_nonce = self._security.generate_callback_nonce(approval_id, "secops_authorize") @@ -2018,10 +2019,6 @@ class TelegramGateway: "inline_keyboard": [ [ {"text": "🚫 隔離資源", "callback_data": isolate_nonce}, - {"text": "⛔ 封鎖來源 IP", "callback_data": f"secops_block_ip:{incident_id}"}, - ], - [ - {"text": "🔄 強制驅逐 Pod", "callback_data": f"secops_evict:{incident_id}"}, {"text": "✅ 確認授權操作", "callback_data": auth_nonce}, ], ] @@ -2068,14 +2065,9 @@ class TelegramGateway: if loss_rate: text += f"└─ 損失速率:{html.escape(loss_rate)}\n" - keyboard = { - "inline_keyboard": [ - [ - {"text": "⏸️ 暫停 1h", "callback_data": f"action:pause_1h:{incident_id}"}, - {"text": "❌ 忽略", "callback_data": f"action:ignore:{incident_id}"}, - ], - ] - } + # 2026-04-16 ogt: 移除 pause_1h / ignore (3-part ghost button,無 handler) + # 鐵律: 寧可沒按鈕,不可有死按鈕 (feedback_no_ghost_buttons.md) + keyboard = {"inline_keyboard": []} target_chat = group_chat_id or settings.OPENCLAW_TG_CHAT_ID return await self._send_request( @@ -2125,17 +2117,9 @@ class TelegramGateway: if current_impact: text += f"└─ 目前影響:{html.escape(current_impact[:100])}\n" - keyboard = { - "inline_keyboard": [ - [ - {"text": "📄 產生 Postmortem 草稿", "callback_data": f"action:postmortem:{incident_id}"}, - ], - [ - {"text": "✅ 確認已接手處理", "callback_data": f"action:escalation_ack:{incident_id}"}, - {"text": "📖 DR 手冊", "callback_data": f"action:dr_manual:{incident_id}"}, - ], - ] - } + # 2026-04-16 ogt: 移除 postmortem / escalation_ack / dr_manual (3-part ghost button,無 handler) + # 鐵律: 寧可沒按鈕,不可有死按鈕 (feedback_no_ghost_buttons.md) + keyboard = {"inline_keyboard": []} results = [] # 發個人 DM