Skip to content

Account


class Account

class Account(BaseObject)

Telegram Desktop account

Attributes:

Name Type Description
api API The API this acount is using.
authKey AuthKey The authorization key used to authorize this acocunt.
UserId int User ID of this account.
MainDcId DcId The main Data Center ID this account connects to.
basePath str The folder where tdata is stored.
localKey AuthKey Key used to encrypt and decrypt tdata.
owner TDesktop td.TDesktop client owner of this account.
keyFile str See td.TDesktop.keyFile.


Account()

def __init__(owner: td.TDesktop, basePath: str = None, api: Union[Type[APIData], APIData] = API.TelegramDesktop, keyFile: str = None, index: int = 0) -> None

Initialized a TDesktop account.
You should use TDesktop() or TDesktop.FromTelethon() instead. Manually using Account() is not recommended. But this is here for your need anyway.

Arguments:

Name Type Default Description
owner TDesktop TDesktop client owner of this account.
basePath str None The folder where tdata is stored.
api API TelegramDesktop Which API to use. Read more here.
keyFile str None See TDesktop.keyFile.
index int 0 Index of this account in the TDesktop client.
TODO

prepareToStart() must be call after initalizing the object.


api

@property
def api() -> APIData

The API this acount is using.


owner

@property
def owner() -> td.TDesktop

TDesktop client owner of this account.


basePath

@property
def basePath() -> str

The folder where tdata is stored.


keyFile

@property
def keyFile() -> str

See TDesktop.keyFile


localKey

@property
def localKey() -> Optional[td.AuthKey]

Key used to encrypt and decrypt tdata.


authKey

@property
def authKey() -> Optional[td.AuthKey]

The authorization key used to authorize this acocunt.


UserId

@property
def UserId() -> int

User ID of this account.


MainDcId

@property
def MainDcId() -> DcId

The main Data Center ID this account connects to.


prepareToStart()

def prepareToStart(localKey: td.AuthKey) -> td.MTP.Config

Prepare the account before starting it

Arguments:

Name Type Description
localKey AuthKey API

Returns:

MTP.Config : [description]


SaveTData()

def SaveTData(basePath: str = None, passcode: str = None, keyFile: str = None) -> None

Save this account to a folder

Arguments:

Name Type Default Description
basePath str None The path to the folder. Defaults to None.
passcode str None Lock the data with a passcode. Defaults to None.
keyFile str None See TDesktop.keyFile

Examples

Add an account to TDesktop and save it to tdata:

telethonClient = TelegramClient("sessionFile", API_ID, API_HASH)
td = TDesktop("new_tdata")
account = Account.FromTelethon(telethonClient, owner=td) # add this account to td
td.SaveTData()