From 37fa11e81a4d4afdb4782e141b50425608c52ce8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 18 Oct 2016 17:11:33 +0000 Subject: [PATCH] uhh --- src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php | 2 +- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 4 ++-- src/danog/MadelineProto/MTProtoTools/MessageHandler.php | 6 ++++-- src/danog/MadelineProto/MTProtoTools/ResponseHandler.php | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index 76cdd6cc3..936b17950 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -484,7 +484,7 @@ class AuthKeyHandler extends AckHandler list($aes_key, $aes_iv) = $this->aes_calculate($message_key, $this->settings['authorization']['auth_key']['auth_key']); $encrypted_message = $this->settings['authorization']['auth_key']['id'].$message_key.$this->ige_encrypt($encrypted_data.$padding, $aes_key, $aes_iv); - if ($this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message])) { + if ($this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message], $message_id)) { $this->log->log('Successfully binded temporary and permanent authorization keys.'); $this->write_client_info(); diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 2f3102205..c39319944 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -45,12 +45,12 @@ class CallHandler extends AuthKeyHandler } } - public function method_call($method, $args) + public function method_call($method, $args, $message_id = null) { foreach (range(1, $this->settings['max_tries']['query']) as $i) { try { $args = $this->tl->get_named_method_args($method, $args); - $int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method)); + $int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method), $message_id); $this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args]; $server_answer = $this->wait_for_response($int_message_id, $method); } catch (Exception $e) { diff --git a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php index d8829f4ef..378d4fada 100644 --- a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php @@ -21,9 +21,11 @@ class MessageHandler extends Crypt * Forming the message frame and sending message to server * :param message: byte string to send. */ - public function send_message($message_data, $content_related) + public function send_message($message_data, $content_related, $int_message_id = null) { - $int_message_id = $this->generate_message_id(); + if ($int_message_id == null) { + $int_message_id = $this->generate_message_id(); + } $message_id = $this->struct->pack('settings['authorization']['temp_auth_key']['auth_key'] == null) || ($this->settings['authorization']['temp_auth_key']['server_salt'] == null)) { $message = $this->string2bin('\x00\x00\x00\x00\x00\x00\x00\x00').$message_id.$this->struct->pack('settings['authorization']['temp_auth_key']['server_salt'] = $response['new_server_salt'];