mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 02:54:42 +01:00
Fixed visualization
This commit is contained in:
parent
b2e9930d16
commit
6fdb63bac2
@ -66,6 +66,11 @@ trait AuthKeyHandler
|
||||
$controller->discard();
|
||||
}
|
||||
});
|
||||
if ($this->call_status($call['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED) {
|
||||
\danog\MadelineProto\Logger::log(['Could not find and accept call '.$call['id']]);
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Accepting call from '.$this->calls[$call['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
|
||||
$dh_config = $this->get_dh_config();
|
||||
@ -77,14 +82,21 @@ trait AuthKeyHandler
|
||||
$res = $this->method_call('phone.acceptCall', ['peer' => $call, 'g_b' => $g_b->toBytes(), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_reflector' => true, 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc === 'CALL_ALREADY_ACCEPTED') {
|
||||
\danog\MadelineProto\Logger::log(['Call '.$call['id'].' already accepted']);
|
||||
return true;
|
||||
}
|
||||
if ($e->rpc === 'CALL_ALREADY_DECLINED') {
|
||||
\danog\MadelineProto\Logger::log(['Call '.$call['id'].' already declined']);
|
||||
$this->calls[$res['phone_call']['id']]->discard();
|
||||
return false;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
$this->calls[$res['phone_call']['id']]->storage['b'] = $b;
|
||||
|
||||
$this->handle_pending_updates();
|
||||
$this->get_updates_difference();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function confirm_call($params)
|
||||
@ -113,8 +125,9 @@ trait AuthKeyHandler
|
||||
|
||||
$visualization = [];
|
||||
$length = new \phpseclib\Math\BigInteger(count($this->emojis));
|
||||
foreach (str_split(hash('sha256', $key.$this->calls[$params['id']]->storage['g_a'], true), 8) as $number) {
|
||||
$visualization[] = $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
|
||||
foreach (str_split(hash('sha256', $key.str_pad($this->calls[$params['id']]->storage['g_a'], 256, chr(0), \STR_PAD_LEFT), true), 8) as $number) {
|
||||
$number[0] = chr(ord($number[0]) & 0x7F);
|
||||
$visualization[] = $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, 256))->divide($length)[1]->toString())];
|
||||
}
|
||||
$this->calls[$params['id']]->setVisualization($visualization);
|
||||
|
||||
@ -172,8 +185,10 @@ trait AuthKeyHandler
|
||||
}
|
||||
$visualization = [];
|
||||
$length = new \phpseclib\Math\BigInteger(count($this->emojis));
|
||||
foreach (str_split(hash('sha256', $key.str_pad($params['g_a_or_b'], 256, chr(0), \STR_PAD_LEFT), true), 8) as $number) {
|
||||
$visualization[] = $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
|
||||
|
||||
foreach (str_split(hash('sha256', $key.str_pad($params['g_a_or_b']->toBytes(), 256, chr(0), \STR_PAD_LEFT), true), 8) as $number) {
|
||||
$number[0] = chr(ord($number[0]) & 0x7F);
|
||||
$visualization[] = $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, 256))->divide($length)[1]->toString())];
|
||||
}
|
||||
|
||||
$this->calls[$params['id']]->setVisualization($visualization);
|
||||
|
@ -90,7 +90,8 @@ if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
|
||||
while ($controller->getCallState() < \danog\MadelineProto\VoIP::CALL_STATE_READY) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
var_dump($controller->getVisualization());
|
||||
$MadelineProto->messages->sendMessage(['peer' => $controller->getOtherID(), 'message' => 'Emojis: '.implode('', $controller->getVisualization())]);
|
||||
var_dump($controller->configuration);
|
||||
while ($controller->getCallState() < \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user