Update tdjson_example.py to a new clean structure. #3276
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.
I've been working with TDLib for a few personal projects and noticed the Python example could use some improvements to make it more accessible to newcomers. After struggling with some aspects of the example myself, I decided to rewrite it while keeping all the functionality intact.
The main changes:
- Restructured the code into a proper class to make it easier to reuse
- Added better error messages and prompts during the authentication flow
- Improved documentation so new users understand what each part does
- Added type hints for better IDE support
- Separated the authentication logic from the main loop for clarity
I just made it easier to understand and extend. The new version should be a drop-in replacement that works exactly the same way but with a cleaner structure.
I've been using this version in my own projects for a while now and it's been much easier to build on top of. Hope this helps other (soy)Python devs.