feat: forum topics CRUD + manage_topics admin right (fixes list_topics)#126
Open
artgas1 wants to merge 1 commit into
Open
feat: forum topics CRUD + manage_topics admin right (fixes list_topics)#126artgas1 wants to merge 1 commit into
artgas1 wants to merge 1 commit into
Conversation
Adds three new MCP tools for forum topic management: - create_forum_topic — create a topic in a forum-enabled supergroup - edit_forum_topic — edit/close/reopen/hide a topic - delete_forum_topic — clear a topic's history (effectively delete) Adds `manage_topics` to ChatAdminRights for promote_admin, demote_admin, and edit_admin_rights so bots can be granted topic-management privileges (without this, you can promote a bot to admin but it still can't create or edit topics). Also fixes a latent bug in `list_topics`: it was calling `functions.channels.GetForumTopicsRequest` which doesn't exist in current Telethon — the actual MTProto method lives under `functions.messages.GetForumTopicsRequest` (verified on Telethon 1.42). Same correction applied across all forum-topic methods. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
Hi @artgas1, and thank you for the contribution! Could you please fix the |
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.
Summary
Three new MCP tools for forum topic management — and a bug fix on
list_topics.New tools (
telegram_mcp/tools/forum_topics.py)create_forum_topic(chat_id, title, icon_color, icon_emoji_id)— create a topic in a forum-enabled supergroupedit_forum_topic(chat_id, topic_id, title, icon_emoji_id, closed, hidden)— edit / close / reopen / hidedelete_forum_topic(chat_id, topic_id)— clear the topic's history (Telegram clients use this to delete a topic)manage_topicsadmin right (groups.py)ChatAdminRightsalready supportsmanage_topics, butpromote_admin,demote_admin, andedit_admin_rightsweren't passing it through. Result: you can promote a bot to admin, but it still can't create or edit topics. Now:promote_admindefault rights includemanage_topics: Trueedit_admin_rightsexposes amanage_topics: boolparameterdemote_adminexplicitly clears it on revokeBug fix on
list_topics(chats.py)list_topicswas callingfunctions.channels.GetForumTopicsRequest— that attribute doesn't exist in current Telethon (verified on 1.42.0). The MTProto method actually lives undermessagesnamespace:functions.messages.GetForumTopicsRequest(peer=...). The new forum-topic methods (Create/Edit/DeleteTopicHistory) live there too — so all four are now consistent.Test plan
functions.messages.{Create,Edit,Get,DeleteTopicHistory}exist withpeerkwargChatAdminRights(manage_topics=True)constructs without errorcreate_forum_topic, post into the new topicSupersedes #125 (closed because the original branch was off our internal fork rather than upstream main).
🤖 Generated with Claude Code