From bbcb799c6cc90f0a6fac4771b8f942b27482e5e2 Mon Sep 17 00:00:00 2001
From: "2569718930@qq.com" <2569718930@qq.com>
Date: Mon, 23 Feb 2026 21:11:16 +0800
Subject: [PATCH] feat: Initialize bot with API key and add robust error
handling for weather commands.
---
bot_listener.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/bot_listener.py b/bot_listener.py
index 79dd633c..060e7afd 100644
--- a/bot_listener.py
+++ b/bot_listener.py
@@ -256,10 +256,12 @@ def analyze_weather_trend(weather_data, temp_symbol):
# 正在峰值窗口内
if is_breakthrough:
insights.append(f"🔥 极端升温:正处于最热时段,温度已经超过所有预报,还在继续往上走!")
- elif max_so_far is not None and forecast_high - max_so_far <= 0.8:
- insights.append(f"⚖️ 到顶了:正处于最热时段,温度基本到位,接下来会在这个水平上下浮动。")
+ elif max_so_far is not None and (om_today or forecast_high) - max_so_far <= 0.8:
+ insights.append(f"⚖️ 到顶了:正处于最热时段,温度基本到位(实测 {max_so_far}{temp_symbol} ≈ 预报 {om_today}{temp_symbol}),接下来会在这个水平上下浮动。")
else:
- insights.append(f"⏳ 最热时段进行中:虽然在最热时段了,但离预报最高温还差一些,继续观察。")
+ ref = om_today or forecast_high
+ gap = ref - (max_so_far if max_so_far is not None else curr_temp)
+ insights.append(f"⏳ 最热时段进行中:虽然在最热时段了,但离预报 {ref}{temp_symbol} 还差 {gap:.1f}°,继续观察。")
elif local_hour < first_peak_h:
# 还没到峰值窗口
gap_to_high = forecast_high - (max_so_far if max_so_far is not None else curr_temp)