Hierarchy (View Summary)

Implements

Constructors

Properties

appConfig: AppConfigManager = ...

App config manager

log: Logger

Logger for the client

onConnectionState: Emitter<ConnectionState> = ...

Emitted when the connection state changes

onError: Emitter<Error> = ...

Emitted when an error occurs

onRawUpdate: Emitter<RawUpdateInfo> = ...

Emitted when an update is received from the server. Requires updates loop to be running

onServerUpdate: Emitter<TypeUpdates> = ...

Emitted when a low-level Updates updates is received

platform: ICorePlatform

Platform used by the client

Storage manager

timers: TimersManager

Timers manager

updates?: UpdatesManager

Accessors

  • get isConnected(): boolean
  • Returns boolean

  • get stopSignal(): AbortSignal
  • Signal that will be aborted when the client is destroyed

    Returns AbortSignal

Methods

  • Returns Promise<void>

  • Make an RPC call

    This method is still quite low-level and you shouldn't use this when using high-level API provided by @mtcute/client.

    Type Parameters

    • T extends RpcMethod

    Parameters

    Returns Promise<RpcCallReturn[T["_"]]>

  • Change the primary DC

    Parameters

    • dcId: number

    Returns Promise<void>

  • Initialize the connection to the primary DC.

    You shouldn't usually call this method directly as it is called implicitly the first time you call call.

    Returns Promise<void>

  • Destroy the client and all its resources.

    This will terminate any connections to the Telegram servers, free all the resources, and make the client no longer usable

    Returns Promise<void>

  • Terminate any connections to the Telegram servers, but keep the client usable

    Returns Promise<void>

  • Export current session to a single LONG string, containing all the needed information.

    Warning! Anyone with this string will be able to authorize as you and do anything. Treat this as your password, and never give it away!

    In case you have accidentally leaked this string, make sure to revoke this session in account settings: "Privacy & Security" > "Active sessions" > find the one containing mtcute > Revoke, or, in case this is a bot, revoke bot token with @BotFather

    Returns Promise<string>

  • Get the API credentials for use in authorization methods

    Returns Promise<{ hash: string; id: number }>

  • Get the number of connections of the given kind

    Parameters

    Returns Promise<number>

  • Get the primary DC ID

    Returns Promise<number>

  • Handle an update sent by the server in response to an RPC call

    Parameters

    • updates: TypeUpdates

      Updates to handle

    • OptionalnoDispatch: boolean

      Whether the updates inside should not be dispatched as events

    Returns void

  • Import the session from the given session string.

    Note that the session will only be imported in case the storage is missing authorization (i.e. does not contain auth key for the primary DC), otherwise it will be ignored (unless force).

    Parameters

    • session: string | InputStringSessionData

      Session string to import

    • force: boolean = false

      Whether to overwrite existing session

    Returns Promise<void>

  • Notify the client that a channel has been closed

    Parameters

    • channelId: number

    Returns Promise<boolean>

  • Notify the client that a channel has been opened

    Parameters

    • channelId: number
    • Optionalpts: number

    Returns Promise<boolean>

  • Notify the client that the user has logged out

    Returns Promise<void>

  • ADVANCED

    Do all the preparations, but don't connect just yet. Useful when you want to do some preparations before connecting, like setting up session.

    Call connect to actually connect.

    Returns Promise<void>

  • ADVANCED Recreate the given DC, forcefully using the IP taken from server config.

    Parameters

    • dcId: number

    Returns Promise<void>

  • Start the updates loop

    Returns Promise<void>

  • Stop the updates loop

    Returns Promise<void>