From b8e6f752fa10587b35ad7844a2a34c7915261e67 Mon Sep 17 00:00:00 2001 From: ogt Date: Mon, 20 Apr 2026 22:48:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=20Telegram=20Bot=20/m?= =?UTF-8?q?enu=20=E6=8C=87=E4=BB=A4=E7=84=A1=E9=9F=BF=E6=87=89=E5=8F=8A?= =?UTF-8?q?=E9=87=8D=E8=A4=87=E8=A8=8A=E6=81=AF=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - telegram_bot_service: 新增 /menu 指令處理器,映射到 cmd_start - openclaw_bot_routes: 優化「今日業績資料尚未匯入」訊息邏輯 - 區分「資料載入異常」vs「確實未匯入」 - 避免在已有今日資料時仍顯示未匯入訊息 Co-Authored-By: Claude Sonnet 4.6 --- routes/openclaw_bot_routes.py | 9 ++++++++- services/telegram_bot_service.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/routes/openclaw_bot_routes.py b/routes/openclaw_bot_routes.py index 6993821..9eac0e3 100644 --- a/routes/openclaw_bot_routes.py +++ b/routes/openclaw_bot_routes.py @@ -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) diff --git a/services/telegram_bot_service.py b/services/telegram_bot_service.py index 6f8fe15..00be136 100644 --- a/services/telegram_bot_service.py +++ b/services/telegram_bot_service.py @@ -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))