fix: show MB/NWS/MGM as comp_parts when Open-Meteo daily data is missing

This commit is contained in:
2569718930@qq.com
2026-03-11 03:44:10 +08:00
parent ffb88ae61d
commit d4760dbcb2
+12 -4
View File
@@ -445,25 +445,32 @@ def start_bot():
sources = ["Open-Meteo"] if max_temps else [] sources = ["Open-Meteo"] if max_temps else []
if mb_high is not None: if mb_high is not None:
if "MB" not in sources:
sources.append("MB") sources.append("MB")
# 只在非 fallback(即 Open-Meteo 存在)时显示为对比,否则作为 today_t 已显示
if fallback_source != "MB":
comp_parts.append( comp_parts.append(
f"MB: {mb_high:.1f}{temp_symbol}" f"MB: {mb_high:.1f}{temp_symbol}"
if isinstance(mb_high, (int, float)) if isinstance(mb_high, (int, float))
else f"MB: {mb_high}" else f"MB: {mb_high}"
) )
if nws_high is not None: if nws_high is not None:
if "NWS" not in sources:
sources.append("NWS") sources.append("NWS")
if fallback_source != "NWS":
comp_parts.append( comp_parts.append(
f"NWS: {nws_high:.1f}{temp_symbol}" f"NWS: {nws_high:.1f}{temp_symbol}"
if isinstance(nws_high, (int, float)) if isinstance(nws_high, (int, float))
else f"NWS: {nws_high}" else f"NWS: {nws_high}"
) )
if mgm_high is not None: if mgm_high is not None:
if "MGM" not in sources:
sources.append("MGM") sources.append("MGM")
if fallback_source != "MGM":
comp_parts.append( comp_parts.append(
f"🇺🇸 MGM: {mgm_high:.1f}{temp_symbol}" f"MGM: {mgm_high:.1f}{temp_symbol}"
if isinstance(mgm_high, (int, float)) if isinstance(mgm_high, (int, float))
else f"🇺🇸 MGM: {mgm_high}" else f"MGM: {mgm_high}"
) )
if fallback_source and fallback_source not in sources: if fallback_source and fallback_source not in sources:
sources.append(fallback_source) sources.append(fallback_source)
@@ -472,8 +479,9 @@ def start_bot():
# 检查是否有显著分歧 (超过 5°F 或 2.5°C) # 检查是否有显著分歧 (超过 5°F 或 2.5°C)
divergence_warning = "" divergence_warning = ""
if mb_high is not None and max_temps: base_for_divergence = _sf(max_temps[0]) if max_temps else today_t
diff = abs(mb_high - (_sf(max_temps[0]) or 0)) if mb_high is not None and base_for_divergence is not None:
diff = abs(mb_high - base_for_divergence)
threshold = 5.0 if temp_unit == "fahrenheit" else 2.5 threshold = 5.0 if temp_unit == "fahrenheit" else 2.5
if diff > threshold: if diff > threshold:
divergence_warning = ( divergence_warning = (