thedemons / opentele

A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs.
https://opentele.readthedocs.io/
MIT License
295 stars 95 forks source link

I dont understand how to start it:( #53

Open Bufins opened 2 years ago

Bufins commented 2 years ago

Sorry but i dont understand how to start it. I know how to sart .py files but id ont know how to start opentele. i need to convert tdate to session

0Empty0 commented 7 months ago
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 = 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())