feat(telegram): implement reanalyze button handler, replace placeholder (ADR-050)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1821,9 +1821,13 @@ class TelegramGateway:
|
||||
# 2026-04-01 Claude Code (ADR-050 P2)
|
||||
await self._answer_callback(callback_query_id, action, text="📊 歷史統計傳送中...")
|
||||
await self._send_incident_history(incident_id)
|
||||
elif action == "reanalyze":
|
||||
# ADR-050 P2: 觸發重診
|
||||
# 2026-04-01 Claude Code (ADR-050 P2): reanalyze button handler
|
||||
await self._answer_callback(callback_query_id, action, text="🔄 重診排程中...")
|
||||
await self._send_reanalyze_result(incident_id)
|
||||
else:
|
||||
# reanalyze: 開發中
|
||||
await self._answer_callback(callback_query_id, action, text="🔄 功能開發中")
|
||||
await self._answer_callback(callback_query_id, action, text="⚠️ 未知操作")
|
||||
|
||||
return {
|
||||
"action": action,
|
||||
@@ -2345,6 +2349,49 @@ class TelegramGateway:
|
||||
logger.warning("send_incident_history_failed", incident_id=incident_id, error=str(e))
|
||||
await self.send_notification(f"⚠️ 無法取得歷史統計: {html.escape(str(e)[:100])}")
|
||||
|
||||
async def _send_reanalyze_result(self, incident_id: str) -> None:
|
||||
"""
|
||||
ADR-050 P2: 觸發重診並傳送結果訊息
|
||||
|
||||
呼叫 IncidentService.trigger_reanalysis(),以新訊息回報排程結果。
|
||||
不修改原始簽核卡片,避免干擾授權流程。
|
||||
|
||||
2026-04-01 Claude Code (ADR-050 P2): reanalyze button handler
|
||||
"""
|
||||
from src.services.incident_service import get_incident_service
|
||||
|
||||
try:
|
||||
service = get_incident_service()
|
||||
result = await service.trigger_reanalysis(incident_id)
|
||||
|
||||
if result["already_analyzing"]:
|
||||
msg = (
|
||||
f"⏳ <b>重診進行中</b>\n\n"
|
||||
f"🔖 <code>{html.escape(incident_id)}</code>\n\n"
|
||||
f"{html.escape(result['message'])}"
|
||||
)
|
||||
elif result["triggered"]:
|
||||
msg = (
|
||||
f"🔄 <b>重診已排程</b>\n\n"
|
||||
f"🔖 <code>{html.escape(incident_id)}</code>\n\n"
|
||||
f"✅ {html.escape(result['message'])}\n"
|
||||
f"AI 分析結果將自動更新事件狀態。"
|
||||
)
|
||||
else:
|
||||
msg = (
|
||||
f"⚠️ <b>重診失敗</b>\n\n"
|
||||
f"🔖 <code>{html.escape(incident_id)}</code>\n\n"
|
||||
f"{html.escape(result['message'])}"
|
||||
)
|
||||
|
||||
await self.send_notification(msg)
|
||||
|
||||
except Exception as e:
|
||||
logger.warning("send_reanalyze_result_failed", incident_id=incident_id, error=str(e))
|
||||
await self.send_notification(
|
||||
f"⚠️ 重診觸發失敗: {html.escape(str(e)[:100])}"
|
||||
)
|
||||
|
||||
async def send_notification(
|
||||
self,
|
||||
text: str,
|
||||
|
||||
Reference in New Issue
Block a user