Skip to content

Fix list_topics crash on Telethon 1.42#91

Open
embogomolov wants to merge 1 commit intochigwell:mainfrom
embogomolov:fix/forum-topics-telethon-142
Open

Fix list_topics crash on Telethon 1.42#91
embogomolov wants to merge 1 commit intochigwell:mainfrom
embogomolov:fix/forum-topics-telethon-142

Conversation

@embogomolov
Copy link
Copy Markdown

What's broken

Telethon 1.42 doesn't generate a Python wrapper for the channels.getForumTopics TL method. Calling functions.channels.GetForumTopicsRequest(...) in list_topics throws an AttributeError because the class simply doesn't exist in this version.

The fix

Hand-wrote the TL request class (GetForumTopicsRequest) following the schema:

channels.getForumTopics#de560d1 flags:# channel:InputChannel
    q:flags.0?string offset_date:int offset_id:int
    offset_topic:int limit:int = messages.ForumTopics;

It extends TLRequest, handles binary serialization manually via struct.pack, and supports the optional q (search query) flag. Replaces the missing auto-generated class in the list_topics call.

How to test

  • Pick a supergroup with forum topics enabled, call list_topics with its ID
  • Try with and without search_query parameter

Telethon 1.42 does not generate a wrapper for the
channels.getForumTopics TL method, causing list_topics to fail
with AttributeError.

Add a manual TLRequest implementation (GetForumTopicsRequest)
that serializes the request according to the TL schema:
channels.getForumTopics#de560d1

Replace the broken functions.channels.GetForumTopicsRequest call
in list_topics with the new manual implementation.
@embogomolov
Copy link
Copy Markdown
Author

Anyone?

@chigwell
Copy link
Copy Markdown
Owner

chigwell commented Apr 8, 2026

Hey @embogomolov, thank you for the contribution! Could I please ask you to fix the black formatting so the CI tests will pass? Thank you!

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