Link Search Menu Expand Document

danog\MadelineProto\PluginEventHandler

Back to index

Author: Daniil Gentili daniil@daniil.it

Plugin event handler class.

Properties

  • $auth: \danog\MadelineProto\Namespace\Auth
  • $account: \danog\MadelineProto\Namespace\Account
  • $users: \danog\MadelineProto\Namespace\Users
  • $contacts: \danog\MadelineProto\Namespace\Contacts
  • $messages: \danog\MadelineProto\Namespace\Messages
  • $updates: \danog\MadelineProto\Namespace\Updates
  • $photos: \danog\MadelineProto\Namespace\Photos
  • $upload: \danog\MadelineProto\Namespace\Upload
  • $help: \danog\MadelineProto\Namespace\Help
  • $channels: \danog\MadelineProto\Namespace\Channels
  • $bots: \danog\MadelineProto\Namespace\Bots
  • $payments: \danog\MadelineProto\Namespace\Payments
  • $stickers: \danog\MadelineProto\Namespace\Stickers
  • $phone: \danog\MadelineProto\Namespace\Phone
  • $langpack: \danog\MadelineProto\Namespace\Langpack
  • $folders: \danog\MadelineProto\Namespace\Folders
  • $stats: \danog\MadelineProto\Namespace\Stats
  • $chatlists: \danog\MadelineProto\Namespace\Chatlists
  • $stories: \danog\MadelineProto\Namespace\Stories
  • $premium: \danog\MadelineProto\Namespace\Premium
  • $smsjobs: \danog\MadelineProto\Namespace\Smsjobs
  • $fragment: \danog\MadelineProto\Namespace\Fragment

Method list:

Methods:

getPluginPaths(): array|string|null

Plugins can require other plugins ONLY with the getPlugins() method.

isPluginEnabled(): bool

Whether the plugin is enabled.

startAndLoop(string $session, ?\danog\MadelineProto\SettingsAbstract $settings = NULL): void

Start MadelineProto and the event handler.

Also initializes error reporting, catching and reporting all errors surfacing from the event loop.

Parameters:

  • $session: string Session name
  • $settings: ?\danog\MadelineProto\SettingsAbstract Settings

See also:

  • \danog\MadelineProto\SettingsAbstract

startAndLoopBot(string $session, string $token, ?\danog\MadelineProto\SettingsAbstract $settings = NULL): void

Start MadelineProto as a bot and the event handler.

Also initializes error reporting, catching and reporting all errors surfacing from the event loop.

Parameters:

  • $session: string Session name
  • $token: string Bot token
  • $settings: ?\danog\MadelineProto\SettingsAbstract Settings

See also:

  • \danog\MadelineProto\SettingsAbstract

getPeriodicLoop(string $name): ?\danog\Loop\PeriodicLoop

Obtain a PeriodicLoop instance created by the Cron attribute.

Parameters:

  • $name: string Method name

See also:

  • \danog\Loop\PeriodicLoop

getPeriodicLoops(): array<string, \danog\Loop\PeriodicLoop>

Obtain all PeriodicLoop instances created by the Cron attribute.

See also:

  • \danog\Loop\PeriodicLoop

getReportPeers(): (string|int|array<(string|int)>)

Get peers where to send error reports.

getPlugins(): array<class-string<\danog\MadelineProto\EventHandler>>

Obtain a list of plugin event handlers to use, in addition with those found by getPluginPath.

MTProtoToBotAPI(array $data): array

Convert MTProto parameters to bot API parameters.

Parameters:

  • $data: array Data

MTProtoToTd(mixed $params): array

MTProto to TD params.

Parameters:

  • $params: mixed Params

MTProtoToTdcli(mixed $params): array

MTProto to TDCLI params.

Parameters:

  • $params: mixed Params

acceptCall(int $id): void

Accept call.

Parameters:

  • $id: int

acceptSecretChat(array $params): void

Accept secret chat.

Parameters:

  • $params: array Secret chat ID

arr(mixed ...$params): array

Create array.

Parameters:

  • ...$params: mixed Params

base64urlDecode(string $data): string

base64URL decode.

Parameters:

  • $data: string Data to decode

base64urlEncode(string $data): string

Base64URL encode.

Parameters:

  • $data: string Data to encode

botAPIToMTProto(array $arguments): array

Convert bot API parameters to MTProto parameters.

Parameters:

  • $arguments: array Arguments

botLogin(string $token): ?array

Login as bot.

Parameters:

  • $token: string Bot token

broadcastCustom(\danog\MadelineProto\Broadcast\Action $action, ?\danog\MadelineProto\Broadcast\Filter $filter = NULL, (float|null) $delay = NULL): int

Executes a custom broadcast action with all peers (users, chats, channels) of the bot.

Will return an integer ID that can be used to:

  • Get the current broadcast progress with getBroadcastProgress
  • Cancel the broadcast using cancelBroadcast

Note that to avoid manually polling the progress,
MadelineProto will also periodically emit updateBroadcastProgress updates,
containing a Progress object for all broadcasts currently in-progress.

Parameters:

  • $action: \danog\MadelineProto\Broadcast\Action A custom, serializable Action class that will be called once for every peer.
  • $filter: ?\danog\MadelineProto\Broadcast\Filter
  • $delay: (float|null) Number of seconds to wait between each peer.

See also:

broadcastForwardMessages(mixed $from_peer, list<int> $message_ids, bool $drop_author = false, ?\danog\MadelineProto\Broadcast\Filter $filter = NULL, bool $pin = false, (float|null) $delay = NULL): int

Forwards a list of messages to all peers (users, chats, channels) of the bot.

Will return an integer ID that can be used to:

  • Get the current broadcast progress with getBroadcastProgress
  • Cancel the broadcast using cancelBroadcast

Note that to avoid manually polling the progress,
MadelineProto will also periodically emit updateBroadcastProgress updates,
containing a Progress object for all broadcasts currently in-progress.

Parameters:

  • $from_peer: mixed Bot API ID or Update, from where to forward the messages.
  • $message_ids: list<int> IDs of the messages to forward.
  • $drop_author: bool If true, will forward messages without quoting the original author.
  • $filter: ?\danog\MadelineProto\Broadcast\Filter
  • $pin: bool Whether to also pin the last sent message.
  • $delay: (float|null) Number of seconds to wait between each peer.

See also:

broadcastMessages(array $messages, ?\danog\MadelineProto\Broadcast\Filter $filter = NULL, bool $pin = false, (float|null) $delay = NULL): int

Sends a list of messages to all peers (users, chats, channels) of the bot.

A simplified version of this method is also available: broadcastForwardMessages can work with pre-prepared messages.

Will return an integer ID that can be used to:

  • Get the current broadcast progress with getBroadcastProgress
  • Cancel the broadcast using cancelBroadcast

Note that to avoid manually polling the progress,
MadelineProto will also periodically emit updateBroadcastProgress updates,
containing a Progress object for all broadcasts currently in-progress.

Parameters:

  • $messages: array The messages to send: an array of arrays, containing parameters to pass to messages.sendMessage.
  • $filter: ?\danog\MadelineProto\Broadcast\Filter
  • $pin: bool Whether to also pin the last sent message.
  • $delay: (float|null) Number of seconds to wait between each peer.

See also:

callFork(\Generator|\Amp\Future|callable $callable, mixed ...$args): \Amp\Future<T>

Fork a new green thread and execute the passed function in the background.

Parameters:

  • $callable: \Generator|\Amp\Future|callable
  • ...$args: mixed Arguments forwarded to the function when forking the thread.

See also:

  • \Generator
  • \Amp\Future

callGetCurrent(int $id): \danog\MadelineProto\RemoteUrl|\danog\MadelineProto\LocalFile|string|null

Get the file that is currently being played.

Will return a string with the object ID of the stream if we’re currently playing a stream, otherwise returns the related LocalFile or RemoteUrl.

Parameters:

  • $id: int

See also:

callPlay(int $id, \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream $file): void

Play file in call.

Parameters:

  • $id: int
  • $file: \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream

See also:

callPlayOnHold(int $id, \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream ...$files): void

Play files on hold in call.

Parameters:

  • $id: int
  • ...$files: \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream

See also:

callSetOutput(int $id, \danog\MadelineProto\LocalFile|\Amp\ByteStream\WritableStream $file): void

Set output file or stream for incoming OPUS audio packets in a call.

Will write an OGG OPUS stream to the specified file or stream.

Parameters:

  • $id: int
  • $file: \danog\MadelineProto\LocalFile|\Amp\ByteStream\WritableStream

See also:

canConvertOgg(): bool

Whether we can convert any audio/video file to a VoIP OGG OPUS file, or the files must be preconverted using @libtgvoipbot.

canUseFFmpeg(?\Amp\Cancellation $cancellation = NULL): bool

Whether we can convert any audio/video file using ffmpeg.

Parameters:

  • $cancellation: ?\Amp\Cancellation

See also:

  • \Amp\Cancellation

cancelBroadcast(integer $id): void

Cancel a running broadcast.

Parameters:

  • $id: integer Broadcast ID

closeConnection(string $message): void

Close connection with client, connected via web.

Parameters:

  • $message: string Message

complete2faLogin(string $password): array

Complete 2FA login.

Parameters:

  • $password: string Password

completePhoneLogin(string $code): array

Complet user login using login code.

Parameters:

  • $code: string Login code

completeSignup(string $first_name, string $last_name = ''): array

Complete signup to Telegram.

Parameters:

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

discardCall(int $id, \danog\MadelineProto\VoIP\DiscardReason $reason = \danog\MadelineProto\VoIP\DiscardReason::HANGUP, int<1, 5> $rating = NULL, string $comment = NULL): void

Discard call.

Parameters:

  • $id: int
  • $reason: \danog\MadelineProto\VoIP\DiscardReason
  • $rating: int<1, 5> Call rating in stars
  • $comment: string Additional comment on call quality.

See also:

discardSecretChat(int $chat, bool $deleteHistory = false): void

Discard secret chat.

Parameters:

  • $chat: int Secret chat ID
  • $deleteHistory: bool If true, deletes the entire chat history for the other user as well.

downloadServer(string $session): void

Downloads a file to the browser using the specified session file.

Parameters:

  • $session: string

downloadToBrowser((array|string|\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message) $messageMedia, (null|callable) $cb = NULL, (null|int) $size = NULL, (null|string) $name = NULL, (null|string) $mime = NULL, ?\Amp\Cancellation $cancellation = NULL): void

Download file to browser.

Supports HEAD requests and content-ranges for parallel and resumed downloads.

Parameters:

  • $messageMedia: (array|string|\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message) File to download
  • $cb: (null|callable) Status callback (can also use FileCallback)
  • $size: (null|int) Size of file to download, required for bot API file IDs.
  • $name: (null|string) Name of file to download, required for bot API file IDs.
  • $mime: (null|string) MIME type of file to download, required for bot API file IDs.
  • $cancellation: ?\Amp\Cancellation

See also:

downloadToCallable(mixed $messageMedia, (callable|\danog\MadelineProto\FileCallbackInterface) $callable, callable $cb = NULL, bool $seekable = true, int $offset = 0, int $end = -1, int $part_size = NULL, ?\Amp\Cancellation $cancellation = NULL): void

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

Parameters:

  • $messageMedia: mixed File to download
  • $callable: (callable|\danog\MadelineProto\FileCallbackInterface) Chunk callback
  • $cb: callable Status callback
  • $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
  • $cancellation: ?\Amp\Cancellation

See also:

downloadToDir(mixed $messageMedia, (string|\danog\MadelineProto\FileCallbackInterface) $dir, callable $cb = NULL, ?\Amp\Cancellation $cancellation = NULL): non-empty-string

Download file to directory.

Parameters:

  • $messageMedia: mixed File to download
  • $dir: (string|\danog\MadelineProto\FileCallbackInterface) Directory where to download the file
  • $cb: callable Callback
  • $cancellation: ?\Amp\Cancellation

Return value: Downloaded file name

See also:

downloadToFile(mixed $messageMedia, (string|\danog\MadelineProto\FileCallbackInterface) $file, callable $cb = NULL, ?\Amp\Cancellation $cancellation = NULL): non-empty-string

Download file.

Parameters:

  • $messageMedia: mixed File to download
  • $file: (string|\danog\MadelineProto\FileCallbackInterface) Downloaded file path
  • $cb: callable Callback
  • $cancellation: ?\Amp\Cancellation

Return value: Downloaded file name

See also:

downloadToResponse((array|string|\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message) $messageMedia, \Amp\Http\Server\Request $request, callable $cb = NULL, (null|int) $size = NULL, (null|string) $mime = NULL, (null|string) $name = NULL, ?\Amp\Cancellation $cancellation = NULL): \Amp\Http\Server\Response

Download file to amphp/http-server response.

Supports HEAD requests and content-ranges for parallel and resumed downloads.

Parameters:

  • $messageMedia: (array|string|\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message) File to download
  • $request: \Amp\Http\Server\Request Request
  • $cb: callable Status callback (can also use FileCallback)
  • $size: (null|int) Size of file to download, required for bot API file IDs.
  • $mime: (null|string) MIME type of file to download, required for bot API file IDs.
  • $name: (null|string) Name of file to download, required for bot API file IDs.
  • $cancellation: ?\Amp\Cancellation

See also:

downloadToReturnedStream(mixed $messageMedia, callable $cb = NULL, int $offset = 0, int $end = -1, ?\Amp\Cancellation $cancellation = NULL): \Amp\ByteStream\ReadableStream

Download file to an amphp stream, returning it.

Parameters:

  • $messageMedia: mixed File to download
  • $cb: callable Callback
  • $offset: int Offset where to start downloading
  • $end: int Offset where to end download
  • $cancellation: ?\Amp\Cancellation

See also:

  • \Amp\Cancellation
  • \Amp\ByteStream\ReadableStream

downloadToStream(mixed $messageMedia, (mixed|\danog\MadelineProto\FileCallbackInterface|resource|\Amp\ByteStream\WritableStream) $stream, callable $cb = NULL, int $offset = 0, int $end = -1, ?\Amp\Cancellation $cancellation = NULL): void

Download file to stream.

Parameters:

  • $messageMedia: mixed File to download
  • $stream: (mixed|\danog\MadelineProto\FileCallbackInterface|resource|\Amp\ByteStream\WritableStream) Stream where to download file
  • $cb: callable Callback
  • $offset: int Offset where to start downloading
  • $end: int Offset where to end download
  • $cancellation: ?\Amp\Cancellation

See also:

echo(string $string): void

Asynchronously write to stdout/browser.

Parameters:

  • $string: string Message to echo

end(array<T> $what): T

Get final element of array.

Parameters:

  • $what: array<T> Array

entitiesToHtml(string $message, list<(\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity|array{_: string, offset: int, length: int})> $entities, bool $allowTelegramTags = false): string

Convert a message and a set of entities to HTML.

Parameters:

  • $message: string
  • $entities: list<(\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity|array{_: string, offset: int, length: int})>
  • $allowTelegramTags: bool Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on…

See also:

exportAuthorization(): array{0: (int|string), 1: string}

Export authorization.

extractBotAPIFile(array $info): ?array

Extract file info from bot API message.

Parameters:

  • $info: array Bot API message object

extractMessage(array $updates): array

Extract a message constructor from an Updates constructor.

Parameters:

  • $updates: array

extractMessageId(array $updates): int

Extract a message ID from an Updates constructor.

Parameters:

  • $updates: array

extractMessageUpdate(array $updates): array

Extract an update message constructor from an Updates constructor.

Parameters:

  • $updates: array

extractUpdates(array $updates): array<array>

Extract Update constructors from an Updates constructor.

Parameters:

  • $updates: array

fileGetContents(string $url): string

Get contents of remote file asynchronously.

Parameters:

  • $url: string URL

flock(string $file, integer $operation, float $polling = 0.1, ?\Amp\Cancellation $token = NULL, ?\Closure $failureCb = NULL): ($token is null ? Closure(): void : (Closure(): void | null))

Asynchronously lock a file Resolves with a callbable that MUST eventually be called in order to release the lock.

Parameters:

  • $file: string File to lock
  • $operation: integer Locking mode
  • $polling: float Polling interval
  • $token: ?\Amp\Cancellation Cancellation token
  • $failureCb: ?\Closure Failure callback, called only once if the first locking attempt fails.

See also:

  • \Amp\Cancellation
  • \Closure

fullChatLastUpdated(mixed $id): int

When was full info for this chat last cached.

Parameters:

  • $id: mixed Chat ID

fullGetSelf(): array|false

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

genVectorHash(array $longs): string

Generate MTProto vector hash.

Returns a vector hash.

Parameters:

  • $longs: array IDs

getAdminIds(): array

Get admin IDs (equal to all user report peers).

getAllCalls(): array<int, \danog\MadelineProto\VoIP>

Get all pending and running calls, indexed by user ID.

See also:

getAllMethods(): array

Get full list of MTProto and API methods.

getAuthorization(): (\danog\MadelineProto\API::NOT_LOGGED_IN|\danog\MadelineProto\API::WAITING_CODE|\danog\MadelineProto\API::WAITING_SIGNUP|\danog\MadelineProto\API::WAITING_PASSWORD|\danog\MadelineProto\API::LOGGED_IN|API::LOGGED_OUT)

Get authorization info.

See also:

  • \danog\MadelineProto\API::NOT_LOGGED_IN
  • \danog\MadelineProto\API::WAITING_CODE
  • \danog\MadelineProto\API::WAITING_SIGNUP
  • \danog\MadelineProto\API::WAITING_PASSWORD
  • \danog\MadelineProto\API::LOGGED_IN
  • API::LOGGED_OUT

getBroadcastProgress(integer $id): ?\danog\MadelineProto\Broadcast\Progress

Get the progress of a currently running broadcast.

Will return null if the broadcast doesn’t exist, has already completed or was cancelled.

Use updateBroadcastProgress updates to get real-time progress status without polling.

Parameters:

  • $id: integer Broadcast ID

See also:

getCachedConfig(): array

Get cached server-side config.

getCall(int $id): ?\danog\MadelineProto\VoIP

Get phone call information.

Parameters:

  • $id: int

See also:

getCallByPeer(int $userId): ?\danog\MadelineProto\VoIP

Get the phone call with the specified user ID.

Parameters:

  • $userId: int

See also:

getCallState(int $id): ?\danog\MadelineProto\VoIP\CallState

Get call state.

Parameters:

  • $id: int

See also:

getCdnConfig(): void

Store RSA keys for CDN datacenters.

getConfig(array $config = []): array

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

Parameters:

  • $config: array Current config

getDNSClient(): \Amp\Dns\DnsResolver

Get async DNS client.

See also:

  • \Amp\Dns\DnsResolver

getDhConfig(): array

Get diffie-hellman configuration.

getDialogIds(): list<int>

Get dialog IDs.

getDownloadInfo(mixed $messageMedia): array{ext: string, name: string, mime: string, size: int, InputFileLocation: array, key_fingerprint?: string, key?: string, iv?: string, thumb_size?: string}

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

Get download link of media file.

Parameters:

  • $media: \danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|array|string
  • $scriptUrl: ?string
  • $size: ?int
  • $name: ?string
  • $mime: ?string

See also:

getEventHandler((class-string<T>|null) $class = NULL): (T|\danog\MadelineProto\Ipc\EventHandlerProxy|\__PHP_Incomplete_Class|null)

Get event handler (or plugin instance).

Parameters:

  • $class: (class-string<T>|null)

See also:

  • \danog\MadelineProto\Ipc\EventHandlerProxy
  • \__PHP_Incomplete_Class

getExtensionFromLocation(mixed $location, string $default): string

Get extension from file location.

Parameters:

  • $location: mixed File location
  • $default: string Default extension

getExtensionFromMime(string $mime): string

Get extension from mime type.

Parameters:

  • $mime: string MIME type

getFileInfo(mixed $constructor): array

Get info about file.

Parameters:

  • $constructor: mixed File ID

getFullDialogs(): array<int, array>

Get full info of all dialogs.

Bots should use getDialogIds, instead.

getFullInfo(mixed $id): array

Get full info about peer, returns an FullInfo object.

Parameters:

  • $id: mixed Peer

See also:

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

Get async HTTP client.

See also:

  • \Amp\Http\Client\HttpClient

getHint(): string

Get current password hint.

getId(mixed $id): int

Get the bot API ID of a peer.

Parameters:

  • $id: mixed Peer

getInfo(mixed $id, \danog\MadelineProto\API::INFO_TYPE_* $type = \danog\MadelineProto\API::INFO_TYPE_ALL): (\$type is \danog\MadelineProto\API::INFO_TYPE_ALL ? array{User?: array, Chat?: array, bot_api_id: int, user_id?: int, chat_id?: int, channel_id?: int, type: string} : ($type is API::INFO_TYPE_TYPE ? string : ($type is \danog\MadelineProto\API::INFO_TYPE_ID ? int : (array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int} | array{_: string, user_id?: int, access_hash?: int, min?: bool} | array{_: string, channel_id: int, access_hash: int, min: bool}))))

Get info about peer, returns an Info object.

If passed a secret chat ID, returns information about the user, not about the secret chat.
Use getSecretChat to return information about the secret chat.

Parameters:

  • $id: mixed Peer
  • $type: \danog\MadelineProto\API::INFO_TYPE_* Whether to generate an Input*, an InputPeer or the full set of constructors

See also:

getLogger(): \danog\MadelineProto\Logger

Get logger.

See also:

getMaps(): ?int

Get current number of memory-mapped regions, UNIX only.

getMaxMaps(): ?int

Get maximum number of memory-mapped regions, UNIX only. Use testFibers to get the maximum number of fibers on any platform.

getMemoryProfile(): string

Get memory profile with memprof.

getMethodNamespaces(): array

Get TL namespaces.

getMethodsNamespaced(): array

Get namespaced methods (method => namespace).

getMimeFromBuffer(string $buffer): string

Get mime type from buffer.

Parameters:

  • $buffer: string Buffer

getMimeFromExtension(string $extension, string $default): string

Get mime type from file extension.

Parameters:

  • $extension: string File extension
  • $default: string Default mime type

getMimeFromFile(string $file): string

Get mime type of file.

Parameters:

  • $file: string File

getPlugin(class-string<T> $class): \danog\MadelineProto\PluginEventHandler|\danog\MadelineProto\Ipc\EventHandlerProxy|null

Obtain a certain event handler plugin instance.

Parameters:

  • $class: class-string<T>

return T|null

See also:

getPromCounter(string $namespace, string $name, string $help, array<string, string> $labels = []): ?\danog\BetterPrometheus\BetterCounter

Creates and returns a prometheus counter.

Returns null if prometheus stats are disabled.

Parameters:

  • $namespace: string
  • $name: string
  • $help: string
  • $labels: array<string, string>

See also:

  • \danog\BetterPrometheus\BetterCounter

getPromGauge(string $namespace, string $name, string $help, array<string, string> $labels = []): ?\danog\BetterPrometheus\BetterGauge

Creates and returns a prometheus gauge.

Returns null if prometheus stats are disabled.

Parameters:

  • $namespace: string
  • $name: string
  • $help: string
  • $labels: array<string, string>

See also:

  • \danog\BetterPrometheus\BetterGauge

getPromHistogram(string $namespace, string $name, string $help, array<string, string> $labels = [], ?non-empty-list<float> $buckets = NULL): ?\danog\BetterPrometheus\BetterHistogram

Creates and returns a prometheus histogram.

Returns null if prometheus stats are disabled.

Parameters:

  • $namespace: string
  • $name: string
  • $help: string
  • $labels: array<string, string>
  • $buckets: ?non-empty-list<float>

See also:

  • non-empty-list
  • \danog\BetterPrometheus\BetterHistogram

getPromSummary(string $namespace, string $name, string $help, array<string, string> $labels = [], int $maxAgeSeconds = 600, ?non-empty-list<float> $quantiles = NULL): ?\danog\BetterPrometheus\BetterSummary

Creates and returns a prometheus summary.

Returns null if prometheus stats are disabled.

Parameters:

  • $namespace: string
  • $name: string
  • $help: string
  • $labels: array<string, string>
  • $maxAgeSeconds: int
  • $quantiles: ?non-empty-list<float>

See also:

  • non-empty-list
  • \danog\BetterPrometheus\BetterSummary

getPropicInfo(mixed $data): ?\danog\MadelineProto\EventHandler\Media\Photo

Gets info of the propic of a user.

Parameters:

  • $data: mixed

See also:

getPsrLogger(): \Psr\Log\LoggerInterface

Get PSR logger.

See also:

  • \Psr\Log\LoggerInterface

getPwrChat(mixed $id, bool $fullfetch = true): array

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

Parameters:

  • $id: mixed Peer
  • $fullfetch: bool

See also:

getSecretChat((array|int) $chat): \danog\MadelineProto\SecretChats\SecretChat

Get secret chat.

Parameters:

  • $chat: (array|int) Secret chat ID

See also:

getSecretMessage(integer $chatId, integer $randomId): \danog\MadelineProto\EventHandler\Message\SecretMessage

Gets a secret chat message.

Parameters:

  • $chatId: integer Secret chat ID.
  • $randomId: integer Secret chat message ID.

See also:

getSelf(): array|false

Get info about the logged-in user, cached.

Use fullGetSelf to bypass the cache.

getSessionName(): string

Returns the session name.

getSettings(): \danog\MadelineProto\Settings

Return current settings.

See also:

getSponsoredMessages((int|string|array) $peer): ?array

Get sponsored messages for channel. This method will return an array of sponsored message objects.

See the API documentation for more info on how to handle sponsored messages.

Parameters:

  • $peer: (int|string|array) Channel ID, or Update, or Message, or Peer.

getStream(\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream $stream, ?\Amp\Cancellation $cancellation = NULL, ?int $size = NULL): \Amp\ByteStream\ReadableStream

Provide a stream for a file, URL or amp stream.

Parameters:

  • $stream: \danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream
  • $cancellation: ?\Amp\Cancellation
  • $size: ?int

See also:

getStreamPipe(): \Amp\ByteStream\Pipe

Obtains a pipe that can be used to upload a file from a stream.

See also:

  • \Amp\ByteStream\Pipe

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

Get TL serializer.

See also:

getType(mixed $id): \danog\MadelineProto\API::PEER_TYPE_*

Get type of peer.

Parameters:

  • $id: mixed Peer

See also:

  • \danog\MadelineProto\API::PEER_TYPE_*

getUpdates(array{offset?: int, limit?: int, timeout?: float} $params = []): list<array{update_id: mixed, update: mixed}>

Only useful when consuming MadelineProto updates through an API in another language (like Javascript), absolutely not recommended when directly writing MadelineProto bots.

getUpdates will greatly slow down your bot if used directly inside of PHP code.

Only use the event handler when writing a MadelineProto bot, because update handling in the event handler is completely parallelized and non-blocking.

Parameters:

  • $params: array{offset?: int, limit?: int, timeout?: float} Params

getWebMessage(string $message): string

Get a message to show to the user when starting the bot.

Parameters:

  • $message: string

getWebWarnings(): string

Get various warnings to show to the user in the web UI.

hasAdmins(): bool

Check if has admins.

hasEventHandler(): bool

Check if an event handler instance is present.

hasPlugin(class-string<\danog\MadelineProto\EventHandler> $class): bool

Check if a certain event handler plugin is installed.

Parameters:

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

See also:

hasReportPeers(): bool

Check if has report peers.

hasSecretChat((array|int) $chat): bool

Check whether secret chat exists.

Parameters:

  • $chat: (array|int) Secret chat ID

htmlEscape(string $what): string

Escape string for MadelineProto’s HTML entity converter.

Parameters:

  • $what: string String to escape

htmlToMessageEntities(string $html): \danog\MadelineProto\TextEntities

Manually convert HTML to a message and a set of entities.

NOTE: You don’t have to use this method to send HTML messages.

This method is already called automatically by using parse_mode: “HTML” in messages.sendMessage, messages.sendMedia, et cetera…

Parameters:

  • $html: string

Return value: Object containing message and entities

See also:

importAuthorization(array<int, string> $authorization, int $mainDcID): array

Import authorization.

Parameters:

  • $authorization: array<int, string> Authorization info
  • $mainDcID: int Main DC ID

inflateStripped(string $stripped): string

Inflate stripped photosize to full JPG payload.

Parameters:

  • $stripped: string Stripped photosize

initSelfRestart(): void

Initialize self-restart hack.

isAltervista(): bool

Whether this is altervista.

isArrayOrAlike(mixed $var): bool

Check if is array or similar (traversable && countable && arrayAccess).

Parameters:

  • $var: mixed Value to check

isBot(mixed $peer): bool

Check if the specified peer is a bot.

Parameters:

  • $peer: mixed

isForum(mixed $peer): bool

Check if the specified peer is a forum.

Parameters:

  • $peer: mixed

isIpc(): bool

Whether we’re an IPC client instance.

isIpcWorker(): bool

Whether we’re an IPC server process (as opposed to an event handler).

isPlayPaused(int $id): bool

Whether the currently playing audio file is paused.

Parameters:

  • $id: int

isPremium(): bool

Returns whether the current user is a premium user, cached.

isSelfBot(): bool

Returns whether the current user is a bot.

isSelfUser(): bool

Returns whether the current user is a user.

isTestMode(): boolean

Whether we’re currently connected to the test DCs.

logger(mixed $param, int $level = \danog\MadelineProto\Logger::NOTICE, string $file = ''): void

Logger.

Parameters:

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

logout(): void

Logout the session.

markdownCodeEscape(string $what): string

Escape string for markdown code section.

Parameters:

  • $what: string String to escape

markdownCodeblockEscape(string $what): string

Escape string for markdown codeblock.

Parameters:

  • $what: string String to escape

markdownEscape(string $what): string

Escape string for markdown.

Parameters:

  • $what: string String to escape

markdownToMessageEntities(string $markdown): \danog\MadelineProto\TextEntities

Manually convert markdown to a message and a set of entities.

NOTE: You don’t have to use this method to send Markdown messages.

This method is already called automatically by using parse_mode: “Markdown” in messages.sendMessage, messages.sendMedia, et cetera…

Parameters:

  • $markdown: string

Return value: Object containing message and entities

See also:

markdownUrlEscape(string $what): string

Escape string for URL.

Parameters:

  • $what: string String to escape

mbStrSplit(string $text, integer $length): array<string>

Telegram UTF-8 multibyte split.

Parameters:

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

mbStrlen(string $text): int

Get Telegram UTF-8 length of string.

Parameters:

  • $text: string Text

mbSubstr(string $text, integer $offset, (null|int) $length = NULL): string

Telegram UTF-8 multibyte substring.

Parameters:

  • $text: string Text to substring
  • $offset: integer Offset
  • $length: (null|int) Length

openBuffered(\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream $stream, ?\Amp\Cancellation $cancellation = NULL): Closure(int): ?string

Provide a buffered reader for a file, URL or amp stream.

Parameters:

  • $stream: \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream
  • $cancellation: ?\Amp\Cancellation

See also:

openFileAppendOnly(string $path): \Amp\File\File

Opens a file in append-only mode.

Parameters:

  • $path: string File path.

See also:

  • \Amp\File\File

packDouble(float $value): string

Convert double to binary version.

Parameters:

  • $value: float Value to convert

packSignedInt(integer $value): string

Convert integer to base256 signed int.

Parameters:

  • $value: integer Value to convert

packSignedLong(int $value): string

Convert integer to base256 long.

Parameters:

  • $value: int Value to convert

packUnsignedInt(int $value): string

Convert value to unsigned base256 int.

Parameters:

  • $value: int Value

pausePlay(int $id): void

Pauses playback of the current audio file in the call.

Parameters:

  • $id: int

peerIsset(mixed $id): bool

Check if peer is present in internal peer database.

Parameters:

  • $id: mixed Peer

phoneLogin(string $number, integer $sms_type = 5): array

Login as user.

Parameters:

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

posmod(int $a, int $b): int

Positive modulo Works just like the % (modulus) operator, only returns always a postive number.

Parameters:

  • $a: int A
  • $b: int B

processDownloadServerPing(string $path, string $payload): void

Internal endpoint used by the download server.

Parameters:

  • $path: string
  • $payload: string

qrLogin(): ?\danog\MadelineProto\TL\Types\LoginQrCode

Initiates QR code login.

Returns a QR code login helper object, that can be used to render the QR code, display the link directly, wait for login, QR code expiration and much more.

Returns null if we’re already logged in, or if we’re waiting for a password (use getAuthorization to distinguish between the two cases).

See also:

random(integer $length): string

Get secure random string of specified length.

Parameters:

  • $length: integer Length

randomInt(integer $modulus = 0): int

Get random integer.

Parameters:

  • $modulus: integer Modulus

readLine(string $prompt = '', ?\Amp\Cancellation $cancel = NULL): string

Asynchronously read line.

Parameters:

  • $prompt: string Prompt
  • $cancel: ?\Amp\Cancellation

See also:

  • \Amp\Cancellation

refreshFullPeerCache(mixed $id): void

Refresh full peer cache for a certain peer.

Parameters:

  • $id: mixed The peer to refresh

refreshPeerCache(mixed ...$ids): void

Refresh peer cache for a certain peer.

Parameters:

  • ...$ids: mixed

renderPromStats(?\Prometheus\RendererInterface $renderer = NULL): string

Renders prometheus stats using the specified renderer.

By default uses the text renderer.

Parameters:

  • $renderer: ?\Prometheus\RendererInterface

See also:

  • \Prometheus\RendererInterface

report(string $message, string $parseMode = ''): void

Report an error to the previously set peer.

Parameters:

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

reportMemoryProfile(): void

Report memory profile with memprof.

requestCall(mixed $user): \danog\MadelineProto\VoIP

Request VoIP call.

Parameters:

  • $user: mixed User

See also:

requestSecretChat(mixed $user): int

Request secret chat.

Parameters:

  • $user: mixed User to start secret chat with

resetUpdateState(): void

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

restart(): void

Restart update loop.

resumePlay(int $id): void

Resumes playback of the current audio file in the call.

Parameters:

  • $id: int

rethrow(Throwable $e): void

Rethrow exception into event loop.

Parameters:

  • $e: Throwable

See also:

  • Throwable

rleDecode(string $string): string

null-byte RLE decode.

Parameters:

  • $string: string Data to decode

rleEncode(string $string): string

null-byte RLE encode.

Parameters:

  • $string: string Data to encode

sendAudio((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) $thumb = NULL, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, ?string $mimeType = NULL, (integer|null) $duration = NULL, (string|null) $title = NULL, (string|null) $performer = NULL, ?int $ttl = NULL, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|string|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, boolean $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $forceResend = false, ?\Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends an audio.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $thumb: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) Optional: Thumbnail to upload
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $mimeType: ?string
  • $duration: (integer|null) Duration of the audio
  • $title: (string|null) Title of the audio
  • $performer: (string|null) Performer of the audio
  • $ttl: ?int
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|string|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: boolean Whether to disable forwards for this message.
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: ?\Amp\Cancellation Cancellation.

See also:

sendCustomEvent(mixed $payload): void

Sends an updateCustomEvent update to the event handler.

Parameters:

  • $payload: mixed

sendDocument((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) $thumb = NULL, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, ?string $mimeType = NULL, ?int $ttl = NULL, bool $spoiler = false, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, bool $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $updateStickersetsOrder = false, boolean $forceResend = false, \Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a document.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $thumb: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) Optional: Thumbnail to upload
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $mimeType: ?string
  • $ttl: ?int
  • $spoiler: bool
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: bool
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $updateStickersetsOrder: boolean Whether to move used stickersets to top
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: \Amp\Cancellation Cancellation.

See also:

sendDocumentPhoto((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, ?int $ttl = NULL, bool $spoiler = false, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, bool $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $updateStickersetsOrder = false, boolean $forceResend = false, \Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a photo.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $ttl: ?int
  • $spoiler: bool
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: bool
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $updateStickersetsOrder: boolean Whether to move used stickersets to top
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: \Amp\Cancellation Cancellation.

See also:

sendGif((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) $thumb = NULL, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, (integer|null) $ttl = NULL, boolean $spoiler = false, ?int $duration = NULL, ?int $width = NULL, ?int $height = NULL, string $thumbSeek = '00:00:01.000', (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|string|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, boolean $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $forceResend = false, ?\Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a gif.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $thumb: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) Optional: Thumbnail to upload
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $ttl: (integer|null) Time to live
  • $spoiler: boolean Whether the message is a spoiler
  • $duration: ?int
  • $width: ?int
  • $height: ?int
  • $thumbSeek: string
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|string|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: boolean Whether to disable forwards for this message.
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: ?\Amp\Cancellation Cancellation.

See also:

sendMessage((integer|string) $peer, string $message, \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, bool $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $noWebpage = false, boolean $updateStickersetsOrder = false, ?\Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a message.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $message: string Message to send
  • $parseMode: \danog\MadelineProto\ParseMode Parse mode
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: bool
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $noWebpage: boolean Set this flag to disable generation of the webpage preview
  • $updateStickersetsOrder: boolean Whether to move used stickersets to top
  • $cancellation: ?\Amp\Cancellation Cancellation

See also:

sendMessageToAdmins(string $message, \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, (array|null) $replyMarkup = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, bool $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $noWebpage = false, ?\Amp\Cancellation $cancellation = NULL): list<\danog\MadelineProto\EventHandler\Message>

Sends a message to all report peers (admins of the bot).

Parameters:

  • $message: string Message to send
  • $parseMode: \danog\MadelineProto\ParseMode Parse mode
  • $replyMarkup: (array|null) Keyboard information.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: bool
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $noWebpage: boolean Set this flag to disable generation of the webpage preview
  • $cancellation: ?\Amp\Cancellation

See also:

sendPhoto((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, ?int $ttl = NULL, bool $spoiler = false, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, bool $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $updateStickersetsOrder = false, boolean $forceResend = false, \Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a photo.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $ttl: ?int
  • $spoiler: bool
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: bool
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $updateStickersetsOrder: boolean Whether to move used stickersets to top
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: \Amp\Cancellation Cancellation.

See also:

sendSticker((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, string $mimeType, string $emoji = '', array $stickerSet = [ '_' => 'inputStickerSetEmpty',], ?callable $callback = NULL, ?string $fileName = NULL, ?int $ttl = NULL, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, boolean $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $updateStickersetsOrder = false, boolean $forceResend = false, \Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a sticker.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $mimeType: string
  • $emoji: string
  • $stickerSet: array
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $ttl: ?int
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: boolean Whether to disable forwards for this message.
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $updateStickersetsOrder: boolean Whether to move used stickersets to top
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: \Amp\Cancellation Cancellation.

See also:

sendVideo((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) $thumb = NULL, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, string $mimeType = 'video/mp4', (integer|null) $ttl = NULL, boolean $spoiler = false, boolean $roundMessage = false, boolean $supportsStreaming = true, boolean $noSound = false, (integer|null) $duration = NULL, (integer|null) $width = NULL, (integer|null) $height = NULL, string $thumbSeek = '00:00:01.000', (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|string|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, boolean $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $forceResend = false, bool $updateStickersetsOrder = false, \Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a video.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $thumb: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|null) Optional: Thumbnail to upload
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $mimeType: string
  • $ttl: (integer|null) Time to live
  • $spoiler: boolean Whether the message is a spoiler
  • $roundMessage: boolean Whether the message should be round
  • $supportsStreaming: boolean Whether the video supports streaming
  • $noSound: boolean Whether the video has no sound
  • $duration: (integer|null) Duration of the video
  • $width: (integer|null) Width of the video
  • $height: (integer|null) Height of the video
  • $thumbSeek: string
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|string|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: boolean Whether to disable forwards for this message.
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $updateStickersetsOrder: bool
  • $cancellation: \Amp\Cancellation Cancellation.

See also:

sendVoice((integer|string) $peer, (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) $file, string $caption = '', \danog\MadelineProto\ParseMode $parseMode = \danog\MadelineProto\ParseMode::TEXT, ?callable $callback = NULL, ?string $fileName = NULL, (integer|null) $ttl = NULL, (integer|null) $duration = NULL, (array|null) $waveform = NULL, (integer|null) $replyToMsgId = NULL, (integer|null) $topMsgId = NULL, (array|null) $replyMarkup = NULL, (integer|string|null) $sendAs = NULL, (integer|null) $scheduleDate = NULL, boolean $silent = false, boolean $noForwards = false, boolean $background = false, boolean $clearDraft = false, boolean $forceResend = false, ?\Amp\Cancellation $cancellation = NULL): \danog\MadelineProto\EventHandler\Message

Sends a voice.

Please use named arguments to call this method.

Parameters:

  • $peer: (integer|string) Destination peer or username.
  • $file: (\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream) File to upload: can be a message to reuse media present in a message.
  • $caption: string Caption of document
  • $parseMode: \danog\MadelineProto\ParseMode Text parse mode for the caption
  • $callback: ?callable
  • $fileName: ?string Optional file name, if absent will be extracted from the passed $file.
  • $ttl: (integer|null) Time to live
  • $duration: (integer|null) Duration of the voice
  • $waveform: (array|null) Waveform of the voice
  • $replyToMsgId: (integer|null) ID of message to reply to.
  • $topMsgId: (integer|null) ID of thread where to send the message.
  • $replyMarkup: (array|null) Keyboard information.
  • $sendAs: (integer|string|null) Peer to send the message as.
  • $scheduleDate: (integer|null) Schedule date.
  • $silent: boolean Whether to send the message silently, without triggering notifications.
  • $noForwards: boolean Whether to disable forwards for this message.
  • $background: boolean Send this message as background message
  • $clearDraft: boolean Clears the draft field
  • $forceResend: boolean Whether to forcefully resend the file, even if its type and name are the same.
  • $cancellation: ?\Amp\Cancellation Cancellation.

See also:

setNoop(): void

Set NOOP update handler, ignoring all updates.

setReportPeers((int|string|array<(int|string)>) $userOrId): void

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

Parameters:

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

setWebhook(string $webhookUrl): void

Set webhook update handler.

Parameters:

  • $webhookUrl: string Webhook URL

skipPlay(int $id): void

When called, skips to the next file in the playlist.

Parameters:

  • $id: int

sleep(float $time): void

Asynchronously sleep.

Parameters:

  • $time: float Number of seconds to sleep for

start(): array

Log in to telegram (via CLI or web).

stop(): void

Stop update loop.

stopPlay(int $id): void

Stops playing all files in the call, clears the main and the hold playlist.

Parameters:

  • $id: int

stringToStream(string $str): \Amp\ByteStream\ReadableBuffer

Converts a string into an async amphp stream.

Parameters:

  • $str: string

See also:

  • \Amp\ByteStream\ReadableBuffer

subscribeToUpdates(mixed $channel): bool

Subscribe to event handler updates for a channel/supergroup we’re not a member of.

Parameters:

  • $channel: mixed Channel/supergroup to subscribe to

Return value: False if we were already subscribed

tdToMTProto(array $params): array

Convert TD to MTProto parameters.

Parameters:

  • $params: array Parameters

tdToTdcli(mixed $params): array

Convert TD parameters to tdcli.

Parameters:

  • $params: mixed Parameters

tdcliToTd(mixed $params, array $key = NULL): array

Convert tdcli parameters to tdcli.

Parameters:

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

testFibers(int $fiberCount = 100000): array{maxFibers: int, realMemoryMb: int, maps: ?int, maxMaps: ?int}

Test fibers.

Parameters:

  • $fiberCount: int

toCamelCase(string $input): string

Convert to camelCase.

Parameters:

  • $input: string String

toSnakeCase(string $input): string

Convert to snake_case.

Parameters:

  • $input: string String

unpackDouble(string $value): float

Unpack binary double.

Parameters:

  • $value: string Value to unpack

unpackFileId(string $fileId): array

Unpack bot API file ID.

Parameters:

  • $fileId: string Bot API file ID

Return value: Unpacked file ID

unpackSignedInt(string $value): int

Unpack base256 signed int.

Parameters:

  • $value: string base256 int

unpackSignedLong(string $value): int

Unpack base256 signed long.

Parameters:

  • $value: string base256 long

unpackSignedLongString((string|int|array) $value): string

Unpack base256 signed long to string.

Parameters:

  • $value: (string|int|array) base256 long

unsetEventHandler(): void

Unset event handler.

update2fa(array{password?: string, new_password?: string, email?: string, hint?: string} $params): void

Update the 2FA password.

The params array can contain password, new_password, email and hint params.

Parameters:

  • $params: array{password?: string, new_password?: string, email?: string, hint?: string} The params

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

Parse, update and store settings.

Parameters:

  • $settings: \danog\MadelineProto\SettingsAbstract Settings

See also:

  • \danog\MadelineProto\SettingsAbstract

upload((\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|string|array|resource) $file, string $fileName = '', callable $cb = NULL, boolean $encrypted = false, ?\Amp\Cancellation $cancellation = NULL): array

Upload file.

Parameters:

  • $file: (\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|\Amp\ByteStream\ReadableStream|string|array|resource) File, URL or Telegram file to upload
  • $fileName: string File name
  • $cb: callable Callback
  • $encrypted: boolean Whether to encrypt file for secret chats
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

uploadEncrypted((\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|string|array|resource) $file, string $fileName = '', callable $cb = NULL, ?\Amp\Cancellation $cancellation = NULL): array

Upload file to secret chat.

Parameters:

  • $file: (\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\danog\MadelineProto\BotApiFileId|string|array|resource) File, URL or Telegram file to upload
  • $fileName: string File name
  • $cb: callable Callback
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

uploadFromCallable(callable(int, int, ?Cancellation): strin) $callable, integer $size = 0, string $mime = 'application/octet-stream', string $fileName = '', callable(float, float, float): voi) $cb = NULL, boolean $seekable = true, boolean $encrypted = false, ?\Amp\Cancellation $cancellation = NULL): array

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: callable(int, int, ?Cancellation): strin) Callable (offset, length) => data
  • $size: integer File size
  • $mime: string Mime type
  • $fileName: string File name
  • $cb: callable(float, float, float): voi) Status callback
  • $seekable: boolean Whether chunks can be fetched out of order
  • $encrypted: boolean Whether to encrypt file for secret chats
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

  • \Amp\Cancellation

uploadFromStream(mixed $stream, integer $size = 0, string $mime = 'application/octet-stream', string $fileName = '', callable $cb = NULL, boolean $encrypted = false, ?\Amp\Cancellation $cancellation = NULL): array

Upload file from stream.

Parameters:

  • $stream: mixed PHP resource or AMPHP async stream
  • $size: integer File size
  • $mime: string Mime type
  • $fileName: string File name
  • $cb: callable Callback
  • $encrypted: boolean Whether to encrypt file for secret chats
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

  • \Amp\Cancellation

uploadFromTgfile(mixed $media, callable $cb = NULL, boolean $encrypted = false, ?\Amp\Cancellation $cancellation = NULL): array

Reupload telegram file.

Parameters:

  • $media: mixed Telegram file
  • $cb: callable Callback
  • $encrypted: boolean Whether to encrypt file for secret chats
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

  • \Amp\Cancellation

uploadFromUrl((string|\danog\MadelineProto\FileCallbackInterface) $url, integer $size = 0, string $fileName = '', callable $cb = NULL, boolean $encrypted = false, ?\Amp\Cancellation $cancellation = NULL): array

Upload file from URL.

Parameters:

  • $url: (string|\danog\MadelineProto\FileCallbackInterface) URL of file
  • $size: integer Size of file
  • $fileName: string File name
  • $cb: callable Callback
  • $encrypted: boolean Whether to encrypt file for secret chats
  • $cancellation: ?\Amp\Cancellation

Return value: InputFile constructor

See also:

validateEventHandlerClass(class-string<\danog\MadelineProto\EventHandler> $class): list<\danog\MadelineProto\EventHandlerIssue>

Perform static analysis on a certain event handler class, to make sure it satisfies some performance requirements.

Parameters:

  • $class: class-string<\danog\MadelineProto\EventHandler> Class name

See also:

viewSponsoredMessage((int|array) $peer, (string|array{random_id: string}) $message): bool

Mark sponsored message as read.

Parameters:

  • $peer: (int|array) Channel ID, or Update, or Message, or Peer.
  • $message: (string|array{random_id: string}) Random ID or sponsored message to mark as read.

wrapMedia(array $media, bool $protected = false): ?\danog\MadelineProto\EventHandler\Media

Wrap a media constructor into an abstract Media object.

Parameters:

  • $media: array
  • $protected: bool

See also:

wrapMessage(array $message, bool $scheduled = false): ?\danog\MadelineProto\EventHandler\AbstractMessage

Wrap a Message constructor into an abstract Message object.

Parameters:

  • $message: array
  • $scheduled: bool

See also:

wrapPin(array $message): ?\danog\MadelineProto\EventHandler\Pinned

Wrap a Pin constructor into an abstract Pinned object.

Parameters:

  • $message: array

See also:

wrapUpdate(array $update): ?\danog\MadelineProto\EventHandler\Update

Wrap an Update constructor into an abstract Update object.

Parameters:

  • $update: array

See also:

initDbProperties(\danog\AsyncOrm\Settings $settings, string $tablePrefix): void

Initialize database properties.

Parameters:

  • $settings: \danog\AsyncOrm\Settings
  • $tablePrefix: string

See also:

  • \danog\AsyncOrm\Settings

saveDbProperties(): void

Save all properties.


Generated by danog/phpdoc