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 workflow tests 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.0.0.tar.gz (74.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.0.0-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opentele2-1.0.0.tar.gz
  • Upload date:
  • Size: 74.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.0.0.tar.gz
Algorithm Hash digest
SHA256 b06aa5b812e6bafd49ded56053f964ffa8c19498e3efd77b138c761f94c62bd9
MD5 299a18aa40948b70d116b8642991fde8
BLAKE2b-256 e7803e500d47e40ad0d36bb107f3a4b8801b3eadd78ce44b3a7fca773c270260

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opentele2-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 83.9 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4a12dcc31920633c16948de5d4a850f9c7771a428d4ef49fc4e6d01d1f87cf5
MD5 23a769e2aeeafb58c253bbdfe6f11e65
BLAKE2b-256 7cc5efb5da03b86462bb4756f55d82ce4cef386519b03349a5252ed9d344eeb2

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