From 4d584f482857da218efaab14a98652eeb5a35bec Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 12 May 2026 20:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=A2=91=E7=8E=87=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=8C=89=E6=95=B0=E6=8D=AE=E6=BA=90=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E9=80=9F=E7=8E=87=EF=BC=9AAMOS=201=E5=88=86=E9=92=9F=EF=BC=8C?= =?UTF-8?q?=E5=85=B6=E4=BD=99=2010=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不再统一 2 分钟,各城市按实际数据刷新周期独立推送: 首尔/釜山 60s,东京/安卡拉/赫尔辛基/阿姆斯特丹 600s。 循环轮询间隔降至 60s 以匹配最快频率。 Constraint: 循环每 60s 跑一轮,但 interval 判断让各城市按自有节奏推送 Tested: pytest 176 passed, ruff check 通过 --- src/bot/runtime_coordinator.py | 2 +- src/utils/telegram_push.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bot/runtime_coordinator.py b/src/bot/runtime_coordinator.py index e7840b21..1cea6ad4 100644 --- a/src/bot/runtime_coordinator.py +++ b/src/bot/runtime_coordinator.py @@ -186,7 +186,7 @@ class StartupCoordinator: def _start_airport_high_freq_loop(self) -> LoopStatus: enabled = _env_bool("TELEGRAM_AIRPORT_PUSH_ENABLED", True) chat_ids = get_telegram_chat_ids_from_env() - interval = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 120)) + interval = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 60)) details = { "mode": "airport-periodic", "interval_sec": interval, diff --git a/src/utils/telegram_push.py b/src/utils/telegram_push.py index 38347b17..0e723b0a 100644 --- a/src/utils/telegram_push.py +++ b/src/utils/telegram_push.py @@ -752,7 +752,15 @@ def _build_airport_status_message( return "\n".join(lines) -_AIRPORT_PUSH_INTERVAL_SEC = 120 +# Per-city push interval matching native data refresh rate (seconds) +_AIRPORT_PUSH_INTERVAL = { + "seoul": 60, # AMOS 1-min + "busan": 60, # AMOS 1-min + "tokyo": 600, # JMA 10-min + "ankara": 600, # MGM ~10-min + "helsinki": 600, # FMI 10-min + "amsterdam": 600, # KNMI 10-min +} _DEB_PROXIMITY_THRESHOLD_C = 3.0 @@ -770,7 +778,8 @@ def _run_high_freq_airport_cycle( try: last_city = last_by_city.get(city) or {} last_city_ts = int(last_city.get("ts") or 0) - if now_ts - last_city_ts < _AIRPORT_PUSH_INTERVAL_SEC: + city_interval = _AIRPORT_PUSH_INTERVAL.get(city, 600) + if now_ts - last_city_ts < city_interval: continue city_weather: Dict[str, Any] = {} @@ -851,7 +860,7 @@ def start_high_freq_airport_push_loop(bot: Any, config: Dict[str, Any]) -> Optio logger.warning("airport high-freq push loop skipped: TELEGRAM_CHAT_IDS is not set") return None - interval_sec = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", _AIRPORT_PUSH_INTERVAL_SEC)) + interval_sec = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 60)) def _runner() -> None: state = _load_airport_state()