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:20:47 +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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Add user info.
|
|
|
|
*
|
|
|
|
* @param array $user User info
|
|
|
|
*/
|
2023-01-27 14:36:54 +01:00
|
|
|
public function addUser(array $user): void
|
2023-01-27 14:20:47 +01:00
|
|
|
{
|
2023-01-31 14:11:31 +01:00
|
|
|
$this->wrapper->getAPI()->addUser($user);
|
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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Call promise in background.
|
|
|
|
*
|
|
|
|
* @deprecated Coroutines are deprecated since amp v3
|
2023-01-27 19:00:11 +01:00
|
|
|
* @param Generator|Future $promise Promise to resolve
|
|
|
|
* @param ?\Generator|Future $actual Promise to resolve instead of $promise
|
2023-01-27 14:20:47 +01:00
|
|
|
* @param string $file File
|
|
|
|
* @psalm-suppress InvalidScope
|
|
|
|
*/
|
|
|
|
public static function callFork(\Generator|\Amp\Future $promise, $actual = null, string $file = ''): mixed
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\AsyncTools::callFork($promise, $actual, $file);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
public function complete2faLogin(string $password)
|
|
|
|
{
|
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
|
|
|
|
*/
|
|
|
|
public function completeSignup(string $first_name, string $last_name = '')
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Connects to all datacenters and if necessary creates authorization keys, binds them and writes client info.
|
|
|
|
*
|
|
|
|
* @param boolean $reconnectAll Whether to reconnect to all DCs
|
|
|
|
*/
|
2023-01-27 14:36:54 +01:00
|
|
|
public function connectToAllDcs(bool $reconnectAll = true): void
|
2023-01-27 14:20:47 +01:00
|
|
|
{
|
2023-01-31 14:11:31 +01:00
|
|
|
$this->wrapper->getAPI()->connectToAllDcs($reconnectAll);
|
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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param array $ints IDs
|
|
|
|
* @return string Vector hash
|
|
|
|
*/
|
|
|
|
public static function genVectorHash(array $ints): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\Tools::genVectorHash($ints);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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-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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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-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.
|
|
|
|
*/
|
2023-01-31 14:11:31 +01:00
|
|
|
public function getEventHandler(): \danog\MadelineProto\EventHandler|\__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
|
|
|
}
|
|
|
|
/**
|
2023-04-22 20:22:17 +02:00
|
|
|
* Get the bot API ID of a peer.
|
2023-01-27 14:20:47 +01:00
|
|
|
*
|
|
|
|
* @param mixed $id Peer
|
|
|
|
*/
|
2023-04-22 20:22:17 +02:00
|
|
|
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
|
|
|
|
* @param MTProto::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
|
|
|
|
* @see https://docs.madelineproto.xyz/Info.html
|
2023-01-31 14:11:31 +01:00
|
|
|
* @return ($type is MTProto::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-01-27 14:42:41 +01:00
|
|
|
* } : ($type is MTProto::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-01-31 14:11:31 +01:00
|
|
|
public function getInfo(mixed $id, int $type = \danog\MadelineProto\MTProto::INFO_TYPE_ALL): array|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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
2023-02-06 14:48:08 +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-01-31 14:11:31 +01: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-01-31 14:11:31 +01:00
|
|
|
public function getTL(): \danog\MadelineProto\TL\TL
|
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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get updates.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Accesses a private variable from an object.
|
|
|
|
*
|
|
|
|
* @param object $obj Object
|
|
|
|
* @param string $var Attribute name
|
|
|
|
* @psalm-suppress InvalidScope
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
public static function getVar(object $obj, string $var)
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\Tools::getVar($obj, $var);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get web template.
|
|
|
|
*/
|
2023-01-31 14:11:31 +01:00
|
|
|
public function getWebTemplate(): string
|
2023-01-27 14:20:47 +01:00
|
|
|
{
|
2023-01-31 14:11:31 +01:00
|
|
|
return $this->wrapper->getAPI()->getWebTemplate();
|
2023-01-27 14:20:47 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Checks whether all datacenters are authorized.
|
|
|
|
*/
|
2023-01-31 14:11:31 +01:00
|
|
|
public function hasAllAuth(): bool
|
2023-01-27 14:20:47 +01:00
|
|
|
{
|
2023-01-31 14:11:31 +01:00
|
|
|
return $this->wrapper->getAPI()->hasAllAuth();
|
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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Checks private property exists in an object.
|
|
|
|
*
|
|
|
|
* @param object $obj Object
|
|
|
|
* @param string $var Attribute name
|
|
|
|
* @psalm-suppress InvalidScope
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
public static function hasVar(object $obj, string $var): bool
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\Tools::hasVar($obj, $var);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Import authorization.
|
|
|
|
*
|
|
|
|
* @param array<int, string> $authorization Authorization info
|
|
|
|
* @param int $mainDcID Main DC ID
|
|
|
|
*/
|
|
|
|
public function importAuthorization(array $authorization, int $mainDcID)
|
|
|
|
{
|
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
|
|
|
|
* @return string JPG payload
|
|
|
|
*/
|
|
|
|
public static function inflateStripped(string $stripped): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\Tools::inflateStripped($stripped);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Check whether provided bot API ID is a channel.
|
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*
|
2023-04-22 20:22:17 +02:00
|
|
|
* @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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Escape string for markdown.
|
|
|
|
*
|
|
|
|
* @param string $hwat String to escape
|
|
|
|
*/
|
|
|
|
public static function markdownEscape(string $hwat): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\StrTools::markdownEscape($hwat);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Escape method name.
|
|
|
|
*
|
|
|
|
* @param string $method Method name
|
|
|
|
*/
|
|
|
|
public static function methodEscape(string $method): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\StrTools::methodEscape($method);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* @return int Modulo
|
|
|
|
*/
|
|
|
|
public static function posmod(int $a, int $b): int
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\Tools::posmod($a, $b);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get random string of specified length.
|
|
|
|
*
|
|
|
|
* @param integer $length Length
|
|
|
|
* @return string Random string
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
public static function readLine(string $prompt = ''): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\AsyncTools::readLine($prompt);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
2023-04-22 20:22:17 +02: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-01-31 14:11:31 +01:00
|
|
|
* @return int One of MTProto::SECRET_EMPTY, MTProto::SECRET_REQUESTED, MTProto::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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Sets a private variable in an object.
|
|
|
|
*
|
|
|
|
* @param object $obj Object
|
|
|
|
* @param string $var Attribute name
|
|
|
|
* @param mixed $val Attribute value
|
|
|
|
* @psalm-suppress InvalidScope
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
public static function setVar(object $obj, string $var, mixed &$val): void
|
|
|
|
{
|
2023-01-27 14:36:54 +01:00
|
|
|
\danog\MadelineProto\Tools::setVar($obj, $var, $val);
|
2023-01-27 14:20:47 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Set web template.
|
|
|
|
*
|
|
|
|
* @param string $template Template
|
|
|
|
*/
|
2023-01-27 14:36:54 +01:00
|
|
|
public function setWebTemplate(string $template): void
|
2023-01-27 14:20:47 +01:00
|
|
|
{
|
2023-01-31 14:11:31 +01:00
|
|
|
$this->wrapper->getAPI()->setWebTemplate($template);
|
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
|
|
|
}
|
2023-04-22 20:22:17 +02:00
|
|
|
/**
|
|
|
|
* Stop update loop.
|
|
|
|
*/
|
|
|
|
public function stop(): void
|
|
|
|
{
|
|
|
|
$this->wrapper->getAPI()->stop();
|
|
|
|
}
|
2023-01-27 14:20:47 +01:00
|
|
|
/**
|
|
|
|
* Subscribe to event handler updates for a channel/supergroup we're not a member of.
|
|
|
|
*
|
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);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Escape type name.
|
|
|
|
*
|
|
|
|
* @param string $type String to escape
|
|
|
|
*/
|
|
|
|
public static function typeEscape(string $type): string
|
|
|
|
{
|
|
|
|
return \danog\MadelineProto\StrTools::typeEscape($type);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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|string|array $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
|
|
|
|
*/
|
|
|
|
public function upload(\danog\MadelineProto\FileCallbackInterface|array|string $file, string $fileName = '', ?callable $cb = null, bool $encrypted = false)
|
|
|
|
{
|
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-01-27 14:36:54 +01:00
|
|
|
}
|