fix(gateway): route forum supergroup General topic messages by including 'supergroup' chat type (#13607)

Forum supergroups always have chat.type == SUPERGROUP in the Telegram API,
but the General topic fallback in _build_message_event() only checked for
chat_type == "group". While the current mapping happens to map SUPERGROUP
to "group", this is fragile — other methods (e.g. _is_group_chat) already
distinguish the two types, and any refactor to the mapping would silently
break General topic routing.

Extend the check to accept both "group" and "supergroup", and add a debug
log when the fallback fires to aid future diagnosis.
This commit is contained in:
Tranquil-Flow 2026-04-25 08:49:47 +10:00
parent 00c3d848d8
commit 027e054a17
2 changed files with 85 additions and 1 deletions

View file

@ -2989,8 +2989,12 @@ class TelegramAdapter(BasePlatformAdapter):
# Resolve DM topic name and skill binding
thread_id_raw = message.message_thread_id
thread_id_str = str(thread_id_raw) if thread_id_raw is not None else None
if chat_type == "group" and thread_id_str is None and getattr(chat, "is_forum", False):
if chat_type in ("group", "supergroup") and thread_id_str is None and getattr(chat, "is_forum", False):
thread_id_str = self._GENERAL_TOPIC_THREAD_ID
logger.debug(
"Forum %s message without thread_id — routing to General topic (thread=%s)",
chat_type, thread_id_str,
)
chat_topic = None
topic_skill = None