Overview of the Telethon extension
mainopentele ecosystem. It extends the core functionality of Telethon to support advanced Telegram session handling and client features.repository·main·Indexed 19 days ago
https://github.com/thedemons/openteleA Python library that bridges Telegram Desktop (tdata) and Telethon. It enables the conversion of tdata sessions into Telethon clients and vice versa, allowing the use of official Telegram APIs with randomized device information to minimize bot detection. The library includes an extended version of Telethon and provides tools for managing TDesktop accounts, AuthKeys, and MTProto implementation.
opentele ecosystem. It extends the core functionality of Telethon to support advanced Telegram session handling and client features.opentele project provides an extended version of the Telethon library. It enhances the standard Telethon client with additional capabilities specifically for Telegram automation and session management. The primary entry point for using this extended functionality is the TelegramClient class.The opentele documentation is organized into several key functional areas:
TelegramClient integration.LoginFlag settings.opentele library provides authorization mechanisms for both Telethon and Telegram Desktop clients. Depending on your target client type, you can use different authorization flows and flags to manage how sessions are established and authenticated.The opentele project provides tools for interacting with Telegram Desktop (TDesktop) sessions. The documentation is organized into four main areas:
The opentele project provides several ways to interact with Telegram using Telegram Desktop (TDesktop) data. You can explore documentation for the following core components:
The API class provides built-in templates that allow opentele to use official Telegram APIs, making the client indistinguishable from official Telegram apps to the server. This includes support for the lang_pack parameter, which libraries like Telethon cannot use because it is reserved for official apps.
Available templates include:
TelegramDesktop: Official Telegram for Desktop (Windows, macOS, Linux)TelegramAndroid: Official Telegram for AndroidTelegramAndroidX: Official TelegramX for AndroidTelegramIOS: Official Telegram for iOSTelegramMacOS: Official Telegram-Swift for macOSTelegramWeb_Z: Official Telegram Web ZTelegramWeb_K: Official Telegram Web KWebogram: Old Telegram for browsersThe LoginFlag class is used to control how sessions are handled when converting between TDesktop (Telegram Desktop) and TelegramClient (Telethon). It determines whether the conversion process should reuse an existing authentication key or initiate a new login flow.
Available Flags:
UseCurrentSession: Reuses the existing 256-byte AuthKey from the source (either a tdata folder or a Telethon SQLite session file) to perform the conversion.CreateNewSession: Uses the current session to authorize a brand new session via QR code login.class LoginFlag(int)The API class provides access to built-in templates that mimic official Telegram applications. Using these templates allows your client to appear as an official app to Telegram's servers, as opentele supports parameters like lang_pack which standard Telethon clients cannot use.
Available templates include:
TelegramDesktop: Official Telegram for Desktop (Windows, macOS, Linux)TelegramAndroid: Official Telegram for AndroidTelegramAndroidX: Official TelegramX for AndroidTelegramIOS: Official Telegram for iOSTelegramMacOS: Official Telegram-Swift for macOSTelegramWeb_Z: Official Telegram Web Z for browsersTelegramWeb_K: Official Telegram Web K for browsersWebogram: Old Telegram for browsersWhen calling client.ToTDesktop(flag=...), you can choose between two authorization strategies:
UseCurrentSession: Converts the existing Telethon session directly to a TDesktop session. This is the faster method as it leverages the current authentication state.CreateNewSession: Creates a new TDesktop session. This method uses the existing tdata folder to authorize a new session via QR Login.password argument in ToTDesktop.UseCurrentSession because it involves a new authorization flow.# Option 1: Fast conversion using existing session
tdesk = await client.ToTDesktop(flag=UseCurrentSession)
# Option 2: Create new session via QR Login (requires password if 2FA is on)
tdesk = await client.ToTDesktop(flag=CreateNewSession, password="your_2fa_password")The MTP class is a container for MTProto (MTProto Protocol) related components. Note that this class is currently intended for future developments and has no active usage at this time.
class MTP(BaseObject)To avoid being flagged as an unofficial client, opentele allows you to use official Telegram APIs (e.g., API.TelegramIOS).
Unlike standard Telethon, opentele supports the lang_pack parameter required by official apps, making the connection indistinguishable from an official client to the Telegram server. You can also randomize device information using real data recognized by Telegram servers to further reduce the risk of spam detection.