fix: show MB/NWS/MGM as comp_parts when Open-Meteo daily data is missing
This commit is contained in:
+28
-20
@@ -445,26 +445,33 @@ 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:
|
||||||
sources.append("MB")
|
if "MB" not in sources:
|
||||||
comp_parts.append(
|
sources.append("MB")
|
||||||
f"MB: {mb_high:.1f}{temp_symbol}"
|
# 只在非 fallback(即 Open-Meteo 存在)时显示为对比,否则作为 today_t 已显示
|
||||||
if isinstance(mb_high, (int, float))
|
if fallback_source != "MB":
|
||||||
else f"MB: {mb_high}"
|
comp_parts.append(
|
||||||
)
|
f"MB: {mb_high:.1f}{temp_symbol}"
|
||||||
|
if isinstance(mb_high, (int, float))
|
||||||
|
else f"MB: {mb_high}"
|
||||||
|
)
|
||||||
if nws_high is not None:
|
if nws_high is not None:
|
||||||
sources.append("NWS")
|
if "NWS" not in sources:
|
||||||
comp_parts.append(
|
sources.append("NWS")
|
||||||
f"NWS: {nws_high:.1f}{temp_symbol}"
|
if fallback_source != "NWS":
|
||||||
if isinstance(nws_high, (int, float))
|
comp_parts.append(
|
||||||
else f"NWS: {nws_high}"
|
f"NWS: {nws_high:.1f}{temp_symbol}"
|
||||||
)
|
if isinstance(nws_high, (int, float))
|
||||||
|
else f"NWS: {nws_high}"
|
||||||
|
)
|
||||||
if mgm_high is not None:
|
if mgm_high is not None:
|
||||||
sources.append("MGM")
|
if "MGM" not in sources:
|
||||||
comp_parts.append(
|
sources.append("MGM")
|
||||||
f"🇺🇸 MGM: {mgm_high:.1f}{temp_symbol}"
|
if fallback_source != "MGM":
|
||||||
if isinstance(mgm_high, (int, float))
|
comp_parts.append(
|
||||||
else f"🇺🇸 MGM: {mgm_high}"
|
f"MGM: {mgm_high:.1f}{temp_symbol}"
|
||||||
)
|
if isinstance(mgm_high, (int, float))
|
||||||
|
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)
|
||||||
if not sources:
|
if not sources:
|
||||||
@@ -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 = (
|
||||||
|
|||||||
Reference in New Issue
Block a user