From 86467d4e92b573e585343406e79d222370fd0cd9 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 13 May 2026 15:29:28 +0800 Subject: [PATCH] =?UTF-8?q?HK/LFS=20=E6=95=B0=E6=8D=AE=E5=BB=B6=E8=BF=9F?= =?UTF-8?q?=E9=87=8D=E8=AF=95=EF=BC=9Aobs=5Ftime=20=E6=9C=AA=E5=8F=98?= =?UTF-8?q?=E4=B8=94=E8=B7=9D=E4=B8=8A=E6=AC=A1=E6=8E=A8=E9=80=81=E8=B6=85?= =?UTF-8?q?=209min=20=E6=97=B6=E7=AD=89=204s=20=E9=87=8D=E6=8B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HKO API 在 x7 分发布数据但有 3-5s 延迟,推送检查可能刚好在 API 更新前拿到旧数据被去重跳过。现在检测到数据过期时等待重拉。 Constraint: 仅影响 hong kong / lau fau shan,其他城市无额外延迟 --- src/utils/telegram_push.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/utils/telegram_push.py b/src/utils/telegram_push.py index 8b8b62da..bcc5c519 100644 --- a/src/utils/telegram_push.py +++ b/src/utils/telegram_push.py @@ -968,7 +968,38 @@ def _run_high_freq_airport_cycle( continue # 基于原始观测数据时间的去重:同一条观测不重复推送 - if current_obs_time and last_obs_time and current_obs_time == last_obs_time: + # HK/LFS 数据在 x7 分发布,API 可能有 3-5s 延迟, + # obs_time 未变但距上次推送已超 9min → 等 4s 重拉一次 + _CITIES_WITH_DELAYED_API = {"hong kong", "lau fau shan"} + if (current_obs_time and last_obs_time and current_obs_time == last_obs_time + and city in _CITIES_WITH_DELAYED_API + and now_ts - last_city_ts > 540): + time.sleep(4) + try: + city_weather = _analyze(city) + deb_raw2 = (city_weather.get("deb") or {}).get("prediction") + if deb_raw2 is not None: + deb_pred = float(deb_raw2) + mgm_nearby2 = city_weather.get("mgm_nearby") or [] + row2 = None + for r in mgm_nearby2: + if str(r.get("istNo") or "") == airport_icao or str(r.get("icao") or "") == airport_icao: + row2 = r + break + if not row2 and mgm_nearby2: + row2 = mgm_nearby2[0] + retry_obs = str(row2.get("obs_time") or "") if row2 else "" + if retry_obs and retry_obs != last_obs_time: + current_obs_time = retry_obs + station_temp = row2.get("temp") if row2 else None + current_temp = station_temp or (city_weather.get("current") or {}).get("temp") + if current_temp is None or deb_pred is None: + continue + else: + continue + except Exception: + continue + elif current_obs_time and last_obs_time and current_obs_time == last_obs_time: continue # ── Three-condition heat window ──