Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tdjson_example.py to a new clean structure. #3276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

9v2
Copy link

@9v2 9v2 commented Mar 16, 2025

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.

Re-writing python example.
@levlam
Copy link
Contributor

levlam commented Mar 18, 2025

It is recommended to use the libraries mentioned at https://github.com/tdlib/td/tree/master/example#python instead of the example, but the changes looks good and significantly improve the example. Therefore, I will merge them after the next code update on Github.

@9v2
Copy link
Author

9v2 commented Mar 18, 2025

Thank you for paying attention. I have also been working with Pytdbot back in time. It was great, but I also sometimes needed to use raw codes such as the example in the repository.

Editing client class name using more detailed way of the example.
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