1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-02 16:17:46 +01:00
MadelineProto/src/InternalDoc.php

1883 lines
64 KiB
PHP
Raw Normal View History

2023-01-27 14:36:54 +01:00
<?php declare(strict_types=1);
2023-01-27 14:20:47 +01:00
/**
* This file is automatically generated by the build_docs.php file
* and is used only for autocompletion in multiple IDEs
* don't modify it manually.
*/
namespace danog\MadelineProto;
2023-01-27 19:00:11 +01:00
use Amp\ByteStream\WritableStream;
use Amp\Cancellation;
use Amp\Future;
use Amp\Http\Server\Request as ServerRequest;
use Closure;
use Generator;
2023-01-27 14:20:47 +01:00
abstract class InternalDoc
{
2023-01-27 14:36:54 +01:00
protected APIWrapper $wrapper;
2023-02-24 14:51:29 +01:00
/** @var \danog\MadelineProto\Namespace\Auth $auth */
public $auth;
/** @var \danog\MadelineProto\Namespace\Account $account */
public $account;
/** @var \danog\MadelineProto\Namespace\Users $users */
public $users;
/** @var \danog\MadelineProto\Namespace\Contacts $contacts */
public $contacts;
/** @var \danog\MadelineProto\Namespace\Messages $messages */
public $messages;
/** @var \danog\MadelineProto\Namespace\Updates $updates */
public $updates;
/** @var \danog\MadelineProto\Namespace\Photos $photos */
public $photos;
/** @var \danog\MadelineProto\Namespace\Upload $upload */
public $upload;
/** @var \danog\MadelineProto\Namespace\Help $help */
public $help;
/** @var \danog\MadelineProto\Namespace\Channels $channels */
public $channels;
/** @var \danog\MadelineProto\Namespace\Bots $bots */
public $bots;
/** @var \danog\MadelineProto\Namespace\Payments $payments */
public $payments;
/** @var \danog\MadelineProto\Namespace\Stickers $stickers */
public $stickers;
/** @var \danog\MadelineProto\Namespace\Phone $phone */
public $phone;
/** @var \danog\MadelineProto\Namespace\Langpack $langpack */
public $langpack;
/** @var \danog\MadelineProto\Namespace\Folders $folders */
public $folders;
/** @var \danog\MadelineProto\Namespace\Stats $stats */
public $stats;
2023-04-21 17:33:00 +02:00
/** @var \danog\MadelineProto\Namespace\Chatlists $chatlists */
public $chatlists;
2023-01-27 14:20:47 +01:00
2023-01-27 14:36:54 +01:00
/**
* Export APIFactory instance with the specified namespace.
2023-01-27 14:42:41 +01:00
* @psalm-suppress InaccessibleProperty
2023-01-27 14:36:54 +01:00
*/
protected function exportNamespaces(): void
{
$this->auth ??= new \danog\MadelineProto\Namespace\AbstractAPI('auth');
$this->auth->setWrapper($this->wrapper);
$this->account ??= new \danog\MadelineProto\Namespace\AbstractAPI('account');
$this->account->setWrapper($this->wrapper);
$this->users ??= new \danog\MadelineProto\Namespace\AbstractAPI('users');
$this->users->setWrapper($this->wrapper);
$this->contacts ??= new \danog\MadelineProto\Namespace\AbstractAPI('contacts');
$this->contacts->setWrapper($this->wrapper);
$this->messages ??= new \danog\MadelineProto\Namespace\AbstractAPI('messages');
$this->messages->setWrapper($this->wrapper);
$this->updates ??= new \danog\MadelineProto\Namespace\AbstractAPI('updates');
$this->updates->setWrapper($this->wrapper);
$this->photos ??= new \danog\MadelineProto\Namespace\AbstractAPI('photos');
$this->photos->setWrapper($this->wrapper);
$this->upload ??= new \danog\MadelineProto\Namespace\AbstractAPI('upload');
$this->upload->setWrapper($this->wrapper);
$this->help ??= new \danog\MadelineProto\Namespace\AbstractAPI('help');
$this->help->setWrapper($this->wrapper);
$this->channels ??= new \danog\MadelineProto\Namespace\AbstractAPI('channels');
$this->channels->setWrapper($this->wrapper);
$this->bots ??= new \danog\MadelineProto\Namespace\AbstractAPI('bots');
$this->bots->setWrapper($this->wrapper);
$this->payments ??= new \danog\MadelineProto\Namespace\AbstractAPI('payments');
$this->payments->setWrapper($this->wrapper);
$this->stickers ??= new \danog\MadelineProto\Namespace\AbstractAPI('stickers');
$this->stickers->setWrapper($this->wrapper);
$this->phone ??= new \danog\MadelineProto\Namespace\AbstractAPI('phone');
$this->phone->setWrapper($this->wrapper);
$this->langpack ??= new \danog\MadelineProto\Namespace\AbstractAPI('langpack');
$this->langpack->setWrapper($this->wrapper);
$this->folders ??= new \danog\MadelineProto\Namespace\AbstractAPI('folders');
$this->folders->setWrapper($this->wrapper);
$this->stats ??= new \danog\MadelineProto\Namespace\AbstractAPI('stats');
$this->stats->setWrapper($this->wrapper);
2023-04-21 17:33:00 +02:00
$this->chatlists ??= new \danog\MadelineProto\Namespace\AbstractAPI('chatlists');
$this->chatlists->setWrapper($this->wrapper);
2023-01-27 14:36:54 +01:00
}
/**
2023-01-27 14:36:54 +01:00
* Convert MTProto parameters to bot API parameters.
*
* @param array $data Data
*/
2023-01-31 14:11:31 +01:00
public function MTProtoToBotAPI(array $data): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->MTProtoToBotAPI($data);
2023-01-27 14:20:47 +01:00
}
/**
* MTProto to TD params.
*
* @param mixed $params Params
*/
public function MTProtoToTd(mixed &$params)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->MTProtoToTd($params);
2023-01-27 14:20:47 +01:00
}
/**
* MTProto to TDCLI params.
*
* @param mixed $params Params
*/
public function MTProtoToTdcli(mixed $params)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->MTProtoToTdcli($params);
2023-01-27 14:20:47 +01:00
}
/**
* Accept call.
*
* @param array $call Call
*/
2023-01-31 14:11:31 +01:00
public function acceptCall(array $call): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->acceptCall($call);
2023-01-27 14:20:47 +01:00
}
/**
* Accept secret chat.
*
* @param array $params Secret chat ID
*/
2023-01-27 14:36:54 +01:00
public function acceptSecretChat(array $params): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->acceptSecretChat($params);
2023-01-27 14:20:47 +01:00
}
/**
* Call promise $b after promise $a.
*
* @deprecated Coroutines are deprecated since amp v3
2023-01-27 19:00:11 +01:00
* @param Generator|Future $a Promise A
* @param Generator|Future $b Promise B
2023-01-27 14:20:47 +01:00
* @psalm-suppress InvalidScope
*/
public static function after(\Generator|\Amp\Future $a, \Generator|\Amp\Future $b): \Amp\Future
{
return \danog\MadelineProto\AsyncTools::after($a, $b);
}
/**
* Returns a promise that succeeds when all promises succeed, and fails if any promise fails.
* Returned promise succeeds with an array of values used to succeed each contained promise, with keys corresponding to the array of promises.
*
* @deprecated Coroutines are deprecated since amp v3
2023-01-27 19:00:11 +01:00
* @param array<(Generator|Future)> $promises Promises
2023-01-27 14:20:47 +01:00
*/
public static function all(array $promises)
{
return \danog\MadelineProto\AsyncTools::all($promises);
}
/**
* Returns a promise that is resolved when all promises are resolved. The returned promise will not fail.
*
* @deprecated Coroutines are deprecated since amp v3
* @param array<(Future|Generator)> $promises Promises
*/
public static function any(array $promises)
{
return \danog\MadelineProto\AsyncTools::any($promises);
}
/**
* Create array.
*
* @param mixed ...$params Params
*/
public static function arr(mixed ...$params): array
{
return \danog\MadelineProto\Tools::arr(...$params);
}
/**
* base64URL decode.
*
* @param string $data Data to decode
*/
public static function base64urlDecode(string $data): string
{
return \danog\MadelineProto\Tools::base64urlDecode($data);
}
/**
* Base64URL encode.
*
* @param string $data Data to encode
*/
public static function base64urlEncode(string $data): string
{
return \danog\MadelineProto\Tools::base64urlEncode($data);
}
/**
* Convert bot API parameters to MTProto parameters.
*
* @param array $arguments Arguments
*/
2023-01-31 14:11:31 +01:00
public function botAPIToMTProto(array $arguments): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->botAPIToMTProto($arguments);
2023-01-27 14:20:47 +01:00
}
/**
* Login as bot.
*
* @param string $token Bot token
*/
2023-01-31 14:11:31 +01:00
public function botLogin(string $token): ?array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->botLogin($token);
2023-01-27 14:20:47 +01:00
}
2023-05-26 17:54:42 +02:00
/**
* 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.
*
* @param Action $action A custom, serializable Action class that will be called once for every peer.
*/
2023-05-26 21:03:01 +02:00
public function broadcastCustom(\danog\MadelineProto\Broadcast\Action $action, ?\danog\MadelineProto\Broadcast\Filter $filter = null): int
2023-05-07 21:05:11 +02:00
{
2023-05-26 21:03:01 +02:00
return $this->wrapper->getAPI()->broadcastCustom($action, $filter);
2023-05-07 21:05:11 +02:00
}
/**
2023-05-26 17:54:42 +02:00
* 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.
*
* @param mixed $from_peer Bot API ID or Update, from where to forward the messages.
* @param list<int> $message_ids IDs of the messages to forward.
2023-05-26 17:54:42 +02:00
* @param bool $drop_author If true, will forward messages without quoting the original author.
* @param bool $pin Whether to also pin the last sent message.
2023-05-07 21:05:11 +02:00
*/
public function broadcastForwardMessages(mixed $from_peer, array $message_ids, bool $drop_author = false, ?\danog\MadelineProto\Broadcast\Filter $filter = null, bool $pin = false): int
2023-05-07 21:05:11 +02:00
{
return $this->wrapper->getAPI()->broadcastForwardMessages($from_peer, $message_ids, $drop_author, $filter, $pin);
2023-05-07 21:05:11 +02:00
}
2023-05-26 17:54:42 +02:00
/**
* 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.
*
* @param array $messages The messages to send: an array of arrays, containing parameters to pass to messages.sendMessage.
* @param bool $pin Whether to also pin the last sent message.
2023-05-26 17:54:42 +02:00
*/
public function broadcastMessages(array $messages, ?\danog\MadelineProto\Broadcast\Filter $filter = null, bool $pin = false): int
2023-05-07 21:05:11 +02:00
{
return $this->wrapper->getAPI()->broadcastMessages($messages, $filter, $pin);
2023-05-07 21:05:11 +02:00
}
2023-01-27 14:20:47 +01:00
/**
* Convert generator, promise or any other value to a promise.
*
* @deprecated Coroutines are deprecated since amp v3
* @template TReturn
* @param Generator<mixed, mixed, mixed, TReturn>|Future<TReturn>|TReturn $promise
2023-01-27 19:00:11 +01:00
* @return Future<TReturn>
2023-01-27 14:20:47 +01:00
*/
public static function call(mixed $promise): \Amp\Future
{
return \danog\MadelineProto\AsyncTools::call($promise);
}
/**
2023-06-25 16:59:56 +02:00
* Fork a new green thread and execute the passed function in the background.
*
* @template T
*
2023-06-25 17:02:20 +02:00
* @param \Closure(...):T $callable Function to execute
2023-06-25 16:59:56 +02:00
* @param mixed ...$args Arguments forwarded to the function when forking the thread.
*
* @return Future<T>
2023-01-27 14:20:47 +01:00
*
* @psalm-suppress InvalidScope
*/
2023-06-25 17:02:20 +02:00
public static function callFork(\Generator|\Amp\Future|callable $callable, ...$args): \Amp\Future
2023-01-27 14:20:47 +01:00
{
2023-06-25 17:02:20 +02:00
return \danog\MadelineProto\AsyncTools::callFork($callable, ...$args);
2023-01-27 14:20:47 +01:00
}
/**
* Call promise in background, deferring execution.
*
* @deprecated Coroutines are deprecated since amp v3
2023-01-27 19:00:11 +01:00
* @param Generator|Future $promise Promise to resolve
2023-01-27 14:20:47 +01:00
*/
public static function callForkDefer(\Generator|\Amp\Future $promise): void
{
2023-01-27 14:36:54 +01:00
\danog\MadelineProto\AsyncTools::callForkDefer($promise);
2023-01-27 14:20:47 +01:00
}
/**
* Get call status.
*
* @param int $id Call ID
*/
2023-01-31 14:11:31 +01:00
public function callStatus(int $id): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->callStatus($id);
2023-01-27 14:20:47 +01:00
}
2023-05-07 21:05:11 +02:00
/**
* Cancel a running broadcast.
*
* @param integer $id Broadcast ID
*/
public function cancelBroadcast(int $id): void
{
$this->wrapper->getAPI()->cancelBroadcast($id);
}
2023-01-27 14:20:47 +01:00
/**
* Close connection with client, connected via web.
*
* @param string $message Message
*/
public static function closeConnection(string $message): void
{
2023-01-27 14:36:54 +01:00
\danog\MadelineProto\Tools::closeConnection($message);
2023-01-27 14:20:47 +01:00
}
/**
* Complete 2FA login.
*
* @param string $password Password
*/
2023-06-13 16:52:58 +02:00
public function complete2faLogin(string $password): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->complete2faLogin($password);
2023-01-27 14:20:47 +01:00
}
/**
* Complete call handshake.
*
* @param array $params Params
*/
public function completeCall(array $params)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->completeCall($params);
2023-01-27 14:20:47 +01:00
}
/**
* Complet user login using login code.
*
* @param string $code Login code
*/
public function completePhoneLogin(string $code)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->completePhoneLogin($code);
2023-01-27 14:20:47 +01:00
}
/**
* Complete signup to Telegram.
*
* @param string $first_name First name
* @param string $last_name Last name
*/
2023-06-13 16:52:58 +02:00
public function completeSignup(string $first_name, string $last_name = ''): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->completeSignup($first_name, $last_name);
2023-01-27 14:20:47 +01:00
}
/**
* Confirm call.
*
* @param array $params Params
*/
public function confirmCall(array $params)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->confirmCall($params);
2023-01-27 14:20:47 +01:00
}
/**
* Discard call.
*
* @param array $call Call
* @param array $rating Rating
* @param boolean $need_debug Need debug?
*/
2023-01-27 14:36:54 +01:00
public function discardCall(array $call, array $reason, array $rating = [
2023-01-31 14:11:31 +01:00
], bool $need_debug = true): ?\danog\MadelineProto\VoIP
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->discardCall($call, $reason, $rating, $need_debug);
2023-01-27 14:20:47 +01:00
}
/**
* Discard secret chat.
*
* @param int $chat Secret chat ID
*/
2023-01-27 14:36:54 +01:00
public function discardSecretChat(int $chat): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->discardSecretChat($chat);
2023-01-27 14:20:47 +01:00
}
/**
* Download file to browser.
*
* Supports HEAD requests and content-ranges for parallel and resumed downloads.
*
* @param array|string|FileCallbackInterface $messageMedia File to download
* @param null|callable $cb Status callback (can also use FileCallback)
* @param null|int $size Size of file to download, required for bot API file IDs.
* @param null|string $mime MIME type of file to download, required for bot API file IDs.
* @param null|string $name Name of file to download, required for bot API file IDs.
*/
2023-01-27 14:36:54 +01:00
public function downloadToBrowser(\danog\MadelineProto\FileCallbackInterface|array|string $messageMedia, ?callable $cb = null, ?int $size = null, ?string $name = null, ?string $mime = null): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->downloadToBrowser($messageMedia, $cb, $size, $name, $mime);
2023-01-27 14:20:47 +01:00
}
/**
* 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).
*
* @param mixed $messageMedia File to download
* @param callable|FileCallbackInterface $callable Chunk callback
* @param callable $cb Status callback (DEPRECATED, use FileCallbackInterface)
* @param bool $seekable Whether the callable can be called out of order
* @param int $offset Offset where to start downloading
* @param int $end Offset where to stop downloading (inclusive)
* @param int $part_size Size of each chunk
*/
public function downloadToCallable(mixed $messageMedia, callable $callable, ?callable $cb = null, bool $seekable = true, int $offset = 0, int $end = -1, ?int $part_size = null)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->downloadToCallable($messageMedia, $callable, $cb, $seekable, $offset, $end, $part_size);
2023-01-27 14:20:47 +01:00
}
/**
* Download file to directory.
*
* @param mixed $messageMedia File to download
* @param string|FileCallbackInterface $dir Directory where to download the file
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
*/
public function downloadToDir(mixed $messageMedia, \danog\MadelineProto\FileCallbackInterface|string $dir, ?callable $cb = null)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->downloadToDir($messageMedia, $dir, $cb);
2023-01-27 14:20:47 +01:00
}
/**
* Download file.
*
* @param mixed $messageMedia File to download
* @param string|FileCallbackInterface $file Downloaded file path
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
*/
2023-01-31 14:11:31 +01:00
public function downloadToFile(mixed $messageMedia, \danog\MadelineProto\FileCallbackInterface|string $file, ?callable $cb = null): string|false
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->downloadToFile($messageMedia, $file, $cb);
2023-01-27 14:20:47 +01:00
}
/**
* Download file to amphp/http-server response.
*
* Supports HEAD requests and content-ranges for parallel and resumed downloads.
*
* @param array|string|FileCallbackInterface $messageMedia File to download
* @param ServerRequest $request Request
* @param callable $cb Status callback (can also use FileCallback)
* @param null|int $size Size of file to download, required for bot API file IDs.
* @param null|string $name Name of file to download, required for bot API file IDs.
* @param null|string $mime MIME type of file to download, required for bot API file IDs.
*/
2023-01-31 14:11:31 +01:00
public function downloadToResponse(\danog\MadelineProto\FileCallbackInterface|array|string $messageMedia, \Amp\Http\Server\Request $request, ?callable $cb = null, ?int $size = null, ?string $mime = null, ?string $name = null): \Amp\Http\Server\Response
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->downloadToResponse($messageMedia, $request, $cb, $size, $mime, $name);
2023-01-27 14:20:47 +01:00
}
/**
* Download file to stream.
*
* @param mixed $messageMedia File to download
* @param mixed|FileCallbackInterface|resource|WritableStream $stream Stream where to download file
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param int $offset Offset where to start downloading
* @param int $end Offset where to end download
*/
public function downloadToStream(mixed $messageMedia, mixed $stream, ?callable $cb = null, int $offset = 0, int $end = -1)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->downloadToStream($messageMedia, $stream, $cb, $offset, $end);
2023-01-27 14:20:47 +01:00
}
/**
* Asynchronously write to stdout/browser.
*
* @param string $string Message to echo
*/
public static function echo(string $string): void
{
2023-01-27 14:36:54 +01:00
\danog\MadelineProto\AsyncTools::echo($string);
2023-01-27 14:20:47 +01:00
}
/**
* Get final element of array.
*
* @param array $what Array
*/
public static function end(array $what)
{
return \danog\MadelineProto\Tools::end($what);
}
2023-07-07 16:56:03 +02:00
/**
* Convert a message and a set of entities to HTML.
*
* @param bool $allowTelegramTags Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on...
*/
public static function entitiesToHtml(string $message, array $entities, bool $allowTelegramTags = false): string
{
return \danog\MadelineProto\StrTools::entitiesToHtml($message, $entities, $allowTelegramTags);
}
2023-01-27 14:20:47 +01:00
/**
* Export authorization.
*
2023-01-31 14:11:31 +01:00
* @return array{0: (int|string), 1: string}
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function exportAuthorization(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->exportAuthorization();
2023-01-27 14:20:47 +01:00
}
/**
* Extract file info from bot API message.
*
* @param array $info Bot API message object
*/
public static function extractBotAPIFile(array $info): ?array
{
return \danog\MadelineProto\MTProto::extractBotAPIFile($info);
}
/**
* Extract a message constructor from an Updates constructor.
*/
2023-01-31 14:11:31 +01:00
public function extractMessage(array $updates): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->extractMessage($updates);
2023-01-27 14:20:47 +01:00
}
/**
* Extract a message ID from an Updates constructor.
*/
2023-01-31 14:11:31 +01:00
public function extractMessageId(array $updates): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->extractMessageId($updates);
2023-01-27 14:20:47 +01:00
}
/**
* Extract an update message constructor from an Updates constructor.
*/
2023-01-31 14:11:31 +01:00
public function extractMessageUpdate(array $updates): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->extractMessageUpdate($updates);
2023-01-27 14:20:47 +01:00
}
/**
* Extract Update constructors from an Updates constructor.
*
2023-01-31 14:11:31 +01:00
* @return array<array>
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function extractUpdates(array $updates): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->extractUpdates($updates);
2023-01-27 14:20:47 +01:00
}
/**
* Get contents of remote file asynchronously.
*
* @param string $url URL
*/
2023-01-31 14:11:31 +01:00
public function fileGetContents(string $url): string
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->fileGetContents($url);
2023-01-27 14:20:47 +01:00
}
/**
* Returns a promise that succeeds when the first promise succeeds, and fails only if all promises fail.
*
* @deprecated Coroutines are deprecated since amp v3
* @param array<(Future|Generator)> $promises Promises
*/
public static function first(array $promises)
{
return \danog\MadelineProto\AsyncTools::first($promises);
}
/**
* Asynchronously lock a file
* Resolves with a callbable that MUST eventually be called in order to release the lock.
*
* @param string $file File to lock
* @param integer $operation Locking mode
* @param float $polling Polling interval
* @param ?Cancellation $token Cancellation token
* @param ?Closure $failureCb Failure callback, called only once if the first locking attempt fails.
* @return ($token is null ? (Closure(): void) : ((Closure(): void)|null))
*/
public static function flock(string $file, int $operation, float $polling = 0.1, ?\Amp\Cancellation $token = null, ?\Closure $failureCb = null): ?\Closure
{
return \danog\MadelineProto\AsyncTools::flock($file, $operation, $polling, $token, $failureCb);
}
/**
* Convert bot API channel ID to MTProto channel ID.
*
* @param int $id Bot API channel ID
*/
public static function fromSupergroup(int $id): int
{
return \danog\MadelineProto\MTProto::fromSupergroup($id);
}
/**
* When were full info for this chat last cached.
*
* @param mixed $id Chat ID
*/
2023-01-31 14:11:31 +01:00
public function fullChatLastUpdated(mixed $id): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->fullChatLastUpdated($id);
2023-01-27 14:20:47 +01:00
}
/**
* Get info about the logged-in user, not cached.
*/
2023-01-31 14:11:31 +01:00
public function fullGetSelf(): array|false
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->fullGetSelf();
2023-01-27 14:20:47 +01:00
}
/**
* Generate MTProto vector hash.
*
2023-06-13 21:36:04 +02:00
* Returns a vector hash.
*
2023-01-27 14:20:47 +01:00
* @param array $ints IDs
*/
public static function genVectorHash(array $ints): string
{
return \danog\MadelineProto\Tools::genVectorHash($ints);
}
/**
* Obtain the ID of the admin of the bot (equal to the first user ID returned by getReportPeers).
*/
public function getAdmin(): int
{
return $this->wrapper->getAPI()->getAdmin();
}
2023-01-27 14:20:47 +01:00
/**
* Get full list of MTProto and API methods.
*/
2023-01-31 14:11:31 +01:00
public function getAllMethods(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getAllMethods();
2023-01-27 14:20:47 +01:00
}
/**
* Get authorization info.
2023-06-18 22:13:12 +02:00
*
* @return \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
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function getAuthorization(): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getAuthorization();
2023-01-27 14:20:47 +01:00
}
2023-05-07 21:05:11 +02:00
/**
* 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.
*
* @param integer $id Broadcast ID
*/
public function getBroadcastProgress(int $id): ?\danog\MadelineProto\Broadcast\Progress
{
return $this->wrapper->getAPI()->getBroadcastProgress($id);
}
2023-01-27 14:20:47 +01:00
/**
* Get cached server-side config.
*/
2023-01-31 14:11:31 +01:00
public function getCachedConfig(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getCachedConfig();
2023-01-27 14:20:47 +01:00
}
/**
* Get call info.
*
* @param int $call Call ID
*/
2023-01-31 14:11:31 +01:00
public function getCall(int $call): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getCall($call);
2023-01-27 14:20:47 +01:00
}
/**
* Store RSA keys for CDN datacenters.
*/
2023-01-27 14:36:54 +01:00
public function getCdnConfig(): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->getCdnConfig();
2023-01-27 14:20:47 +01:00
}
/**
* Get cached (or eventually re-fetch) server-side config.
*
* @param array $config Current config
*/
2023-01-27 14:36:54 +01:00
public function getConfig(array $config = [
2023-01-31 14:11:31 +01:00
]): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getConfig($config);
2023-01-27 14:20:47 +01:00
}
/**
* Get async DNS client.
*/
2023-01-31 14:11:31 +01:00
public function getDNSClient(): \Amp\Dns\DnsResolver
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getDNSClient();
2023-01-27 14:20:47 +01:00
}
/**
* Get diffie-hellman configuration.
*/
2023-01-31 14:11:31 +01:00
public function getDhConfig(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getDhConfig();
2023-01-27 14:20:47 +01:00
}
2023-01-29 17:51:21 +01:00
/**
* Get dialog IDs.
*
2023-01-31 14:11:31 +01:00
* @return list<int>
2023-01-29 17:51:21 +01:00
*/
2023-01-31 14:11:31 +01:00
public function getDialogIds(): array
2023-01-29 17:51:21 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getDialogIds();
2023-01-29 17:51:21 +01:00
}
2023-01-27 14:20:47 +01:00
/**
* Get dialog peers.
*
2023-01-31 14:11:31 +01:00
* @return list<array>
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function getDialogs(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getDialogs();
2023-01-27 14:20:47 +01:00
}
/**
* 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
*
* @param mixed $messageMedia File ID
2023-07-05 21:28:17 +02:00
*
* @return array{
* ext: string,
* name: string,
* mime: string,
* size: int,
* InputFileLocation: array
* }
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function getDownloadInfo(mixed $messageMedia): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getDownloadInfo($messageMedia);
2023-01-27 14:20:47 +01:00
}
/**
* Get event handler.
*/
public function getEventHandler(): \danog\MadelineProto\EventHandler|\danog\MadelineProto\Ipc\EventHandlerProxy|\__PHP_Incomplete_Class|null
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getEventHandler();
2023-01-27 14:20:47 +01:00
}
/**
* Get extension from file location.
*
* @param mixed $location File location
* @param string $default Default extension
*/
public static function getExtensionFromLocation(mixed $location, string $default): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getExtensionFromLocation($location, $default);
}
/**
* Get extension from mime type.
*
* @param string $mime MIME type
*/
public static function getExtensionFromMime(string $mime): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getExtensionFromMime($mime);
}
/**
* Get info about file.
*
* @param mixed $constructor File ID
*/
2023-01-31 14:11:31 +01:00
public function getFileInfo(mixed $constructor): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getFileInfo($constructor);
2023-01-27 14:20:47 +01:00
}
/**
* Get folder ID from object.
*
* @param mixed $id Object
*/
public static function getFolderId(mixed $id): ?int
{
return \danog\MadelineProto\MTProto::getFolderId($id);
}
/**
* Get full info of all dialogs.
*
2023-01-29 17:51:21 +01:00
* Bots should use getDialogs or getDialogIds, instead.
*
2023-01-31 14:11:31 +01:00
* @return array<int, array>
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function getFullDialogs(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getFullDialogs();
2023-01-27 14:20:47 +01:00
}
/**
* Get full info about peer, returns an FullInfo object.
*
* @param mixed $id Peer
* @see https://docs.madelineproto.xyz/FullInfo.html
*/
2023-01-31 14:11:31 +01:00
public function getFullInfo(mixed $id): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getFullInfo($id);
2023-01-27 14:20:47 +01:00
}
/**
* Get async HTTP client.
*/
2023-01-31 14:11:31 +01:00
public function getHTTPClient(): \Amp\Http\Client\HttpClient
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getHTTPClient();
2023-01-27 14:20:47 +01:00
}
/**
* Get current password hint.
*/
2023-01-31 14:11:31 +01:00
public function getHint(): string
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getHint();
2023-01-27 14:20:47 +01:00
}
/**
* Get the bot API ID of a peer.
2023-01-27 14:20:47 +01:00
*
* @param mixed $id Peer
*/
public function getId(mixed $id): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getId($id);
2023-01-27 14:20:47 +01:00
}
/**
* Get info about peer, returns an Info object.
*
* @param mixed $id Peer
2023-07-04 18:19:06 +02:00
* @param \danog\MadelineProto\API::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
2023-01-27 14:20:47 +01:00
* @see https://docs.madelineproto.xyz/Info.html
2023-07-04 18:19:06 +02:00
* @return ($type is \danog\MadelineProto\API::INFO_TYPE_ALL ? array{
2023-01-27 14:20:47 +01:00
* InputPeer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int},
* Peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int},
* DialogPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* NotifyPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* InputDialogPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* InputNotifyPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* bot_api_id: int|string,
* user_id?: int,
* chat_id?: int,
* channel_id?: int,
* InputUser?: array{_: string, user_id?: int, access_hash?: int, min?: bool},
* InputChannel?: array{_: string, channel_id: int, access_hash: int, min: bool},
* type: string
2023-07-05 21:28:17 +02:00
* } : ($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})))
2023-01-27 14:20:47 +01:00
*/
2023-07-08 22:24:31 +02:00
public function getInfo(mixed $id, int $type = \danog\MadelineProto\API::INFO_TYPE_ALL): array|string|int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getInfo($id, $type);
2023-01-27 14:20:47 +01:00
}
/**
* Get logger.
*/
2023-01-31 14:11:31 +01:00
public function getLogger(): \danog\MadelineProto\Logger
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getLogger();
2023-01-27 14:20:47 +01:00
}
2023-01-27 19:30:08 +01:00
/**
* Get current number of memory-mapped regions, UNIX only.
*/
public static function getMaps(): ?int
{
return \danog\MadelineProto\Tools::getMaps();
}
/**
* Get maximum number of memory-mapped regions, UNIX only.
* Use testFibers to get the maximum number of fibers on any platform.
*/
public static function getMaxMaps(): ?int
{
return \danog\MadelineProto\Tools::getMaxMaps();
}
2023-01-27 14:20:47 +01:00
/**
* Get TL namespaces.
*/
2023-01-31 14:11:31 +01:00
public function getMethodNamespaces(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getMethodNamespaces();
2023-01-27 14:20:47 +01:00
}
/**
* Get namespaced methods (method => namespace).
*/
2023-01-31 14:11:31 +01:00
public function getMethodsNamespaced(): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getMethodsNamespaced();
2023-01-27 14:20:47 +01:00
}
/**
* Get mime type from buffer.
*
* @param string $buffer Buffer
*/
public static function getMimeFromBuffer(string $buffer): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromBuffer($buffer);
}
/**
* Get mime type from file extension.
*
* @param string $extension File extension
* @param string $default Default mime type
*/
public static function getMimeFromExtension(string $extension, string $default): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromExtension($extension, $default);
}
/**
* Get mime type of file.
*
* @param string $file File
*/
public static function getMimeFromFile(string $file): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromFile($file);
}
2023-06-25 19:52:00 +02:00
/**
* Obtain a certain event handler plugin instance.
*
* @template T as EventHandler
*
* @param class-string<T> $class
*
* return T|null
2023-06-25 19:52:00 +02:00
*/
public function getPlugin(string $class): \danog\MadelineProto\PluginEventHandler|\danog\MadelineProto\Ipc\EventHandlerProxy|null
2023-06-25 19:52:00 +02:00
{
return $this->wrapper->getAPI()->getPlugin($class);
2023-06-25 19:52:00 +02:00
}
2023-01-27 14:20:47 +01:00
/**
* 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
*/
2023-01-31 14:11:31 +01:00
public function getPropicInfo($data): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getPropicInfo($data);
2023-01-27 14:20:47 +01:00
}
/**
* Get PSR logger.
*/
2023-01-31 14:11:31 +01:00
public function getPsrLogger(): \Psr\Log\LoggerInterface
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getPsrLogger();
2023-01-27 14:20:47 +01:00
}
/**
* Get full info about peer (including full list of channel members), returns a Chat object.
*
* @param mixed $id Peer
* @see https://docs.madelineproto.xyz/Chat.html
*/
2023-01-31 14:11:31 +01:00
public function getPwrChat(mixed $id, bool $fullfetch = true): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getPwrChat($id, $fullfetch);
2023-01-27 14:20:47 +01:00
}
/**
* Get secret chat.
*
* @param array|int $chat Secret chat ID
*/
2023-01-31 14:11:31 +01:00
public function getSecretChat(array|int $chat): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getSecretChat($chat);
2023-01-27 14:20:47 +01:00
}
/**
* Get info about the logged-in user, cached.
*
* Use fullGetSelf to bypass the cache.
*/
2023-01-31 14:11:31 +01:00
public function getSelf(): array|false
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getSelf();
2023-01-27 14:20:47 +01:00
}
/**
* Returns the session name.
*/
public function getSessionName(): string
{
return $this->wrapper->getAPI()->getSessionName();
}
2023-01-27 14:20:47 +01:00
/**
* Return current settings.
*/
2023-01-31 14:11:31 +01:00
public function getSettings(): \danog\MadelineProto\Settings
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getSettings();
2023-01-27 14:20:47 +01:00
}
/**
* Get sponsored messages for channel.
* This method will return an array of [sponsored message objects](https://docs.madelineproto.xyz/API_docs/constructors/sponsoredMessage.html).
*
* See [the API documentation](https://core.telegram.org/api/sponsored-messages) for more info on how to handle sponsored messages.
*
* @param int|string|array $peer Channel ID, or Update, or Message, or Peer.
*/
2023-05-15 11:42:49 +02:00
public function getSponsoredMessages(array|string|int $peer): ?array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getSponsoredMessages($peer);
2023-01-27 14:20:47 +01:00
}
/**
* Get TL serializer.
*/
2023-06-28 15:50:38 +02:00
public function getTL(): \danog\MadelineProto\TL\TLInterface
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getTL();
2023-01-27 14:20:47 +01:00
}
2023-05-26 21:03:01 +02:00
/**
* Get type of peer.
*
* @param mixed $id Peer
*
2023-06-27 19:47:41 +02:00
* @return \danog\MadelineProto\API::PEER_TYPE_*
2023-05-26 21:03:01 +02:00
*/
public function getType(mixed $id): string
{
return $this->wrapper->getAPI()->getType($id);
}
2023-01-27 14:20:47 +01:00
/**
2023-07-07 16:56:03 +02:00
* 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](#async-event-driven) when writing a MadelineProto bot**, because update handling in the **event handler** is completely parallelized and non-blocking.
2023-01-27 14:20:47 +01:00
*
* @param array{offset?: int, limit?: int, timeout?: float} $params Params
2023-01-31 14:11:31 +01:00
* @return list<array{update_id: mixed, update: mixed}>
2023-01-27 14:20:47 +01:00
*/
2023-01-27 14:36:54 +01:00
public function getUpdates(array $params = [
2023-01-31 14:11:31 +01:00
]): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getUpdates($params);
2023-01-27 14:20:47 +01:00
}
/**
* Get a message to show to the user when starting the bot.
*/
2023-01-31 14:11:31 +01:00
public function getWebMessage(string $message): string
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->getWebMessage($message);
2023-01-27 14:20:47 +01:00
}
/**
* Check if an event handler instance is present.
*/
2023-01-31 14:11:31 +01:00
public function hasEventHandler(): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->hasEventHandler();
2023-01-27 14:20:47 +01:00
}
2023-06-25 19:52:00 +02:00
/**
* Check if a certain event handler plugin is installed.
*
* @param class-string<EventHandler> $class
*/
public function hasPlugin(string $class): bool
2023-06-25 19:52:00 +02:00
{
return $this->wrapper->getAPI()->hasPlugin($class);
2023-06-25 19:52:00 +02:00
}
2023-01-27 14:20:47 +01:00
/**
* Check if has report peers.
*/
2023-01-31 14:11:31 +01:00
public function hasReportPeers(): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->hasReportPeers();
2023-01-27 14:20:47 +01:00
}
/**
* Check whether secret chat exists.
*
* @param array|int $chat Secret chat ID
*/
2023-01-31 14:11:31 +01:00
public function hasSecretChat(array|int $chat): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->hasSecretChat($chat);
2023-01-27 14:20:47 +01:00
}
/**
2023-07-01 14:39:33 +02:00
* Manually convert HTML to a message and a set of entities.
*
* NOTE: You don't have to use this method to send HTML messages.
2023-07-01 18:22:27 +02:00
*
2023-07-01 14:39:33 +02:00
* This method is already called automatically by using parse_mode: "HTML" in messages.sendMessage, messages.sendMedia, et cetera...
*
* @see https://docs.madelineproto.xyz/API_docs/methods/messages.sendMessage.html#usage-of-parse_mode
*
2023-07-05 21:28:17 +02:00
* @return \danog\MadelineProto\TL\Conversion\DOMEntities Object containing message and entities
*/
public static function htmlToMessageEntities(string $html): \danog\MadelineProto\TL\Conversion\DOMEntities
{
return \danog\MadelineProto\StrTools::htmlToMessageEntities($html);
}
2023-01-27 14:20:47 +01:00
/**
* Import authorization.
*
* @param array<int, string> $authorization Authorization info
* @param int $mainDcID Main DC ID
*/
2023-06-13 16:52:58 +02:00
public function importAuthorization(array $authorization, int $mainDcID): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->importAuthorization($authorization, $mainDcID);
2023-01-27 14:20:47 +01:00
}
/**
* Inflate stripped photosize to full JPG payload.
*
* @param string $stripped Stripped photosize
*/
public static function inflateStripped(string $stripped): string
{
return \danog\MadelineProto\Tools::inflateStripped($stripped);
}
2023-04-22 21:44:43 +02:00
/**
* Initialize self-restart hack.
*/
public function initSelfRestart(): void
{
$this->wrapper->getAPI()->initSelfRestart();
}
2023-01-27 14:20:47 +01:00
/**
* Whether this is altervista.
*/
public static function isAltervista(): bool
{
return \danog\MadelineProto\Tools::isAltervista();
}
/**
* Check if is array or similar (traversable && countable && arrayAccess).
*
* @param mixed $var Value to check
*/
public static function isArrayOrAlike(mixed $var): bool
{
return \danog\MadelineProto\Tools::isArrayOrAlike($var);
}
2023-07-01 18:22:27 +02:00
/**
* Check if the specified peer is a forum.
*
*/
public function isForum(mixed $peer): bool
{
return $this->wrapper->getAPI()->isForum($peer);
}
2023-01-27 14:20:47 +01:00
/**
* Whether we're an IPC client instance.
*/
2023-01-31 14:11:31 +01:00
public function isIpc(): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->isIpc();
2023-01-27 14:20:47 +01:00
}
/**
* Whether we're an IPC server process (as opposed to an event handler).
*/
2023-01-31 14:11:31 +01:00
public function isIpcWorker(): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->isIpcWorker();
2023-01-27 14:20:47 +01:00
}
/**
* Returns whether the current user is a premium user, cached.
*/
2023-01-31 14:11:31 +01:00
public function isPremium(): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->isPremium();
2023-01-27 14:20:47 +01:00
}
/**
2023-06-27 19:47:41 +02:00
* Check whether provided bot API ID is a channel or supergroup.
2023-01-27 14:20:47 +01:00
*
* @param int $id Bot API ID
*/
public static function isSupergroup(int $id): bool
{
return \danog\MadelineProto\MTProto::isSupergroup($id);
}
/**
* Logger.
*
* @param mixed $param Parameter
* @param int $level Logging level
* @param string $file File where the message originated
*/
2023-01-27 14:36:54 +01:00
public function logger(mixed $param, int $level = \danog\MadelineProto\Logger::NOTICE, string $file = ''): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->logger($param, $level, $file);
2023-01-27 14:20:47 +01:00
}
/**
* Start MadelineProto's update handling loop, or run the provided async callable.
*
* @deprecated Not needed anymore with amp v3
*
2023-01-27 14:20:47 +01:00
* @param callable|null $callback Async callable to run
*/
public function loop(?callable $callback = null)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->loop($callback);
2023-01-27 14:20:47 +01:00
}
/**
2023-07-01 14:39:33 +02:00
* Manually convert markdown to a message and a set of entities.
*
* NOTE: You don't have to use this method to send Markdown messages.
2023-07-01 18:22:27 +02:00
*
2023-07-01 14:39:33 +02:00
* This method is already called automatically by using parse_mode: "Markdown" in messages.sendMessage, messages.sendMedia, et cetera...
*
* @see https://docs.madelineproto.xyz/API_docs/methods/messages.sendMessage.html#usage-of-parse_mode
*
2023-07-05 21:28:17 +02:00
* @return \danog\MadelineProto\TL\Conversion\DOMEntities Object containing message and entities
*/
public static function markdownToMessageEntities(string $markdown): \danog\MadelineProto\TL\Conversion\DOMEntities
{
return \danog\MadelineProto\StrTools::markdownToMessageEntities($markdown);
}
2023-01-27 14:20:47 +01:00
/**
* Telegram UTF-8 multibyte split.
*
* @param string $text Text
* @param integer $length Length
* @return array<string>
*/
public static function mbStrSplit(string $text, int $length): array
{
return \danog\MadelineProto\StrTools::mbStrSplit($text, $length);
}
/**
* Get Telegram UTF-8 length of string.
*
* @param string $text Text
*/
public static function mbStrlen(string $text): int
{
return \danog\MadelineProto\StrTools::mbStrlen($text);
}
/**
* Telegram UTF-8 multibyte substring.
*
* @param string $text Text to substring
* @param integer $offset Offset
* @param null|int $length Length
*/
public static function mbSubstr(string $text, int $offset, ?int $length = null): string
{
return \danog\MadelineProto\StrTools::mbSubstr($text, $offset, $length);
}
/**
* Convert double to binary version.
*
* @param float $value Value to convert
*/
public static function packDouble(float $value): string
{
return \danog\MadelineProto\Tools::packDouble($value);
}
/**
* Convert integer to base256 signed int.
*
* @param integer $value Value to convert
*/
public static function packSignedInt(int $value): string
{
return \danog\MadelineProto\Tools::packSignedInt($value);
}
/**
* Convert integer to base256 long.
*
* @param int $value Value to convert
*/
public static function packSignedLong(int $value): string
{
return \danog\MadelineProto\Tools::packSignedLong($value);
}
/**
* Convert value to unsigned base256 int.
*
* @param int $value Value
*/
public static function packUnsignedInt(int $value): string
{
return \danog\MadelineProto\Tools::packUnsignedInt($value);
}
/**
* Check if peer is present in internal peer database.
*
* @param mixed $id Peer
*/
2023-01-31 14:11:31 +01:00
public function peerIsset(mixed $id): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->peerIsset($id);
2023-01-27 14:20:47 +01:00
}
/**
* Login as user.
*
* @param string $number Phone number
* @param integer $sms_type SMS type
*/
public function phoneLogin(string $number, int $sms_type = 5)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->phoneLogin($number, $sms_type);
2023-01-27 14:20:47 +01:00
}
/**
* Positive modulo
* Works just like the % (modulus) operator, only returns always a postive number.
*
* @param int $a A
* @param int $b B
*/
public static function posmod(int $a, int $b): int
{
return \danog\MadelineProto\Tools::posmod($a, $b);
}
2023-06-18 22:13:12 +02:00
/**
* 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).
*/
public function qrLogin(): ?\danog\MadelineProto\TL\Types\LoginQrCode
{
return $this->wrapper->getAPI()->qrLogin();
}
2023-01-27 14:20:47 +01:00
/**
2023-06-13 21:36:04 +02:00
* Get secure random string of specified length.
2023-01-27 14:20:47 +01:00
*
* @param integer $length Length
*/
public static function random(int $length): string
{
return \danog\MadelineProto\Tools::random($length);
}
/**
* Get random integer.
*
* @param integer $modulus Modulus
*/
public static function randomInt(int $modulus = 0): int
{
return \danog\MadelineProto\Tools::randomInt($modulus);
}
/**
* Asynchronously read line.
*
* @param string $prompt Prompt
*/
2023-06-18 22:13:12 +02:00
public static function readLine(string $prompt = '', ?\Amp\Cancellation $cancel = null): string
2023-01-27 14:20:47 +01:00
{
2023-06-18 22:13:12 +02:00
return \danog\MadelineProto\AsyncTools::readLine($prompt, $cancel);
2023-01-27 14:20:47 +01:00
}
/**
* Refresh full peer cache for a certain peer.
*
* @param mixed $id The peer to refresh
*/
2023-01-27 14:36:54 +01:00
public function refreshFullPeerCache(mixed $id): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->refreshFullPeerCache($id);
2023-01-27 14:20:47 +01:00
}
/**
* Refresh peer cache for a certain peer.
*
*/
2023-01-27 14:36:54 +01:00
public function refreshPeerCache(mixed ...$ids): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->refreshPeerCache(...$ids);
2023-01-27 14:20:47 +01:00
}
/**
* Rekey secret chat.
*
* @param int $chat Secret chat to rekey
*/
2023-01-31 14:11:31 +01:00
public function rekey(int $chat): ?string
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->rekey($chat);
2023-01-27 14:20:47 +01:00
}
/**
* Report an error to the previously set peer.
*
* @param string $message Error to report
* @param string $parseMode Parse mode
*/
2023-01-27 14:36:54 +01:00
public function report(string $message, string $parseMode = ''): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->report($message, $parseMode);
2023-01-27 14:20:47 +01:00
}
/**
* Report memory profile with memprof.
*/
public function reportMemoryProfile(): void
{
$this->wrapper->getAPI()->reportMemoryProfile();
}
2023-01-27 14:20:47 +01:00
/**
* Request VoIP call.
*
* @param mixed $user User
*/
public function requestCall(mixed $user)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->requestCall($user);
2023-01-27 14:20:47 +01:00
}
/**
* Request secret chat.
*
* @param mixed $user User to start secret chat with
*/
public function requestSecretChat(mixed $user)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->requestSecretChat($user);
2023-01-27 14:20:47 +01:00
}
/**
* Reset the update state and fetch all updates from the beginning.
*/
2023-01-27 14:36:54 +01:00
public function resetUpdateState(): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->resetUpdateState();
2023-01-27 14:20:47 +01:00
}
/**
* Restart update loop.
*/
public function restart(): void
{
$this->wrapper->getAPI()->restart();
}
2023-02-06 20:17:35 +01:00
/**
* Rethrow exception into event loop.
*/
public static function rethrow(\Throwable $e): void
{
\danog\MadelineProto\AsyncTools::rethrow($e);
}
2023-01-27 14:20:47 +01:00
/**
* null-byte RLE decode.
*
* @param string $string Data to decode
*/
public static function rleDecode(string $string): string
{
return \danog\MadelineProto\Tools::rleDecode($string);
}
/**
* null-byte RLE encode.
*
* @param string $string Data to encode
*/
public static function rleEncode(string $string): string
{
return \danog\MadelineProto\Tools::rleEncode($string);
}
/**
* Get secret chat status.
*
* @param int $chat Chat ID
2023-07-04 18:19:06 +02:00
* @return int One of \danog\MadelineProto\API::SECRET_EMPTY, \danog\MadelineProto\API::SECRET_REQUESTED, \danog\MadelineProto\API::SECRET_READY
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function secretChatStatus(int $chat): int
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->secretChatStatus($chat);
2023-01-27 14:20:47 +01:00
}
/**
* Sends an updateCustomEvent update to the event handler.
*/
public function sendCustomEvent(mixed $payload): void
{
$this->wrapper->getAPI()->sendCustomEvent($payload);
}
/**
* Sends a message.
*
* @param integer|string $peer Destination peer or username.
* @param string $message Message to send
* @param "html"|"markdown"|null $parseMode Parse mode
* @param integer|null $replyToMsgId ID of message to reply to.
* @param integer|null $topMsgId ID of thread where to send the message.
* @param array|null $replyMarkup Keyboard information.
* @param integer|null $sendAs Peer to send the message as.
* @param integer|null $scheduleDate Schedule date.
* @param boolean $silent Whether to send the message silently, without triggering notifications.
* @param boolean $background Send this message as background message
* @param boolean $clearDraft Clears the draft field
* @param boolean $noWebpage Set this flag to disable generation of the webpage preview
* @param boolean $updateStickersetsOrder Whether to move used stickersets to top
*
*/
public function sendMessage(string|int $peer, string $message, ?string $parseMode = null, ?int $replyToMsgId = null, ?int $topMsgId = null, ?array $replyMarkup = null, string|int|null $sendAs = null, ?int $scheduleDate = null, bool $silent = false, bool $noForwards = false, bool $background = false, bool $clearDraft = false, bool $noWebpage = false, bool $updateStickersetsOrder = false): \danog\MadelineProto\EventHandler\Message
{
return $this->wrapper->getAPI()->sendMessage($peer, $message, $parseMode, $replyToMsgId, $topMsgId, $replyMarkup, $sendAs, $scheduleDate, $silent, $noForwards, $background, $clearDraft, $noWebpage, $updateStickersetsOrder);
}
2023-01-27 14:20:47 +01:00
/**
* Set NOOP update handler, ignoring all updates.
*/
2023-01-27 14:36:54 +01:00
public function setNoop(): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->setNoop();
2023-01-27 14:20:47 +01:00
}
/**
* Set peer(s) where to send errors occurred in the event loop.
*
* @param int|string|array<int|string> $userOrId Username(s) or peer ID(s)
*/
2023-01-27 14:36:54 +01:00
public function setReportPeers(array|string|int $userOrId): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->setReportPeers($userOrId);
2023-01-27 14:20:47 +01:00
}
/**
* Set webhook update handler.
*
* @param string $webhookUrl Webhook URL
*/
2023-01-27 14:36:54 +01:00
public function setWebhook(string $webhookUrl): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->setWebhook($webhookUrl);
2023-01-27 14:20:47 +01:00
}
/**
* Setup logger.
*/
2023-01-27 14:36:54 +01:00
public function setupLogger(): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->setupLogger();
2023-01-27 14:20:47 +01:00
}
/**
* Asynchronously sleep.
*
* @param float $time Number of seconds to sleep for
*/
public static function sleep(float $time): void
{
2023-01-27 14:36:54 +01:00
\danog\MadelineProto\AsyncTools::sleep($time);
2023-01-27 14:20:47 +01:00
}
/**
* Resolves with a two-item array delineating successful and failed Promise results.
* The returned promise will only fail if the given number of required promises fail.
*
* @deprecated Coroutines are deprecated since amp v3
* @param array<(Future|Generator)> $promises Promises
*/
public static function some(array $promises)
{
return \danog\MadelineProto\AsyncTools::some($promises);
}
/**
* Log in to telegram (via CLI or web).
*/
public function start()
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->start();
2023-01-27 14:20:47 +01:00
}
/**
* Stop update loop.
*/
public function stop(): void
{
$this->wrapper->getAPI()->stop();
}
2023-07-10 10:12:46 +02:00
/**
* Converts a string into an async amphp stream.
*/
public static function stringToStream(string $str): \Amp\ByteStream\ReadableBuffer
{
return \danog\MadelineProto\Tools::stringToStream($str);
}
2023-01-27 14:20:47 +01:00
/**
* Subscribe to event handler updates for a channel/supergroup we're not a member of.
*
2023-05-29 14:46:42 +02:00
* @param mixed $channel Channel/supergroup to subscribe to
*
2023-01-31 14:11:31 +01:00
* @return bool False if we were already subscribed
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function subscribeToUpdates(mixed $channel): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->subscribeToUpdates($channel);
2023-01-27 14:20:47 +01:00
}
/**
* Convert TD to MTProto parameters.
*
* @param array $params Parameters
*/
2023-01-31 14:11:31 +01:00
public function tdToMTProto(array $params): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->tdToMTProto($params);
2023-01-27 14:20:47 +01:00
}
/**
* Convert TD parameters to tdcli.
*
* @param mixed $params Parameters
*/
public function tdToTdcli(mixed $params)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->tdToTdcli($params);
2023-01-27 14:20:47 +01:00
}
/**
* Convert tdcli parameters to tdcli.
*
* @param mixed $params Params
* @param array $key Key
*/
2023-01-31 14:11:31 +01:00
public function tdcliToTd(&$params, ?array $key = null): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->tdcliToTd($params, $key);
2023-01-27 14:20:47 +01:00
}
2023-01-27 19:30:08 +01:00
/**
* Test fibers.
*
* @return array{maxFibers: int, realMemoryMb: int, maps: ?int, maxMaps: ?int}
*/
public static function testFibers(int $fiberCount = 100000): array
{
return \danog\MadelineProto\Tools::testFibers($fiberCount);
}
2023-01-27 14:20:47 +01:00
/**
2023-01-27 19:00:11 +01:00
* Create an artificial timeout for any Generator or Promise.
2023-01-27 14:20:47 +01:00
*
* @deprecated Coroutines are deprecated since amp v3
* @param int $timeout In milliseconds
*/
public static function timeout(\Generator|\Amp\Future $promise, int $timeout): mixed
{
return \danog\MadelineProto\AsyncTools::timeout($promise, $timeout);
}
/**
* Creates an artificial timeout for any `Promise`.
*
* If the promise is resolved before the timeout expires, the result is returned
*
* If the timeout expires before the promise is resolved, a default value is returned
*
* @deprecated Coroutines are deprecated since amp v3
* @template TReturnAlt
* @template TReturn
2023-01-27 19:00:11 +01:00
* @template TGenerator of Generator<mixed, mixed, mixed, TReturn>
* @param Future<TReturn>|TGenerator $promise Promise to which the timeout is applied.
2023-01-27 14:20:47 +01:00
* @param int $timeout Timeout in milliseconds.
* @param TReturnAlt $default
* @return TReturn|TReturnAlt
*/
public static function timeoutWithDefault($promise, int $timeout, $default = null): mixed
{
return \danog\MadelineProto\AsyncTools::timeoutWithDefault($promise, $timeout, $default);
}
/**
* Convert to camelCase.
*
* @param string $input String
*/
public static function toCamelCase(string $input): string
{
return \danog\MadelineProto\StrTools::toCamelCase($input);
}
/**
* Convert to snake_case.
*
* @param string $input String
*/
public static function toSnakeCase(string $input): string
{
return \danog\MadelineProto\StrTools::toSnakeCase($input);
}
/**
* Convert MTProto channel ID to bot API channel ID.
*
* @param int $id MTProto channel ID
*/
public static function toSupergroup(int $id): int
{
return \danog\MadelineProto\MTProto::toSupergroup($id);
}
/**
* Unpack binary double.
*
* @param string $value Value to unpack
*/
public static function unpackDouble(string $value): float
{
return \danog\MadelineProto\Tools::unpackDouble($value);
}
/**
* Unpack bot API file ID.
*
* @param string $fileId Bot API file ID
2023-01-31 14:11:31 +01:00
* @return array Unpacked file ID
2023-01-27 14:20:47 +01:00
*/
2023-01-31 14:11:31 +01:00
public function unpackFileId(string $fileId): array
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->unpackFileId($fileId);
2023-01-27 14:20:47 +01:00
}
/**
* Unpack base256 signed int.
*
* @param string $value base256 int
*/
public static function unpackSignedInt(string $value): int
{
return \danog\MadelineProto\Tools::unpackSignedInt($value);
}
/**
* Unpack base256 signed long.
*
* @param string $value base256 long
*/
public static function unpackSignedLong(string $value): int
{
return \danog\MadelineProto\Tools::unpackSignedLong($value);
}
/**
* Unpack base256 signed long to string.
*
* @param string|int|array $value base256 long
*/
public static function unpackSignedLongString(array|string|int $value): string
{
return \danog\MadelineProto\Tools::unpackSignedLongString($value);
}
/**
* Unset event handler.
*
*/
2023-01-27 14:36:54 +01:00
public function unsetEventHandler(): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->unsetEventHandler();
2023-01-27 14:20:47 +01:00
}
/**
* Update the 2FA password.
*
* The params array can contain password, new_password, email and hint params.
*
2023-02-04 19:18:08 +01:00
* @param array{password?: string, new_password?: string, email?: string, hint?: string} $params The params
2023-01-27 14:20:47 +01:00
*/
2023-01-27 14:36:54 +01:00
public function update2fa(array $params): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->update2fa($params);
2023-01-27 14:20:47 +01:00
}
/**
* Parse, update and store settings.
*
* @param SettingsAbstract $settings Settings
*/
2023-01-27 14:36:54 +01:00
public function updateSettings(\danog\MadelineProto\SettingsAbstract $settings): void
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
$this->wrapper->getAPI()->updateSettings($settings);
2023-01-27 14:20:47 +01:00
}
/**
* Upload file.
*
* @param FileCallbackInterface|LocalFile|string|array|resource $file File, URL or Telegram file to upload
* @param string $fileName File name
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param boolean $encrypted Whether to encrypt file for secret chats
2023-01-27 14:20:47 +01:00
*/
public function upload($file, string $fileName = '', ?callable $cb = null, bool $encrypted = false)
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->upload($file, $fileName, $cb, $encrypted);
2023-01-27 14:20:47 +01:00
}
/**
* Upload file to secret chat.
*
* @param FileCallbackInterface|string|array $file File, URL or Telegram file to upload
* @param string $fileName File name
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
*/
public function uploadEncrypted(\danog\MadelineProto\FileCallbackInterface|array|string $file, string $fileName = '', ?callable $cb = null)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->uploadEncrypted($file, $fileName, $cb);
2023-01-27 14:20:47 +01:00
}
/**
* 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.
*
* @param mixed $callable Callable
* @param integer $size File size
* @param string $mime Mime type
* @param string $fileName File name
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param boolean $seekable Whether chunks can be fetched out of order
* @param boolean $encrypted Whether to encrypt file for secret chats
*/
public function uploadFromCallable(callable $callable, int $size, string $mime, string $fileName = '', ?callable $cb = null, bool $seekable = true, bool $encrypted = false)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->uploadFromCallable($callable, $size, $mime, $fileName, $cb, $seekable, $encrypted);
2023-01-27 14:20:47 +01:00
}
/**
* Upload file from stream.
*
* @param mixed $stream PHP resource or AMPHP async stream
* @param integer $size File size
* @param string $mime Mime type
* @param string $fileName File name
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param boolean $encrypted Whether to encrypt file for secret chats
*/
public function uploadFromStream(mixed $stream, int $size, string $mime, string $fileName = '', ?callable $cb = null, bool $encrypted = false)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->uploadFromStream($stream, $size, $mime, $fileName, $cb, $encrypted);
2023-01-27 14:20:47 +01:00
}
/**
* Reupload telegram file.
*
* @param mixed $media Telegram file
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param boolean $encrypted Whether to encrypt file for secret chats
*/
public function uploadFromTgfile(mixed $media, ?callable $cb = null, bool $encrypted = false)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->uploadFromTgfile($media, $cb, $encrypted);
2023-01-27 14:20:47 +01:00
}
/**
* Upload file from URL.
*
* @param string|FileCallbackInterface $url URL of file
* @param integer $size Size of file
* @param string $fileName File name
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
* @param boolean $encrypted Whether to encrypt file for secret chats
*/
public function uploadFromUrl(\danog\MadelineProto\FileCallbackInterface|string $url, int $size = 0, string $fileName = '', ?callable $cb = null, bool $encrypted = false)
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->uploadFromUrl($url, $size, $fileName, $cb, $encrypted);
2023-01-27 14:20:47 +01:00
}
/**
* Mark sponsored message as read.
*
* @param int|array $peer Channel ID, or Update, or Message, or Peer.
* @param string|array{random_id: string} $message Random ID or sponsored message to mark as read.
*/
2023-01-31 14:11:31 +01:00
public function viewSponsoredMessage(array|int $peer, array|string $message): bool
2023-01-27 14:20:47 +01:00
{
2023-01-31 14:11:31 +01:00
return $this->wrapper->getAPI()->viewSponsoredMessage($peer, $message);
2023-01-27 14:20:47 +01:00
}
/**
* Synchronously wait for a Future|generator.
*
* @deprecated Coroutines are deprecated since amp v3
2023-01-27 19:00:11 +01:00
* @param Generator|Future $promise The promise to wait for
2023-01-27 14:20:47 +01:00
*/
public static function wait(\Generator|\Amp\Future $promise)
{
return \danog\MadelineProto\AsyncTools::wait($promise);
}
2023-07-05 21:28:17 +02:00
/**
* Wrap a media constructor into an abstract Media object.
*/
2023-07-07 16:56:03 +02:00
public function wrapMedia(array $media): ?\danog\MadelineProto\EventHandler\Media
2023-07-05 21:28:17 +02:00
{
return $this->wrapper->getAPI()->wrapMedia($media);
}
/**
* Wrap a Message constructor into an abstract Message object.
*/
public function wrapMessage(array $message): ?\danog\MadelineProto\EventHandler\Message
{
return $this->wrapper->getAPI()->wrapMessage($message);
}
/**
* Wrap an Update constructor into an abstract Update object.
*/
public function wrapUpdate(array $update): ?\danog\MadelineProto\EventHandler\Update
{
return $this->wrapper->getAPI()->wrapUpdate($update);
}
2023-01-27 14:36:54 +01:00
}