Skip to main content

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 .session files

  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgsession-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgsession-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

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

Hashes for tgsession-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de02acd37a8ba8daf3ffefa16f6acc7dbcc0e8761fafe113ddde36767e0509df
MD5 77e1c589f4a2c9557dead28527b246e0
BLAKE2b-256 abf4ea27f8fd7d4c80966b4101dc2e8054769a83ecbcb3d93232949915a56cb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tgsession-0.1.0.tar.gz:

Publisher: publish.yml on ankit-chaubey/tgsession

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for tgsession-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1eb5deebb552b4debbe8d78bd40c70096389feae324c382ea089c69541e8617e
MD5 d88ad17e0a1a7373aaa60bcb20068e44
BLAKE2b-256 375ecb589c87e4b449750a89cbb327b1e659fa6b6b32b9135d81b872bf7ae9ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for tgsession-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ankit-chaubey/tgsession

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page