From ec6ba6ea763331d9d28f6b6bd77e3c30449c44a4 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 22 May 2019 17:50:07 +0200 Subject: [PATCH] Synchronous my.telegram.org wrapper --- src/danog/MadelineProto/MyTelegramOrgWrapper.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/MyTelegramOrgWrapper.php b/src/danog/MadelineProto/MyTelegramOrgWrapper.php index a52d7ed3a..6fdaa1dfc 100644 --- a/src/danog/MadelineProto/MyTelegramOrgWrapper.php +++ b/src/danog/MadelineProto/MyTelegramOrgWrapper.php @@ -25,12 +25,15 @@ use Amp\Artax\Request; */ class MyTelegramOrgWrapper { + use Tools; + private $logged = false; private $hash = ''; private $token; private $number; private $creation_hash; private $settings; + public $async = false; const MY_TELEGRAM_URL = 'https://my.telegram.org'; public function __sleep() @@ -268,5 +271,14 @@ class MyTelegramOrgWrapper return $final_headers; } - + public function async($async) + { + $this->async = $async; + } + public function __call($name, $arguments) + { + $name .= '_async'; + $async = is_array(end($arguments)) && isset(end($arguments)['async']) ? end($arguments)['async'] : $this->async; + return $async ? $this->{$name}(...$arguments) : $this->wait($this->{$name}(...$arguments)); + } }