Skip to main content

A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs.

Project description

opentele2

logo

pypi version pypi status documentation issues github last commit github commits pypi installs pypi license code format


A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs. Read the documentation.

A New Era for opentele

opentele2 is the rebirth of the original opentele project. The library is now actively maintained and under continued development. We are committed to keeping it up-to-date with the latest versions of Telegram Desktop and Telethon, fixing bugs, and adding new features.

Features

Dependencies

  • telethon - Widely used Telegram's API library for Python.
  • tgcrypto - AES-256-IGE encryption to works with tdata.

Installation

  • Install from PyPI:
pip install --upgrade opentele2

First Run

Load TDesktop from tdata folder and convert it to telethon, with a custom API:

from opentele2.td import TDesktop
from opentele2.tl import TelegramClient
from opentele2.api import API, CreateNewSession, UseCurrentSession
import asyncio

async def main():
    
    # Load TDesktop client from tdata folder
    tdataFolder = r"C:\Users\<username>\AppData\Roaming\Telegram Desktop\tdata"
    tdesk = TDesktop(tdataFolder)

    # Using official iOS API with randomly generated device info
    # print(api) to see more
    api = API.TelegramIOS.Generate()

    # Convert TDesktop session to telethon client
    # CreateNewSession flag will use the current existing session to
    # authorize the new client by `Login via QR code`.
    client = await tdesk.ToTelethon("newSession.session", CreateNewSession, api)

    # Although Telegram Desktop doesn't let you authorize other
    # sessions via QR Code (or it doesn't have that feature),
    # it is still available across all platforms (APIs).

    # Connect and print all logged in devices
    await client.connect()
    await client.PrintSessions()

asyncio.run(main())

Authorization

opentele2 offers the ability to use official APIs, which are used by official apps. You can check that out here.

According to Telegram TOS: all accounts that sign up or log in using unofficial Telegram API clients are automatically put under observation to avoid violations of the Terms of Service.

It also uses the lang_pack parameter, of which telethon can't use because it's for official apps only.
Therefore, there are no differences between using opentele2 and official apps, the server can't tell you apart.

New features

  • PyQt5 Removed: The PyQt5 library has been removed. Its functionality has been reimplemented in pure Python to eliminate overhead and avoid installing unnecessary heavy dependencies.
  • New Fingerprints: Some improvements of device information generation. The library now uses a new device database.

Examples

The best way to learn anything is by looking at the examples. Am I right?

Documentation documentation

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

opentele2-1.1.6.tar.gz (77.4 kB view details)

Uploaded Source

Built Distribution

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

opentele2-1.1.6-py3-none-any.whl (74.8 kB view details)

Uploaded Python 3

File details

Details for the file opentele2-1.1.6.tar.gz.

File metadata

  • Download URL: opentele2-1.1.6.tar.gz
  • Upload date:
  • Size: 77.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for opentele2-1.1.6.tar.gz
Algorithm Hash digest
SHA256 b645550bac15d810e168479045cd4f25e301cf32fb2b6a058e5735b370b0242b
MD5 1196ae605bc560e50eaea2246987ba77
BLAKE2b-256 3a01ab1ffe9547111601930b9dae314c8a95ff8ab8857b9f2035afa1b66bfba7

See more details on using hashes here.

File details

Details for the file opentele2-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: opentele2-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 74.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for opentele2-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 11040afdfb86eb512b95db5d02b1c63f5d459929908f454079cfc66fb032dbec
MD5 e67c05cecbbb1b582886bd5ecce5a517
BLAKE2b-256 67bab78aa303e6cfbc2152210e45c3e6240250293f1bcc3558e5864d684cf605

See more details on using hashes here.

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