Telegram Session Toolkit (Telethon & Pyrogram)
Project description
tgsession
Telegram Session Toolkit Generate, inspect, dump, and convert Telegram sessions between Telethon and Pyrogram.
tgsession is designed to be clean, explicit, and predictable — no magic, no broken conversions, no messy side effects.
✨ Features
-
Generate Telethon sessions
-
Generate Pyrogram sessions
-
Convert sessions:
- Telethon → Pyrogram (string)
- Pyrogram → Telethon (planned)
-
Inspect Telethon
.sessionfiles -
Dump Telethon session metadata as JSON
-
Clean, colored CLI output (Colorama)
-
Works on Linux / Termux / GitHub Actions
⚠️ File-based Pyrogram session conversion is experimental. String sessions are the recommended and stable format.
📦 Installation
git clone https://github.com/ankit-chaubey/tgsession.git
cd tgsession
pip install -e .
Or from PyPI release:
pip install tgsession
🚀 Usage
General Help
tgsession --help
🔧 Generate Sessions
Generate a Telethon session
tgsession gen tl myaccount
Creates:
myaccount.session(Telethon SQLite session)
Generate a Pyrogram session
tgsession gen pyro myaccount
Creates:
- Pyrogram string session (recommended)
🔍 Inspect Sessions
Inspect a Telethon session
tgsession inspect myaccount.session
Shows:
- DC ID
- Server address
- Port
📤 Dump Sessions
Dump Telethon session as JSON
tgsession dump myaccount.session
Outputs structured metadata useful for debugging and tooling.
🔄 Convert Sessions
Telethon → Pyrogram (string session)
tgsession convert tl myaccount.session pyro
Output:
- Pyrogram string session (printed to stdout)
🧠 Design Philosophy
- Explicit > Implicit
- No hidden authorization steps
- No silent session mutation
- One clear source of truth per session
If something converts — it really converts.
🗂 Project Structure
tgsession/
├── cli.py # CLI entry point
├── gen/
│ ├── telethon_gen.py # Telethon generator
│ └── pyrogram_gen.py # Pyrogram generator
├── inspect/
│ └── telethon_inspect.py
├── dump/
│ └── telethon_dump.py
├── convert/
│ ├── tl_to_pyro.py
│ └── pyro_to_tl.py
└── core/
└── utils.py
🛣 Roadmap
- Stable Pyrogram → Telethon conversion
- Optional Pyrogram file session export
- Non-interactive mode (CI friendly)
- Plugin system
👤 Author
Ankit Chaubey GitHub: https://github.com/ankit-chaubey
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tgsession-0.1.0.tar.gz.
File metadata
- Download URL: tgsession-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de02acd37a8ba8daf3ffefa16f6acc7dbcc0e8761fafe113ddde36767e0509df
|
|
| MD5 |
77e1c589f4a2c9557dead28527b246e0
|
|
| BLAKE2b-256 |
abf4ea27f8fd7d4c80966b4101dc2e8054769a83ecbcb3d93232949915a56cb8
|
Provenance
The following attestation bundles were made for tgsession-0.1.0.tar.gz:
Publisher:
publish.yml on ankit-chaubey/tgsession
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tgsession-0.1.0.tar.gz -
Subject digest:
de02acd37a8ba8daf3ffefa16f6acc7dbcc0e8761fafe113ddde36767e0509df - Sigstore transparency entry: 869763355
- Sigstore integration time:
-
Permalink:
ankit-chaubey/tgsession@620467e39985bd613f46779ebbcfdad441c4d27d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ankit-chaubey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@620467e39985bd613f46779ebbcfdad441c4d27d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tgsession-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tgsession-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb5deebb552b4debbe8d78bd40c70096389feae324c382ea089c69541e8617e
|
|
| MD5 |
d88ad17e0a1a7373aaa60bcb20068e44
|
|
| BLAKE2b-256 |
375ecb589c87e4b449750a89cbb327b1e659fa6b6b32b9135d81b872bf7ae9ae
|
Provenance
The following attestation bundles were made for tgsession-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ankit-chaubey/tgsession
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tgsession-0.1.0-py3-none-any.whl -
Subject digest:
1eb5deebb552b4debbe8d78bd40c70096389feae324c382ea089c69541e8617e - Sigstore transparency entry: 869763359
- Sigstore integration time:
-
Permalink:
ankit-chaubey/tgsession@620467e39985bd613f46779ebbcfdad441c4d27d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ankit-chaubey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@620467e39985bd613f46779ebbcfdad441c4d27d -
Trigger Event:
workflow_dispatch
-
Statement type: