From 6113c0d63cb6b1740c38613fc220deca57c233c5 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 12 Jul 2017 14:33:10 +0200 Subject: [PATCH] Improved parsing of settings and logging --- src/danog/MadelineProto/API.php | 1 + src/danog/MadelineProto/APIFactory.php | 4 ++++ src/danog/MadelineProto/Logger.php | 2 +- src/danog/MadelineProto/MTProto.php | 2 +- tests/testing.php | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 975e50ba9..00a858554 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -57,6 +57,7 @@ class API extends APIFactory public function &__get($name) { if ($name === 'settings') { + $this->API->setdem = true; return $this->API->settings; } diff --git a/src/danog/MadelineProto/APIFactory.php b/src/danog/MadelineProto/APIFactory.php index 1c96ef51d..92c59ada9 100644 --- a/src/danog/MadelineProto/APIFactory.php +++ b/src/danog/MadelineProto/APIFactory.php @@ -124,6 +124,10 @@ class APIFactory public function __call($name, $arguments) { + if ($this->API->setdem) { + $this->API->setdem = false; + $this->API->__construct($this->API->settings); + } $this->API->get_config([], ['datacenter' => $this->API->datacenter->curdc]); $aargs = isset($arguments[1]) && $this->is_array($arguments[1]) ? $arguments[1] : []; $aargs['datacenter'] = $this->API->datacenter->curdc; diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index 05477d6ac..511bf4e0e 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -148,7 +148,7 @@ class Logger public static function log($params, $level = self::NOTICE) { if (self::$mode === 4) { - return self::$optional(is_array($params) ? $params : [$params], $level); + return call_user_func_array(self::$optional, [is_array($params) ? $params : [$params], $level]); } if ($level > self::$level) { return false; diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index c265de7ad..bf0bcde79 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -183,7 +183,7 @@ class MTProto extends \Volatile private $ipv6 = false; public $run_workers = false; public $threads = false; - + public $setdem = false; public function ___construct($settings = []) { \danog\MadelineProto\Logger::class_exists(); diff --git a/tests/testing.php b/tests/testing.php index c4bb9ab59..9511713d5 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -118,6 +118,7 @@ class pony extends \danog\MadelineProto\VoIP echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL; + if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) { $start = false; var_dump($id = $MadelineProto->request_call('@danogentili', '\pony'));