opentele Documentation

repository·main·Indexed 19 days ago

https://github.com/thedemons/opentele

A 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.

Tokens
35.6K
Snippets
151
Records
194
Agent score
65%

What's inside opentele

  1. Overview of opentele documentation

    main

    The opentele documentation is organized into several key functional areas:

    • Telegram Desktop: Detailed information regarding TDesktop, Account structures, AuthKey management, and MTP (MTProto) implementation.
    • Telethon: Documentation for the TelegramClient integration.
    • Authorization: Guides on using the API for authorization and managing LoginFlag settings.
    • Exceptions: A reference for error handling within the library.
  2. Explore Telegram Desktop documentation

    main

    The opentele project provides tools for interacting with Telegram Desktop (TDesktop) sessions. The documentation is organized into four main areas:

    • TDesktop: Detailed information regarding the Telegram Desktop client implementation.
    • Account: Information about managing and interacting with Telegram accounts.
    • AuthKey: Details regarding authentication keys and security.
    • MTP: Documentation on the MTProto protocol implementation.
  3. Explore Telegram Desktop integration options

    main

    The opentele project provides several ways to interact with Telegram using Telegram Desktop (TDesktop) data. You can explore documentation for the following core components:

    • TDesktop: Detailed information on working with Telegram Desktop clients.
    • Account: Information regarding account management and data.
    • AuthKey: Details on handling authentication keys.
    • MTP: Information on the MTProto protocol implementation.
  4. Use official Telegram API templates with the API class

    main

    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 Android
    • TelegramAndroidX: Official TelegramX for Android
    • TelegramIOS: Official Telegram for iOS
    • TelegramMacOS: Official Telegram-Swift for macOS
    • TelegramWeb_Z: Official Telegram Web Z
    • TelegramWeb_K: Official Telegram Web K
    • Webogram: Old Telegram for browsers
  5. Understand LoginFlag for session conversion

    main

    The 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)
  6. Use built-in Telegram API templates with the API class

    main

    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 Android
    • TelegramAndroidX: Official TelegramX for Android
    • TelegramIOS: Official Telegram for iOS
    • TelegramMacOS: Official Telegram-Swift for macOS
    • TelegramWeb_Z: Official Telegram Web Z for browsers
    • TelegramWeb_K: Official Telegram Web K for browsers
    • Webogram: Old Telegram for browsers
  7. Use ToTDesktop flags: UseCurrentSession vs CreateNewSession

    main

    When calling client.ToTDesktop(flag=...), you can choose between two authorization strategies:

    1. UseCurrentSession: Converts the existing Telethon session directly to a TDesktop session. This is the faster method as it leverages the current authentication state.
    2. CreateNewSession: Creates a new TDesktop session. This method uses the existing tdata folder to authorize a new session via QR Login.
      • Note: If 2FA (Two-Factor Authentication) is enabled on the account, you must provide the password using the password argument in ToTDesktop.
      • This method is slower than 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")
  8. Use official Telegram APIs to avoid detection

    main

    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.