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.5.tar.gz (88.1 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.5-py3-none-any.whl (83.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opentele2-1.1.5.tar.gz
  • Upload date:
  • Size: 88.1 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.5.tar.gz
Algorithm Hash digest
SHA256 4f36f1b50af7ef911b823351282fa5151a7c2b3b9b2afe441b69e239254122aa
MD5 9841e962cdbf08199c2925c88c362484
BLAKE2b-256 874256c5865ef3d551bfd561ab09f2796469bb1f77425ec9164476d554c92e28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opentele2-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 83.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 02d50f64b3c4913fdd2b2a53a9b61faa9e343e3e4df56050c34a61142634b7d0
MD5 8cb521edbeb0d90fe434f6fd34c6b8e6
BLAKE2b-256 9c7be50aa28079169bc516081cba274024e2862e7b1c7f32c0e06c5850467aac

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