From 62ea79cc06a8f2a90ad1e1e6c4c79623d2fc8f7d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 7 Jul 2018 19:48:10 +0200 Subject: [PATCH] Various bugfixes and abstractions --- src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php | 5 ++++- src/danog/MadelineProto/MTProtoTools/UpdateHandler.php | 1 + src/danog/MadelineProto/TL/TL.php | 5 ++++- src/danog/MadelineProto/Wrappers/Loop.php | 2 +- src/danog/MadelineProto/Wrappers/TOS.php | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index ec93e90c..c3cf6469 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -544,7 +544,10 @@ trait AuthKeyHandler $socket->authorized = false; } elseif ($socket->auth_key === null && $media) { $socket->auth_key = $this->datacenter->sockets[intval($id)]->auth_key; - $socket->authorized = $this->datacenter->sockets[intval($id)]->authorized; + $socket->authorized = &$this->datacenter->sockets[intval($id)]->authorized; + } + if ($media) { + $socket->authorized = &$this->datacenter->sockets[intval($id)]->authorized; } if ($this->settings['connection_settings'][$dc_config_number]['pfs']) { if (!$cdn) { diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index 301eb56f..a6c07e4e 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -395,6 +395,7 @@ trait UpdateHandler } break; } + if ($channel_id === false) { $cur_state = &$this->load_update_state(); } else { diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index f4bc4556..d3d1ad98 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -499,11 +499,14 @@ trait TL $serialized .= pack('@4'); continue; } + if (in_array($current_argument['type'], ['bytes', 'string', 'Vector t'])) { + $serialized .= pack('@4'); + continue; + } if ($id = $this->constructors->find_by_predicate(lcfirst($current_argument['type']).'Empty')) { $serialized .= $id['id']; continue; } - throw new Exception(\danog\MadelineProto\Lang::$current_lang['params_missing'], $current_argument['name']); } diff --git a/src/danog/MadelineProto/Wrappers/Loop.php b/src/danog/MadelineProto/Wrappers/Loop.php index c0b02e70..91d14d60 100644 --- a/src/danog/MadelineProto/Wrappers/Loop.php +++ b/src/danog/MadelineProto/Wrappers/Loop.php @@ -35,7 +35,7 @@ trait Loop set_time_limit(-1); } catch (\danog\MadelineProto\Exception $e) { register_shutdown_function(function () { - $this->logger->logger(['Restarting script...']); + //$this->logger->logger(['Restarting script...']); $a = fsockopen((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp').'://'.$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']); fwrite($a, $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n"); }); diff --git a/src/danog/MadelineProto/Wrappers/TOS.php b/src/danog/MadelineProto/Wrappers/TOS.php index 24519e55..c41e48fa 100644 --- a/src/danog/MadelineProto/Wrappers/TOS.php +++ b/src/danog/MadelineProto/Wrappers/TOS.php @@ -20,7 +20,7 @@ trait TOS { public function check_tos() { - if ($this->authorized === self::LOGGED_IN && !$this->get_self()['bot']) { + if ($this->authorized === self::LOGGED_IN && !$this->authorization['user']['bot']) { if ($this->tos['expires'] < time()) { $this->logger->logger('Fetching TOS...'); $this->tos = $this->method_call('help.getTermsOfServiceUpdate', [], ['datacenter' => $this->datacenter->curdc]);