From 4009a2643177be5effc0a2f936413814d3da6388 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 14 Jun 2026 03:58:40 +0800 Subject: [PATCH] Avoid Telegram forum fallback to general --- src/utils/telegram_push.py | 15 ++------------- tests/test_telegram_hashtags.py | 9 +++------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/utils/telegram_push.py b/src/utils/telegram_push.py index 7a6b090a..835cad5f 100644 --- a/src/utils/telegram_push.py +++ b/src/utils/telegram_push.py @@ -1768,23 +1768,12 @@ def _process_airport_city( except Exception as exc: if thread_id and "message thread not found" in str(exc).lower(): logger.warning( - "airport push thread missing; retrying main chat city={} chat_id={} thread_id={}", + "airport push skipped missing forum thread city={} chat_id={} thread_id={}", city, chat_id, thread_id, ) - try: - _rate_limited_send(bot, chat_id, message) - sent = True - continue - except Exception as fallback_exc: - logger.warning( - "airport push main chat fallback failed city={} chat_id={}: {}", - city, - chat_id, - fallback_exc, - ) - continue + continue logger.warning("airport push failed city={} chat_id={}: {}", city, chat_id, exc) if sent: diff --git a/tests/test_telegram_hashtags.py b/tests/test_telegram_hashtags.py index 0b3a70e2..d1a6e7c1 100644 --- a/tests/test_telegram_hashtags.py +++ b/tests/test_telegram_hashtags.py @@ -403,7 +403,7 @@ def test_airport_push_rejects_observation_older_than_last_push(monkeypatch): assert result is None -def test_airport_push_retries_main_chat_when_forum_thread_is_missing(monkeypatch): +def test_airport_push_does_not_retry_general_when_forum_thread_is_missing(monkeypatch): import src.utils.telegram_push as telegram_push calls = [] @@ -438,11 +438,8 @@ def test_airport_push_retries_main_chat_when_forum_thread_is_missing(monkeypatch bot=object(), ) - assert result is not None - assert calls == [ - ("chat-1", {"message_thread_id": 99}), - ("chat-1", {}), - ] + assert result is None + assert calls == [("chat-1", {"message_thread_id": 99})] def test_airport_push_does_not_fall_back_to_general_when_forum_mapping_is_missing(monkeypatch):