Skip to content

feat: forum topics CRUD + manage_topics admin right (fixes list_topics) - #126

Closed
artgas1 wants to merge 1 commit into
chigwell:mainfrom
artgas1:feat/forum-topics-clean
Closed

feat: forum topics CRUD + manage_topics admin right (fixes list_topics)#126
artgas1 wants to merge 1 commit into
chigwell:mainfrom
artgas1:feat/forum-topics-clean

Conversation

@artgas1

@artgas1 artgas1 commented May 12, 2026

Copy link
Copy Markdown
Contributor

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 supergroup
  • edit_forum_topic(chat_id, topic_id, title, icon_emoji_id, closed, hidden) — edit / close / reopen / hide
  • delete_forum_topic(chat_id, topic_id) — clear the topic's history (Telegram clients use this to delete a topic)

manage_topics admin right (groups.py)

ChatAdminRights already supports manage_topics, but promote_admin, demote_admin, and edit_admin_rights weren't passing it through. Result: you can promote a bot to admin, but it still can't create or edit topics. Now:

  • promote_admin default rights include manage_topics: True
  • edit_admin_rights exposes a manage_topics: bool parameter
  • demote_admin explicitly clears it on revoke

Bug fix on list_topics (chats.py)

list_topics was calling functions.channels.GetForumTopicsRequest — that attribute doesn't exist in current Telethon (verified on 1.42.0). The MTProto method actually lives under messages namespace: functions.messages.GetForumTopicsRequest(peer=...). The new forum-topic methods (Create/Edit/DeleteTopicHistory) live there too — so all four are now consistent.

Test plan

  • AST parses cleanly across all 4 changed files
  • Telethon API surface verified by reflection — functions.messages.{Create,Edit,Get,DeleteTopicHistory} exist with peer kwarg
  • ChatAdminRights(manage_topics=True) constructs without error
  • Manual end-to-end (will run after merge): promote bot in forum-enabled supergroup, create_forum_topic, post into the new topic

Supersedes #125 (closed because the original branch was off our internal fork rather than upstream main).

🤖 Generated with Claude Code

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>
@chigwell

Copy link
Copy Markdown
Owner

Hi @artgas1, and thank you for the contribution! Could you please fix the black formatting so that I can approve and merge this PR?

@artgas1

artgas1 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — split into two focused PRs for easier review:

The remaining topic CRUD (edit/close/delete) from this PR can be revived separately if needed — branch stays.

@artgas1 artgas1 closed this Jun 5, 2026
artgas1 added a commit to artgas1/telegram-mcp that referenced this pull request Jun 5, 2026
…ights (#6)

promote_admin builds ChatAdminRights from a fixed dict that silently
dropped manage_topics — granting topic rights via MCP was impossible
(bots promoted this way could not create forum topics).

Extracted from chigwell#126.
artgas1 added a commit to artgas1/telegram-mcp that referenced this pull request Jun 5, 2026
…ights (#6)

promote_admin builds ChatAdminRights from a fixed dict that silently
dropped manage_topics — granting topic rights via MCP was impossible
(bots promoted this way could not create forum topics).

Extracted from chigwell#126.
chigwell pushed a commit that referenced this pull request Jun 8, 2026
…ights

promote_admin builds ChatAdminRights from a fixed dict that silently
dropped manage_topics — granting topic rights via MCP was impossible
(bots promoted this way could not create forum topics).

Extracted from #126.
KiaroSama pushed a commit to KiaroSama/telegram-mcp that referenced this pull request Aug 25, 2026
…ights (chigwell#6)

promote_admin builds ChatAdminRights from a fixed dict that silently
dropped manage_topics — granting topic rights via MCP was impossible
(bots promoted this way could not create forum topics).

Extracted from chigwell#126.
KiaroSama pushed a commit to KiaroSama/telegram-mcp that referenced this pull request Aug 25, 2026
…ights

promote_admin builds ChatAdminRights from a fixed dict that silently
dropped manage_topics — granting topic rights via MCP was impossible
(bots promoted this way could not create forum topics).

Extracted from chigwell#126.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants