diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index fddba355..428d64b2 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -70,6 +70,7 @@ class API extends APIFactory $this->APIFactory(); $this->session = $realpaths['file']; } + return; } $this->session = $realpaths['file']; diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index 8468f15e..29d48fc0 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -132,7 +132,9 @@ class Logger $param = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); } $param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param; - if (self::$isatty) self::$mode = 3; + if (self::$isatty) { + self::$mode = 3; + } switch (self::$mode) { case 1: error_log($param); diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 8d1ccd6e..cb197725 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -30,25 +30,31 @@ trait PeerHandler return ($log - intval($log)) * 1000 < 10; } - public function handle_pending_pwrchat() { + public function handle_pending_pwrchat() + { if ($this->postpone_pwrchat || empty($this->pending_pwrchat)) { return false; } $this->postpone_pwrchat = true; + try { - \danog\MadelineProto\Logger::log("Handling pending pwrchat queries...", \danog\MadelineProto\Logger::VERBOSE); - foreach ($this->pending_pwrchat as $query => $params) { - unset($this->pending_pwrchat[$query]); - try { - $this->get_pwr_chat($query, ...$params); - } catch (\danog\MadelineProto\Exception $e) { - \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); - } catch (\danog\MadelineProto\RPCErrorException $e) { - \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + \danog\MadelineProto\Logger::log('Handling pending pwrchat queries...', \danog\MadelineProto\Logger::VERBOSE); + foreach ($this->pending_pwrchat as $query => $params) { + unset($this->pending_pwrchat[$query]); + + try { + $this->get_pwr_chat($query, ...$params); + } catch (\danog\MadelineProto\Exception $e) { + \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + } catch (\danog\MadelineProto\RPCErrorException $e) { + \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + } } + } finally { + $this->postpone_pwrchat = false; } - } finally { $this->postpone_pwrchat = false; } } + public function add_users($users) { foreach ($users as $key => $user) { @@ -73,19 +79,18 @@ trait PeerHandler if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) { $this->chats[$user['id']] = $user; - if ($this->postpone_pwrchat) { - $this->pending_pwrchat[$user['id']] = [false, true]; - } else { - try { - $this->get_pwr_chat($user['id'], false, true); - } catch (\danog\MadelineProto\Exception $e) { - \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); - } catch (\danog\MadelineProto\RPCErrorException $e) { - \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + if ($this->postpone_pwrchat) { + $this->pending_pwrchat[$user['id']] = [false, true]; + } else { + try { + $this->get_pwr_chat($user['id'], false, true); + } catch (\danog\MadelineProto\Exception $e) { + \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + } catch (\danog\MadelineProto\RPCErrorException $e) { + \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); + } } } - - } case 'userEmpty': break; default: diff --git a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php index 562cd8d6..8bf32482 100644 --- a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php @@ -427,16 +427,17 @@ trait ResponseHandler } $this->handle_pending_updates(); \danog\MadelineProto\Logger::log('Parsing updates received via the socket...', \danog\MadelineProto\Logger::VERBOSE); - try { - $this->postpone_updates = true; - $opts = []; - foreach (['date', 'seq', 'seq_start'] as $key) { - if (isset($updates[$key])) { - $opts[$key] = $updates[$key]; + try { + $this->postpone_updates = true; + + $opts = []; + foreach (['date', 'seq', 'seq_start'] as $key) { + if (isset($updates[$key])) { + $opts[$key] = $updates[$key]; + } } - } - switch ($updates['_']) { + switch ($updates['_']) { case 'updates': case 'updatesCombined': foreach ($updates['updates'] as $update) { diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 8d1093d1..a518b6ef 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -664,6 +664,7 @@ trait TL } } } + return $x; } } diff --git a/tests/testing.php b/tests/testing.php index 8c0a0b51..b5b12602 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -33,6 +33,7 @@ if (!function_exists('readline')) { echo 'Deserializing MadelineProto from testing.madeline...'.PHP_EOL; $MadelineProto = false; + try { $MadelineProto = new \danog\MadelineProto\API('testing.madeline'); } catch (\danog\MadelineProto\Exception $e) {