opentele
A python library created to make life easier for Telegram API Developers. Read the documentation
Features
- Convert Telegram Desktop tdata sessions to telethon sessions and vice versa.
- Use telethon with official APIs to avoid bot detection.
- Randomize device info using real data that recognized by Telegram server.
Dependencies
- telethon - Widely used Telegram's API library for Python.
- tgcrypto - AES-256-IGE encryption to works with
tdata
. - pyQt5 - Used by Telegram Desktop to streams data from files.
Installation
- Install from PyPI:
pip install --upgrade opentele
First Run
Load TDesktop from tdata folder and convert it to telethon, with a custom API:
from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, CreateNewSession, UseCurrentSession
import asyncio
async def main():
# Load TDesktop client from tdata folder
tdataFolder = "Path\\To\\tdata"
tdesktop = 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 tdesktop.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
opentele 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 opentele and official apps, the server can't tell you apart.
Incoming Features
- Writing data to tdata for converting telethon sessions to tdesktop.
- Random device information for initConnection to avoid spam-detection.
- Add support for pyrogram.
Documentation
- Read documentation on readthedocs
- Read documentation on github