fix(telegram): add dedicated handler for forum topic service messages#5488
Open
willy-scr wants to merge 3 commits into
Open
fix(telegram): add dedicated handler for forum topic service messages#5488willy-scr wants to merge 3 commits into
willy-scr wants to merge 3 commits into
Conversation
ad86dde to
a158c04
Compare
Forum topic lifecycle events (created/edited/closed/reopened) are
delivered as service messages that carry neither text nor media. The
existing handler registration only covered TEXT, COMMAND, LOCATION and
MEDIA filters, so forum_topic_created updates were silently dropped
and the auto-discovery logic in _build_message_event was unreachable.
Add a new MessageHandler filtered on
filters.StatusUpdate.FORUM_TOPIC_{CREATED,EDITED,CLOSED,REOPENED}
that directly calls _persist_group_topic / _persist_group_topic_edit,
ensuring new topics are registered in config.yaml immediately when
created by any admin (not just the bot itself).
Also includes group forum topic infrastructure:
- _group_topics_config init from extra.group_topics
- _persist_group_topic: auto-register new topics to config.yaml
- _persist_group_topic_edit: handle rename/close/reopen
- _get_group_topic_info: resolve topic name/skill/role
- _reload_group_topics_from_config: hot-reload without restart
- _build_message_event: resolve group topic context for messages
… error When Telegram returns 'thread not found' BadRequest, the topic has been deleted. Call _remove_group_topic to clean up the stale entry from config.yaml so future messages don't repeatedly hit the same error. Zero performance impact — piggybacks on existing error handling.
a158c04 to
9690bdb
Compare
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Forum topic lifecycle events (
forum_topic_created,forum_topic_edited,forum_topic_closed,forum_topic_reopened) were never processed by the gateway because they are delivered as service messages — they carry neither text nor media content. The existing handler registration only coveredTEXT,COMMAND,LOCATION, andMEDIAfilters, so these events were silently dropped.The auto-discovery logic added in
_build_message_event(checkingmessage.forum_topic_created) was unreachable because no handler filtered for service message types.Root Cause
forum_topic_createdmessages have no.text, no media — they only have the.forum_topic_createdattribute. None of the registered filters match, so the update is discarded.Fix
Add a dedicated
MessageHandlerfiltered onfilters.StatusUpdate.FORUM_TOPIC_CREATED | FORUM_TOPIC_EDITED | FORUM_TOPIC_CLOSED | FORUM_TOPIC_REOPENEDthat directly calls_persist_group_topic/_persist_group_topic_edit.This ensures:
config.yamlimmediately when created by any admin (not just the bot)Changes
_handle_forum_topic_eventhandler withfilters.StatusUpdate.FORUM_TOPIC_*filters_persist_group_topic/_persist_group_topic_editmethods_group_topics_configinit_persist_group_topic,_persist_group_topic_edit_get_group_topic_info,_reload_group_topics_from_config_build_message_eventTesting
Confirmed on live Telegram group:
forum_topic_createdevent received (Telegram behavior — no echo to self)_build_message_event(verified in gateway logs)