MadelineProtoDocs/docs/PHP/danog/MadelineProto/MTProto.md

43 KiB

title: danog\MadelineProto\MTProto: Manages all of the mtproto stuff. description:

danog\MadelineProto\MTProto

Back to index

Author: Daniil Gentili daniil@daniil.it

Manages all of the mtproto stuff.

Constants

  • danog\MadelineProto\MTProto::RELEASE: Release version.

  • danog\MadelineProto\MTProto::NOT_LOGGED_IN: We're not logged in.

  • danog\MadelineProto\MTProto::WAITING_CODE: We're waiting for the login code.

  • danog\MadelineProto\MTProto::WAITING_SIGNUP: We're waiting for parameters to sign up.

  • danog\MadelineProto\MTProto::WAITING_PASSWORD: We're waiting for the 2FA password.

  • danog\MadelineProto\MTProto::LOGGED_IN: We're logged in.

  • danog\MadelineProto\MTProto::SECRET_EMPTY: Secret chat was not found.

  • danog\MadelineProto\MTProto::SECRET_REQUESTED: Secret chat was requested.

  • danog\MadelineProto\MTProto::SECRET_READY: Secret chat was found.

Method list:

  • serializeSession(): \Generator
  • serializeAll(): void
  • cleanup(): \Generator
  • logger(string $param, int $level, string $file): void
  • getMethodNamespaces(): array
  • getMethodsNamespaced(): array
  • getTL(): \danog\MadelineProto\TL\TL
  • getLogger()
  • getPsrLogger()
  • getHTTPClient(): \Amp\Http\Client\HttpClient
  • getDNSClient(): \Amp\Dns\Resolver
  • fileGetContents(string $url): \Generator
  • getDataCenterConnections(): \danog\MadelineProto\DataCenterConnection[]
  • getDataCenterId(): int|string
  • isIpc(): bool
  • updateSettings(\danog\MadelineProto\SettingsAbstract $settings): \Generator
  • getSettings(): \danog\MadelineProto\Settings
  • setupLogger(): void
  • hasAllAuth(): bool
  • connectToAllDcs(bool $reconnectAll): \Generator
  • resetUpdateState(): void
  • getCdnConfig(string $datacenter): \Generator
  • getCachedConfig(): array
  • getConfig(array $config, array $options): \Generator
  • getSelf(): array|bool
  • fullGetSelf(): \Generator<array|bool>
  • getAuthorization(): int
  • getHint(): string
  • hasReportPeers(): bool
  • setReportPeers(int|string $userOrId): \Generator
  • report(string $message, string $parseMode): \Generator
  • getAllMethods(): array
  • getMethodCallbacks(): array
  • getMethodBeforeCallbacks(): array
  • getConstructorCallbacks(): array
  • getConstructorBeforeCallbacks(): array
  • getConstructorSerializeCallbacks(): array
  • getTypeMismatchCallbacks(): array
  • init(): void
  • initAsynchronously(): \Generator
  • inited(): bool
  • forceInit(bool $inited): void
  • methodCall(string $method, array|\Generator $args, array $aargs): mixed
  • methodCallAsyncRead(string $method, array|\Generator $args, array $aargs): \Generator
  • methodCallAsyncWrite(string $method, array|\Generator $args, array $aargs): \Generator
  • toSupergroup(int $id): float|int
  • fromSupergroup(int $id): float|int
  • isSupergroup(int $id): bool
  • addUser(array $user): \Generator
  • peerIsset(mixed $id): \Generator
  • getFolderId(mixed $id): ?int
  • getId(mixed $id): int
  • getInfo(mixed $id, bool $recursive): \Generator Info object
  • fullChatLastUpdated(mixed $id): \Generator<int>
  • getFullInfo(mixed $id): \Generator FullInfo object
  • getPwrChat(mixed $id): \Generator<array> Chat object
  • resolveUsername(string $username): \Generator
  • uploadFromUrl(string|\danog\MadelineProto\FileCallbackInterface $url, int $size, string $fileName, callable $cb, bool $encrypted): \Generator
  • uploadFromCallable(mixed $callable, int $size, string $mime, string $fileName, callable $cb, bool $seekable, bool $encrypted): \Generator
  • uploadFromTgfile(mixed $media, callable $cb, bool $encrypted): \Generator
  • getFileInfo(mixed $constructor): \Generator<array>
  • getPropicInfo(mixed $messageMedia): \Generator<array>
  • extractBotAPIFile(array $info): ?array
  • getDownloadInfo(mixed $messageMedia): \Generator<array>
  • downloadToDir(mixed $messageMedia, string|\danog\MadelineProto\FileCallbackInterface $dir, callable $cb): \Generator
  • downloadToFile(mixed $messageMedia, string|\danog\MadelineProto\FileCallbackInterface $file, callable $cb): \Generator Downloaded file path
  • downloadToCallable(mixed $messageMedia, callable|\danog\MadelineProto\FileCallbackInterface $callable, callable $cb, bool $seekable, int $offset, int $end, int $part_size): \Generator
  • downloadToBrowser(array|string $messageMedia, callable $cb): \Generator
  • downloadToStream(mixed $messageMedia, mixed|\danog\MadelineProto\FileCallbackInterface $stream, callable $cb, int $offset, int $end): \Generator
  • downloadToResponse(array|string $messageMedia, \ServerRequest $request, callable $cb): \Generator Returned response
  • uploadEncrypted(\danog\MadelineProto\FileCallbackInterface|string|array $file, string $fileName, callable $cb): \Generator
  • upload(\danog\MadelineProto\FileCallbackInterface|string|array $file, string $fileName, callable $cb, bool $encrypted): \Generator
  • uploadFromStream(mixed $stream, int $size, string $mime, string $fileName, callable $cb, bool $encrypted): \Generator
  • acceptSecretChat(array $params): \Generator
  • requestSecretChat(mixed $user): \Generator
  • rekey(int $chat): \Generator
  • secretChatStatus(int $chat): \int One of MTProto::SECRET_EMPTY, MTProto::SECRET_REQUESTED, MTProto::SECRET_READY
  • getSecretChat(array|int $chat): array
  • hasSecretChat(array|int $chat): bool
  • discardSecretChat(int $chat): \Generator
  • mbStrlen(string $text): float|int
  • mbSubstr(string $text, int $offset, ?int $length): string
  • mbStrSplit(string $text, int $length): array
  • MTProtoToBotAPI(array $data): \Generator<array>
  • botAPIToMTProto(array $arguments): \Generator<array>
  • unpackFileId(string $fileId): \array Unpacked file ID
  • tdcliToTd(array $params, array $key): array
  • tdToMTProto(array $params): \Generator<array>
  • MTProtoToTdcli(mixed $params): \Generator
  • MTProtoToTd(mixed $params): \Generator
  • tdToTdcli(mixed $params): mixed
  • requestCall(mixed $user): \Generator
  • acceptCall(array $call): \Generator
  • confirmCall(array $params): \Generator
  • completeCall(array $params): \Generator
  • callStatus(int $id): int
  • getCall(int $call): array
  • discardCall(array $call, array $reason, array $rating, bool $need_debug): \Generator
  • getDialogs(bool $force): \Generator
  • getFullDialogs(bool $force): \Generator
  • setEventHandler(class-string<\danog\MadelineProto\EventHandler> $eventHandler): \Generator
  • unsetEventHandler(bool $disableUpdateHandling): void
  • getEventHandler(): \danog\MadelineProto\EventHandler
  • hasEventHandler(): bool
  • setWebhook(string $hook_url, string $pem_path): void
  • setCallback(callable $callback): void
  • logout(): \Generator
  • botLogin(string $token): \Generator
  • phoneLogin(string $number, int $sms_type): \Generator
  • completePhoneLogin(string $code): \Generator
  • importAuthorization(mixed $authorization): \Generator
  • exportAuthorization(): \Generator
  • completeSignup(string $first_name, string $last_name): \Generator
  • complete2faLogin(string $password): \Generator
  • update2fa(array $params): \Generator
  • initSelfRestart(): void
  • loop(callable|null $callback): \Generator
  • stop(): void
  • restart(): void
  • loopFork(): \Amp\Promise
  • closeConnection(string $message): void
  • setNoop(): void
  • start(): \Generator
  • getWebTemplate(): string
  • setWebTemplate(string $template): void
  • checkTos(): \Generator
  • acceptTos(): \Generator
  • declineTos(): \Generator

Methods:

serializeSession(): \Generator

Serialize session, returning object to serialize to db.

See also:

  • \Generator

Generated by danog/phpdoc

serializeAll(): void

Serialize all instances. CALLED ONLY ON SHUTDOWN.


Generated by danog/phpdoc

cleanup(): \Generator

Cleanup memory and session file.

See also:

  • \Generator

Generated by danog/phpdoc

logger(string $param, int $level, string $file): void

Logger.

Parameters:

  • $param: string Parameter
  • $level: int Logging level
  • $file: string File where the message originated

Generated by danog/phpdoc

getMethodNamespaces(): array

Get TL namespaces.


Generated by danog/phpdoc

getMethodsNamespaced(): array

Get namespaced methods (method => namespace).


Generated by danog/phpdoc

getTL(): \danog\MadelineProto\TL\TL

Get TL serializer.

See also:

  • \danog\MadelineProto\TL\TL

Generated by danog/phpdoc

getLogger()

Get logger.


Generated by danog/phpdoc

getPsrLogger()

Get PSR logger.


Generated by danog/phpdoc

getHTTPClient(): \Amp\Http\Client\HttpClient

Get async HTTP client.

See also:

  • \Amp\Http\Client\HttpClient

Generated by danog/phpdoc

getDNSClient(): \Amp\Dns\Resolver

Get async DNS client.

See also:

  • \Amp\Dns\Resolver

Generated by danog/phpdoc

fileGetContents(string $url): \Generator

Get contents of remote file asynchronously.

Parameters:

  • $url: string URL

Fully typed return value:

\Generator<int, \Amp\Promise<string>, mixed, string>

See also:

  • \Amp\Promise
  • \Generator

Generated by danog/phpdoc

getDataCenterConnections(): \danog\MadelineProto\DataCenterConnection[]

Get all datacenter connections.

See also:

  • \danog\MadelineProto\DataCenterConnection

Generated by danog/phpdoc

getDataCenterId(): int|string

Get main DC ID.


Generated by danog/phpdoc

isIpc(): bool

Whether we're an IPC client instance.


Generated by danog/phpdoc

updateSettings(\danog\MadelineProto\SettingsAbstract $settings): \Generator

Parse, update and store settings.

Parameters:

  • $settings: \danog\MadelineProto\SettingsAbstract Settings

See also:

  • \danog\MadelineProto\SettingsAbstract
  • \Generator

Generated by danog/phpdoc

getSettings(): \danog\MadelineProto\Settings

Return current settings.

See also:


Generated by danog/phpdoc

setupLogger(): void

Setup logger.


Generated by danog/phpdoc

hasAllAuth(): bool

Checks whether all datacenters are authorized.


Generated by danog/phpdoc

connectToAllDcs(bool $reconnectAll): \Generator

Connects to all datacenters and if necessary creates authorization keys, binds them and writes client info.

Parameters:

  • $reconnectAll: bool Whether to reconnect to all DCs

See also:

  • \Generator

Generated by danog/phpdoc

resetUpdateState(): void

Reset the update state and fetch all updates from the beginning.


Generated by danog/phpdoc

getCdnConfig(string $datacenter): \Generator

Store RSA keys for CDN datacenters.

Parameters:

  • $datacenter: string DC ID

See also:

  • \Generator

Generated by danog/phpdoc

getCachedConfig(): array

Get cached server-side config.


Generated by danog/phpdoc

getConfig(array $config, array $options): \Generator

Get cached (or eventually re-fetch) server-side config.

Parameters:

  • $config: array Current config
  • $options: array Options for method call

See also:

  • \Generator

Generated by danog/phpdoc

getSelf(): array|bool

Get info about the logged-in user, cached.


Generated by danog/phpdoc

fullGetSelf(): \Generator<array|bool>

Get info about the logged-in user, not cached.

See also:

  • \Generator

Generated by danog/phpdoc

getAuthorization(): int

Get authorization info.


Generated by danog/phpdoc

getHint(): string

Get current password hint.


Generated by danog/phpdoc

hasReportPeers(): bool

Check if has report peers.


Generated by danog/phpdoc

setReportPeers(int|string $userOrId): \Generator

Set peer(s) where to send errors occurred in the event loop.

Parameters:

  • $userOrId: int|string Username(s) or peer ID(s)

See also:

  • \Generator

Generated by danog/phpdoc

report(string $message, string $parseMode): \Generator

Report an error to the previously set peer.

Parameters:

  • $message: string Error to report
  • $parseMode: string Parse mode

See also:

  • \Generator

Generated by danog/phpdoc

getAllMethods(): array

Get full list of MTProto and API methods.


Generated by danog/phpdoc

getMethodCallbacks(): array

Called right before serialization of method starts. Pass the method name


Generated by danog/phpdoc

getMethodBeforeCallbacks(): array

Called right before serialization of method starts. Pass the method name


Generated by danog/phpdoc

getConstructorCallbacks(): array

Called right after deserialization of object, passing the final object.


Generated by danog/phpdoc

getConstructorBeforeCallbacks(): array

Called right before deserialization of object. Pass only the constructor name


Generated by danog/phpdoc

getConstructorSerializeCallbacks(): array

Called right before serialization of constructor. Passed the object, will return a modified version.


Generated by danog/phpdoc

getTypeMismatchCallbacks(): array

Called if objects of the specified type cannot be serialized. Passed the unserializable object, will try to convert it to an object of the proper type.


Generated by danog/phpdoc

init(): void

Blockingly init.


Generated by danog/phpdoc

initAsynchronously(): \Generator

Asynchronously init.

See also:

  • \Generator

Generated by danog/phpdoc

inited(): bool

Check if we've already inited.


Generated by danog/phpdoc

forceInit(bool $inited): void

Mark instance as (de)inited forcefully.

Parameters:

  • $inited: bool Whether to mark the instance as inited or deinited

Generated by danog/phpdoc

methodCall(string $method, array|\Generator $args, array $aargs): mixed

Synchronous wrapper for methodCall.

Parameters:

  • $method: string Method name
  • $args: array|\Generator Arguments
    Full type:
    array|\Generator<mixed, mixed, mixed, array>
    
  • $aargs: array Additional arguments

See also:

  • \Generator

Generated by danog/phpdoc

methodCallAsyncRead(string $method, array|\Generator $args, array $aargs): \Generator

Call method and wait asynchronously for response. If the $aargs['noResponse'] is true, will not wait for a response.

Parameters:

  • $method: string Method name
  • $args: array|\Generator Arguments
    Full type:
    array|\Generator<mixed, mixed, mixed, array>
    
  • $aargs: array Additional arguments

See also:

  • \Generator

Generated by danog/phpdoc

methodCallAsyncWrite(string $method, array|\Generator $args, array $aargs): \Generator

Call method and make sure it is asynchronously sent.

Parameters:

  • $method: string Method name
  • $args: array|\Generator Arguments
    Full type:
    array|\Generator<mixed, mixed, mixed, array>
    
  • $aargs: array Additional arguments

See also:

  • \Generator

Generated by danog/phpdoc

toSupergroup(int $id): float|int

Convert MTProto channel ID to bot API channel ID.

Parameters:

  • $id: int MTProto channel ID

Generated by danog/phpdoc

fromSupergroup(int $id): float|int

Convert bot API channel ID to MTProto channel ID.

Parameters:

  • $id: int Bot API channel ID

Generated by danog/phpdoc

isSupergroup(int $id): bool

Check whether provided bot API ID is a channel.

Parameters:

  • $id: int Bot API ID

Generated by danog/phpdoc

addUser(array $user): \Generator

Add user info.

Parameters:

  • $user: array User info

See also:

  • \Generator

Generated by danog/phpdoc

peerIsset(mixed $id): \Generator

Check if peer is present in internal peer database.

Parameters:

  • $id: mixed Peer

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|array, mixed, bool>

See also:

  • \Amp\Promise
  • \Generator

Generated by danog/phpdoc

getFolderId(mixed $id): ?int

Get folder ID from object.

Parameters:

  • $id: mixed Object

Generated by danog/phpdoc

getId(mixed $id): int

Get bot API ID from peer object.

Parameters:

  • $id: mixed Peer

Generated by danog/phpdoc

getInfo(mixed $id, bool $recursive): \Generator Info object

Get info about peer, returns an Info object.

Parameters:

  • $id: mixed Peer
  • $recursive: bool Internal

Return value: Info object

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<string>|array, mixed, array{InputPeer: array{_: string, user_id?: mixed, access_hash?: mixed, min?: mixed, chat_id?: mixed, channel_id?: mixed}, Peer: array{_: string, user_id?: mixed, chat_id?: mixed, channel_id?: mixed}, DialogPeer: array{_: string, peer: array{_: string, user_id?: mixed, chat_id?: mixed, channel_id?: mixed}}, NotifyPeer: array{_: string, peer: array{_: string, user_id?: mixed, chat_id?: mixed, channel_id?: mixed}}, InputDialogPeer: array{_: string, peer: array{_: string, user_id?: mixed, access_hash?: mixed, min?: mixed, chat_id?: mixed, channel_id?: mixed}}, InputNotifyPeer: array{_: string, peer: array{_: string, user_id?: mixed, access_hash?: mixed, min?: mixed, chat_id?: mixed, channel_id?: mixed}}, bot_api_id: int|string, user_id?: int, chat_id?: int, channel_id?: int, InputUser?: array{_: string, user_id?: int, access_hash?: mixed, min?: bool}, InputChannel?: array{_: string, channel_id: int, access_hash: mixed, min: bool}, type: string}>

See also:


Generated by danog/phpdoc

fullChatLastUpdated(mixed $id): \Generator<int>

When were full info for this chat last cached.

Parameters:

  • $id: mixed Chat ID

See also:

  • \Generator

Generated by danog/phpdoc

getFullInfo(mixed $id): \Generator FullInfo object

Get full info about peer, returns an FullInfo object.

Parameters:

  • $id: mixed Peer

Return value: FullInfo object

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|array, mixed, array>

See also:


Generated by danog/phpdoc

getPwrChat(mixed $id): \Generator<array> Chat object

Get full info about peer (including full list of channel members), returns a Chat object.

Parameters:

  • $id: mixed Peer

Return value: Chat object

See also:


Generated by danog/phpdoc

resolveUsername(string $username): \Generator

Resolve username (use getInfo instead).

Parameters:

  • $username: string Username

See also:

  • \Generator

Generated by danog/phpdoc

uploadFromUrl(string|\danog\MadelineProto\FileCallbackInterface $url, int $size, string $fileName, callable $cb, bool $encrypted): \Generator

Upload file from URL.

Parameters:

  • $url: string|\danog\MadelineProto\FileCallbackInterface URL of file
  • $size: int Size of file
  • $fileName: string File name
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $encrypted: bool Whether to encrypt file for secret chats

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\Http\Client\Response>|\Amp\Promise<int>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>

See also:


Generated by danog/phpdoc

uploadFromCallable(mixed $callable, int $size, string $mime, string $fileName, callable $cb, bool $seekable, bool $encrypted): \Generator

Upload file from callable. The callable must accept two parameters: int $offset, int $size The callable must return a string with the contest of the file at the specified offset and size.

Parameters:

  • $callable: mixed Callable
  • $size: int File size
  • $mime: string Mime type
  • $fileName: string File name
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $seekable: bool Whether chunks can be fetched out of order
  • $encrypted: bool Whether to encrypt file for secret chats

Fully typed return value:

\Generator<int, \Amp\Promise|\Amp\Promise<array>, mixed, array{_: string, id: string, parts: int, name: string, mime_type: string, key_fingerprint?: mixed, key?: mixed, iv?: mixed, md5_checksum: string}>

See also:

  • \Amp\Promise
  • \Generator

Generated by danog/phpdoc

uploadFromTgfile(mixed $media, callable $cb, bool $encrypted): \Generator

Reupload telegram file.

Parameters:

  • $media: mixed Telegram file
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $encrypted: bool Whether to encrypt file for secret chats

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|array, mixed, mixed>

See also:

  • \Amp\Promise
  • \Generator

Generated by danog/phpdoc

getFileInfo(mixed $constructor): \Generator<array>

Get info about file.

Parameters:

  • $constructor: mixed File ID

See also:

  • \Generator

Generated by danog/phpdoc

getPropicInfo(mixed $messageMedia): \Generator<array>

Get download info of the propic of a user Returns an array with the following structure:. $info['ext'] - The file extension $info['name'] - The file name, without the extension $info['mime'] - The file mime type $info['size'] - The file size

Parameters:

  • $messageMedia: mixed File ID

See also:

  • \Generator

Generated by danog/phpdoc

extractBotAPIFile(array $info): ?array

Extract file info from bot API message.

Parameters:

  • $info: array Bot API message object

Generated by danog/phpdoc

getDownloadInfo(mixed $messageMedia): \Generator<array>

Get download info of file Returns an array with the following structure:. $info['ext'] - The file extension $info['name'] - The file name, without the extension $info['mime'] - The file mime type $info['size'] - The file size

Parameters:

  • $messageMedia: mixed File ID

See also:

  • \Generator

Generated by danog/phpdoc

downloadToDir(mixed $messageMedia, string|\danog\MadelineProto\FileCallbackInterface $dir, callable $cb): \Generator

Download file to directory.

Parameters:

  • $messageMedia: mixed File to download
  • $dir: string|\danog\MadelineProto\FileCallbackInterface Directory where to download the file
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|\Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<callable|null>|\Amp\Promise<mixed>|array|bool|mixed, mixed, false|string>

See also:


Generated by danog/phpdoc

downloadToFile(mixed $messageMedia, string|\danog\MadelineProto\FileCallbackInterface $file, callable $cb): \Generator Downloaded file path

Download file.

Parameters:

  • $messageMedia: mixed File to download
  • $file: string|\danog\MadelineProto\FileCallbackInterface Downloaded file path
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)

Return value: Downloaded file path

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|\Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<callable|null>|\Amp\Promise<mixed>|array|bool|mixed, mixed, false|string>

See also:


Generated by danog/phpdoc

downloadToCallable(mixed $messageMedia, callable|\danog\MadelineProto\FileCallbackInterface $callable, callable $cb, bool $seekable, int $offset, int $end, int $part_size): \Generator

Download file to callable. The callable must accept two parameters: string $payload, int $offset The callable will be called (possibly out of order, depending on the value of $seekable). The callable should return the number of written bytes.

Parameters:

  • $messageMedia: mixed File to download
  • $callable: callable|\danog\MadelineProto\FileCallbackInterface Chunk callback
  • $cb: callable Status callback (DEPRECATED, use FileCallbackInterface)
  • $seekable: bool Whether the callable can be called out of order
  • $offset: int Offset where to start downloading
  • $end: int Offset where to stop downloading (inclusive)
  • $part_size: int Size of each chunk

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|array, mixed, true>

See also:


Generated by danog/phpdoc

downloadToBrowser(array|string $messageMedia, callable $cb): \Generator

Download file to browser. Supports HEAD requests and content-ranges for parallel and resumed downloads.

Parameters:

  • $messageMedia: array|string File to download
  • $cb: callable Status callback (can also use FileCallback)

See also:

  • \Generator

Generated by danog/phpdoc

downloadToStream(mixed $messageMedia, mixed|\danog\MadelineProto\FileCallbackInterface $stream, callable $cb, int $offset, int $end): \Generator

Download file to stream.

Parameters:

  • $messageMedia: mixed File to download
  • $stream: mixed|\danog\MadelineProto\FileCallbackInterface Stream where to download file
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $offset: int Offset where to start downloading
  • $end: int Offset where to end download

Fully typed return value:

\Generator<int, \Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<mixed>|mixed, mixed, mixed>

See also:


Generated by danog/phpdoc

downloadToResponse(array|string $messageMedia, \ServerRequest $request, callable $cb): \Generator Returned response

Download file to amphp/http-server response. Supports HEAD requests and content-ranges for parallel and resumed downloads.

Parameters:

  • $messageMedia: array|string File to download
  • $request: \ServerRequest Request
  • $cb: callable Status callback (can also use FileCallback)

Return value: Returned response

Fully typed return value:

\Generator<mixed, array, mixed, \Amp\Http\Server\Response>

See also:

  • \ServerRequest
  • \Amp\Http\Server\Response
  • \Generator

Generated by danog/phpdoc

uploadEncrypted(\danog\MadelineProto\FileCallbackInterface|string|array $file, string $fileName, callable $cb): \Generator

Upload file to secret chat.

Parameters:

  • $file: \danog\MadelineProto\FileCallbackInterface|string|array File, URL or Telegram file to upload
  • $fileName: string File name
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|\Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<int>|\Amp\Promise<mixed>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>

See also:


Generated by danog/phpdoc

upload(\danog\MadelineProto\FileCallbackInterface|string|array $file, string $fileName, callable $cb, bool $encrypted): \Generator

Upload file.

Parameters:

  • $file: \danog\MadelineProto\FileCallbackInterface|string|array File, URL or Telegram file to upload
  • $fileName: string File name
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $encrypted: bool Whether to encrypt file for secret chats

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|\Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<int>|\Amp\Promise<mixed>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>

See also:


Generated by danog/phpdoc

uploadFromStream(mixed $stream, int $size, string $mime, string $fileName, callable $cb, bool $encrypted): \Generator

Upload file from stream.

Parameters:

  • $stream: mixed PHP resource or AMPHP async stream
  • $size: int File size
  • $mime: string Mime type
  • $fileName: string File name
  • $cb: callable Callback (DEPRECATED, use FileCallbackInterface)
  • $encrypted: bool Whether to encrypt file for secret chats

Fully typed return value:

\Generator<int|mixed, \Amp\Promise|\Amp\Promise<int>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>

See also:

  • \Amp\Promise
  • \danog\MadelineProto\Stream\StreamInterface
  • \Generator

Generated by danog/phpdoc

acceptSecretChat(array $params): \Generator

Accept secret chat.

Parameters:

  • $params: array Secret chat ID

See also:

  • \Generator

Generated by danog/phpdoc

requestSecretChat(mixed $user): \Generator

Request secret chat.

Parameters:

  • $user: mixed User to start secret chat with

See also:

  • \Generator

Generated by danog/phpdoc

rekey(int $chat): \Generator

Rekey secret chat.

Parameters:

  • $chat: int Secret chat to rekey

See also:

  • \Generator

Generated by danog/phpdoc

secretChatStatus(int $chat): \int One of MTProto::SECRET_EMPTY, MTProto::SECRET_REQUESTED, MTProto::SECRET_READY

Get secret chat status.

Parameters:

  • $chat: int Chat ID

Return value: One of MTProto::SECRET_EMPTY, MTProto::SECRET_REQUESTED, MTProto::SECRET_READY


Generated by danog/phpdoc

getSecretChat(array|int $chat): array

Get secret chat.

Parameters:

  • $chat: array|int Secret chat ID

Generated by danog/phpdoc

hasSecretChat(array|int $chat): bool

Check whether secret chat exists.

Parameters:

  • $chat: array|int Secret chat ID

Generated by danog/phpdoc

discardSecretChat(int $chat): \Generator

Discard secret chat.

Parameters:

  • $chat: int Secret chat ID

See also:

  • \Generator

Generated by danog/phpdoc

mbStrlen(string $text): float|int

Get Telegram UTF-8 length of string.

Parameters:

  • $text: string Text

Generated by danog/phpdoc

mbSubstr(string $text, int $offset, ?int $length): string

Telegram UTF-8 multibyte substring.

Parameters:

  • $text: string Text to substring
  • $offset: int Offset
  • $length: ?int Length

Generated by danog/phpdoc

mbStrSplit(string $text, int $length): array

Telegram UTF-8 multibyte split.

Parameters:

  • $text: string Text
  • $length: int Length

Generated by danog/phpdoc

MTProtoToBotAPI(array $data): \Generator<array>

Convert MTProto parameters to bot API parameters.

Parameters:

  • $data: array Data

See also:

  • \Generator

Generated by danog/phpdoc

botAPIToMTProto(array $arguments): \Generator<array>

Convert bot API parameters to MTProto parameters.

Parameters:

  • $arguments: array Arguments

See also:

  • \Generator

Generated by danog/phpdoc

unpackFileId(string $fileId): \array Unpacked file ID

Unpack bot API file ID.

Parameters:

  • $fileId: string Bot API file ID

Return value: Unpacked file ID


Generated by danog/phpdoc

tdcliToTd(array $params, array $key): array

Convert tdcli parameters to tdcli.

Parameters:

  • $params: array Params
  • $key: array Key

Generated by danog/phpdoc

tdToMTProto(array $params): \Generator<array>

Convert TD to MTProto parameters.

Parameters:

  • $params: array Parameters

See also:

  • \Generator

Generated by danog/phpdoc

MTProtoToTdcli(mixed $params): \Generator

MTProto to TDCLI params.

Parameters:

  • $params: mixed Params

See also:

  • \Generator

Generated by danog/phpdoc

MTProtoToTd(mixed $params): \Generator

MTProto to TD params.

Parameters:

  • $params: mixed Params

See also:

  • \Generator

Generated by danog/phpdoc

tdToTdcli(mixed $params): mixed

Convert TD parameters to tdcli.

Parameters:

  • $params: mixed Parameters

Generated by danog/phpdoc

requestCall(mixed $user): \Generator

Request VoIP call.

Parameters:

  • $user: mixed User

See also:

  • \Generator

Generated by danog/phpdoc

acceptCall(array $call): \Generator

Accept call.

Parameters:

  • $call: array Call

See also:

  • \Generator

Generated by danog/phpdoc

confirmCall(array $params): \Generator

Confirm call.

Parameters:

  • $params: array Params

See also:

  • \Generator

Generated by danog/phpdoc

completeCall(array $params): \Generator

Complete call handshake.

Parameters:

  • $params: array Params

See also:

  • \Generator

Generated by danog/phpdoc

callStatus(int $id): int

Get call status.

Parameters:

  • $id: int Call ID

Generated by danog/phpdoc

getCall(int $call): array

Get call info.

Parameters:

  • $call: int Call ID

Generated by danog/phpdoc

discardCall(array $call, array $reason, array $rating, bool $need_debug): \Generator

Discard call.

Parameters:

  • $call: array Call
  • $reason: array
  • $rating: array Rating
  • $need_debug: bool Need debug?

See also:

  • \Generator

Generated by danog/phpdoc

getDialogs(bool $force): \Generator

Get dialog peers.

Parameters:

  • $force: bool Whether to refetch all dialogs ignoring cache

Fully typed return value:

\Generator<int, \Amp\Promise<bool>, mixed, list<mixed>>

See also:

  • \Amp\Promise
  • \Generator

Generated by danog/phpdoc

getFullDialogs(bool $force): \Generator

Get full info of all dialogs.

Parameters:

  • $force: bool Whether to refetch all dialogs ignoring cache

See also:

  • \Generator

Generated by danog/phpdoc

setEventHandler(class-string<\danog\MadelineProto\EventHandler> $eventHandler): \Generator

Set event handler.

Parameters:

  • $eventHandler: class-string<\danog\MadelineProto\EventHandler> Event handler

See also:


Generated by danog/phpdoc

unsetEventHandler(bool $disableUpdateHandling): void

Unset event handler.

Parameters:

  • $disableUpdateHandling: bool Whether to also disable internal update handling (will cause errors, otherwise will simply use the NOOP handler)

Generated by danog/phpdoc

getEventHandler(): \danog\MadelineProto\EventHandler

Get event handler.

See also:


Generated by danog/phpdoc

hasEventHandler(): bool

Check if an event handler instance is present.


Generated by danog/phpdoc

setWebhook(string $hook_url, string $pem_path): void

Set webhook update handler.

Parameters:

  • $hook_url: string Webhook URL
  • $pem_path: string PEM path for self-signed certificate

Generated by danog/phpdoc

setCallback(callable $callback): void

Set update handling callback.

Parameters:

  • $callback: callable Callback

Generated by danog/phpdoc

logout(): \Generator

Log out currently logged in user.

See also:

  • \Generator

Generated by danog/phpdoc

botLogin(string $token): \Generator

Login as bot.

Parameters:

  • $token: string Bot token

See also:

  • \Generator

Generated by danog/phpdoc

phoneLogin(string $number, int $sms_type): \Generator

Login as user.

Parameters:

  • $number: string Phone number
  • $sms_type: int SMS type

See also:

  • \Generator

Generated by danog/phpdoc

completePhoneLogin(string $code): \Generator

Complet user login using login code.

Parameters:

  • $code: string Login code

See also:

  • \Generator

Generated by danog/phpdoc

importAuthorization(mixed $authorization): \Generator

Import authorization.

Parameters:

  • $authorization: mixed Authorization info

See also:

  • \Generator

Generated by danog/phpdoc

exportAuthorization(): \Generator

Export authorization.

Fully typed return value:

\Generator<mixed, array|bool, mixed, array{0: int|string, 1: string}>

See also:

  • \Generator

Generated by danog/phpdoc

completeSignup(string $first_name, string $last_name): \Generator

Complete signup to Telegram.

Parameters:

  • $first_name: string First name
  • $last_name: string Last name

See also:

  • \Generator

Generated by danog/phpdoc

complete2faLogin(string $password): \Generator

Complete 2FA login.

Parameters:

  • $password: string Password

See also:

  • \Generator

Generated by danog/phpdoc

update2fa(array $params): \Generator

Update the 2FA password. The params array can contain password, new_password, email and hint params.

Parameters:

  • $params: array The params

See also:

  • \Generator

Generated by danog/phpdoc

initSelfRestart(): void

Initialize self-restart hack.


Generated by danog/phpdoc

loop(callable|null $callback): \Generator

Start MadelineProto's update handling loop, or run the provided async callable.

Parameters:

  • $callback: callable|null Async callable to run

See also:

  • \Generator

Generated by danog/phpdoc

stop(): void

Stop update loop.


Generated by danog/phpdoc

restart(): void

Restart update loop.


Generated by danog/phpdoc

loopFork(): \Amp\Promise

Start MadelineProto's update handling loop in background.

See also:

  • \Amp\Promise

Generated by danog/phpdoc

closeConnection(string $message): void

Close connection with client, connected via web.

Parameters:

  • $message: string Message

Generated by danog/phpdoc

setNoop(): void

Set NOOP update handler, ignoring all updates.


Generated by danog/phpdoc

start(): \Generator

Log in to telegram (via CLI or web).

See also:

  • \Generator

Generated by danog/phpdoc

getWebTemplate(): string

Get web template.


Generated by danog/phpdoc

setWebTemplate(string $template): void

Set web template.

Parameters:

  • $template: string Template

Generated by danog/phpdoc

checkTos(): \Generator

Check for terms of service update.

See also:

  • \Generator

Generated by danog/phpdoc

acceptTos(): \Generator

Accept terms of service update.

See also:

  • \Generator

Generated by danog/phpdoc

declineTos(): \Generator

Decline terms of service update. THIS WILL DELETE YOUR ACCOUNT!

See also:

  • \Generator

Generated by danog/phpdoc


Generated by danog/phpdoc