feat: add telegram topics support#142
Open
jiz4oh wants to merge 70 commits intoehForwarderBot:masterfrom
Open
Conversation
Adds support for Telegram topics by: - Adding topic association database model to track topic linkages - Implementing thread_id handling in message processing - Adding topic group configuration option - Enhancing message editing and reply handling for topics - Improving error handling and logging for topic operations This change allows mapping slave chats to Telegram topics within a designated forum group, enabling better organization of multi-chat conversations.
- Add null check when looking up topic associations to prevent errors - Fix thread_id initialization order in master message processing - Fix topic creation to use proper author name field
Add message_thread_id parameter to all send_chat_action calls to properly show typing indicators and upload status in topic threads. Modify bot_manager to handle thread_id parameter by converting it to the proper api_kwargs format.
When replying in topic threads, only quote the message if it's not the topic starter message (where message_id equals message_thread_id). This prevents unnecessary quoting of topic headers in thread conversations.
Change message_thread_id check in send_chat_action to explicitly compare with None instead of truthy check, fixing cases where thread ID could be 0 or other falsy values.
- Add reopen_forum_topic method to handle closed topics - Fix topic association lookup to use latest thread ID - Add topic association cleanup before creating new topics - Handle BadRequest errors in topic operations - Fix message_thread_id handling in chat actions
Remove topic association from database when linking chats to prevent orphaned topic entries. Add error handling around the cleanup to ensure linking process continues even if topic removal fails.
Add additional validation for topic messages and proper debug logging when messages are ignored. This helps troubleshoot issues with topics that aren't created by the bot or messages from invalid topic groups.
Updates the forum topic creation to use chat.chat_title instead of chat.name
Prevents the channel from attempting to process topic groups for system chats, which could lead to unexpected behavior since system chats are not meant to be linked to topics.
…nd improve validation
…ndling in SlaveMessageProcessor
… and SlaveMessageProcessor
…ignment in SlaveMessageProcessor
…essor reopen_forum_topic have strict rate limit
More topics
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.
close #137, 用法详情可参考 https://jiz4oh.com/2025/04/set-topic-in-efb