diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index eb148305..853e4095 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -282,7 +282,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB ], 'calls' => [ 'accept_calls' => true, // Should I accept calls? Can be true, false or on array of user ids from which to accept calls - 'allow_p2p' => false // Should I accept p2p calls? + 'allow_p2p' => false, // Should I accept p2p calls? ], 'threading' => [ 'allow_threading' => false, // Should I use threading, if it is enabled? diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index 03d181cc..b9fe6c38 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -497,6 +497,7 @@ trait UpdateHandler return $this->accept_call($update['phone_call']); case 'phoneCallAccepted': $this->confirm_call($update['phone_call']); + return; case 'phoneCall': $this->complete_call($update['phone_call']); @@ -561,10 +562,10 @@ trait UpdateHandler \danog\MadelineProto\Logger::log(['Completing creation of secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE); $this->complete_secret_chat($update['chat']); + return; } //\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::NOTICE); - } if (!$this->settings['updates']['handle_updates']) { return; diff --git a/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php b/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php index c708ad9f..2b4dda3c 100644 --- a/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php +++ b/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php @@ -212,5 +212,9 @@ trait AuthKeyHandler return 0; } - public function get_secret_chat($chat) { return $this->secret_chats[$chat]; } + + public function get_secret_chat($chat) + { + return $this->secret_chats[$chat]; + } } diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index c59fb5a5..7c102b16 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -48,8 +48,12 @@ trait AuthKeyHandler public function accept_call($params) { - if ($this->settings['calls']['accept_calls'] === false) return false; - if (is_array($this->settings['calls']['accept_calls']) && !in_array($this->settings['calls']['accept_calls'])) return false; + if ($this->settings['calls']['accept_calls'] === false) { + return false; + } + if (is_array($this->settings['calls']['accept_calls']) && !in_array($this->settings['calls']['accept_calls'])) { + return false; + } if ($params['protocol']['udp_p2p'] && !$this->settings['calls']['allow_p2p']) { return false; } @@ -63,6 +67,7 @@ trait AuthKeyHandler $this->handle_pending_updates(); $this->get_updates_difference(); } + public function confirm_call($params) { if ($this->call_status($params['id']) !== $this->REQUESTED) { @@ -79,13 +84,15 @@ trait AuthKeyHandler $key['visualization'] = ''; $length = new \phpseclib\Math\BigInteger(count($this->emojis)); foreach (str_split(strrev(substr(hash('sha256', $this->calls[$params['id']]['g_a']->toBytes().$key['auth_key'], true), 20)), 8) as $number) { - $key['visualization'] .= $this->emojis[(int)((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())]; + $key['visualization'] .= $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())]; } $this->calls[$params['id']] = ['status' => $this->READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => $this->settings['tl_scheme']['layer'], 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol']]; $this->handle_pending_updates(); } - public function complete_call($params) { + + public function complete_call($params) + { if ($this->call_status($params['id']) !== $this->ACCEPTED) { \danog\MadelineProto\Logger::log(['Could not find and confirm call '.$params['id']]); @@ -105,7 +112,7 @@ trait AuthKeyHandler $key['visualization'] = ''; $length = new \phpseclib\Math\BigInteger(count($this->emojis)); foreach (str_split(strrev(substr(hash('sha256', $params['g_a_or_b']->toBytes().$key['auth_key'], true), 20)), 8) as $number) { - $key['visualization'] .= $this->emojis[(int)((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())]; + $key['visualization'] .= $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())]; } $this->calls[$params['id']] = ['status' => $this->READY, 'key' => $key, 'admin' => false, 'user_id' => $params['admin_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 1, 'out_seq_no_x' => 0, 'layer' => $this->settings['tl_scheme']['layer'], 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol']];