fix: 修復 Telegram Bot /menu 指令無響應及重複訊息問題
Some checks failed
CD Pipeline / deploy (push) Failing after 55s

- telegram_bot_service: 新增 /menu 指令處理器,映射到 cmd_start
- openclaw_bot_routes: 優化「今日業績資料尚未匯入」訊息邏輯
  - 區分「資料載入異常」vs「確實未匯入」
  - 避免在已有今日資料時仍顯示未匯入訊息

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ogt
2026-04-20 22:48:07 +08:00
parent 8df8b24043
commit b8e6f752fa
2 changed files with 9 additions and 1 deletions

View File

@@ -2851,7 +2851,14 @@ def send_evening_report():
lines.append(f"{emoji} *vs 昨日* {arrow}`{abs(pct_d):.1f}%` (`NT$ {diff:+,.0f}`)")
lines.append("")
else:
lines.append("⚠️ *今日業績資料尚未匯入*")
# 檢查是否真的沒有資料,避免重複顯示
today_str = datetime.now(TAIPEI_TZ).strftime('%Y/%m/%d')
if latest_date() == today_str:
# 如果最新日期就是今天,但查詢失敗,可能是資料庫問題
lines.append("⚠️ *今日業績資料載入異常*")
else:
# 確實沒有今天的資料
lines.append("⚠️ *今日業績資料尚未匯入*")
lines.append("")
top15_ev = query_top_products(td, 15)

View File

@@ -1062,6 +1062,7 @@ class TrendTelegramBot:
# 註冊處理器
self.application.add_handler(CommandHandler("start", self.cmd_start))
self.application.add_handler(CommandHandler("help", self.cmd_help))
self.application.add_handler(CommandHandler("menu", self.cmd_start)) # /menu 指令映射到 cmd_start
self.application.add_handler(CommandHandler("trend", self.cmd_trend))
self.application.add_handler(CommandHandler("search", self.cmd_search))
self.application.add_handler(CommandHandler("copy", self.cmd_copy))