diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 006a006f..6100ac26 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -144,15 +144,16 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB $this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in']); $nearestDc = $this->method_call('auth.sendCode', [ 'phone_number' => '393373737', - 'sms_type' => 5, - 'api_id' => $this->settings['app_info']['api_id'], - 'api_hash' => $this->settings['app_info']['api_hash'], - 'lang_code' => $this->settings['app_info']['lang_code'], + 'sms_type' => 5, + 'api_id' => $this->settings['app_info']['api_id'], + 'api_hash' => $this->settings['app_info']['api_hash'], + 'lang_code' => $this->settings['app_info']['lang_code'], ]); -var_dump($nearestDc); + var_dump($nearestDc); } - public function write_client_info() { + public function write_client_info() + { $this->log->log('Writing client info...'); $nearestDc = $this->method_call('invokeWithLayer', [ 'layer' => $this->settings['tl_schema']['layer'], @@ -170,6 +171,7 @@ var_dump($nearestDc); $this->connection->dc_connect($nearestDc['nearest_dc']); } } + public function __destruct() { unset($this->sock); diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index ceed6b36..76cdd6cc 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -458,19 +458,21 @@ class AuthKeyHandler extends AckHandler throw new Exception('Auth Failed'); } - public function bind_temp_auth_key($expires_in) { + + public function bind_temp_auth_key($expires_in) + { $nonce = $this->struct->unpack('struct->unpack('settings['authorization']['temp_auth_key']['id'])[0]; - $perm_auth_key_id= $this->struct->unpack('settings['authorization']['auth_key']['id'])[0]; + $perm_auth_key_id = $this->struct->unpack('settings['authorization']['auth_key']['id'])[0]; $temp_session_id = $this->struct->unpack('settings['authorization']['session_id'])[0]; $message_data = $this->tl->serialize_obj('bind_auth_key_inner', [ - 'nonce' => $nonce, - 'temp_auth_key_id' => $temp_auth_key_id, - 'perm_auth_key_id' => $perm_auth_key_id, + 'nonce' => $nonce, + 'temp_auth_key_id' => $temp_auth_key_id, + 'perm_auth_key_id' => $perm_auth_key_id, 'temp_session_id' => $temp_session_id, - 'expires_at' => $expires_at, + 'expires_at' => $expires_at, ] ); $int_message_id = $this->generate_message_id(); @@ -485,6 +487,7 @@ class AuthKeyHandler extends AckHandler if ($this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message])) { $this->log->log('Successfully binded temporary and permanent authorization keys.'); $this->write_client_info(); + return true; } throw new Exception('An error occurred while binding temporary and permanent authorization keys.');