1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 10:19:00 +01:00

Fixed bugs

This commit is contained in:
danogentili 2016-11-17 20:43:52 +03:00
parent b18c16aedc
commit 82dc195483
6 changed files with 24 additions and 24 deletions

View File

@ -141,8 +141,8 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
\danog\MadelineProto\Logger::log('Switching to DC '.$new_dc.'...');
if ($this->datacenter->dc_connect($new_dc)) {
$this->init_authorization();
$this->write_client_info();
$this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $allow_nearest_dc_switch);
$this->write_client_info($allow_nearest_dc_switch);
$this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in']);
}
}
@ -172,7 +172,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
'query' => $this->tl->serialize_method('initConnection',
array_merge(
$this->settings['app_info'],
['query' => $this->tl->serialize_method('help.getnearest_dc', [])]
['query' => $this->tl->serialize_method('help.getNearestDc', [])]
)
),
]

View File

@ -20,8 +20,8 @@ class SeqNoHandler extends SaltHandler
public function generate_seq_no($content_related = true)
{
$in = $content_related ? 1 : 0;
$value = $this->seq_no;
$this->seq_no += $in;
$value = $this->datacenter->seq_no;
$this->datacenter->seq_no += $in;
return ($value * 2) + $in;
}

View File

@ -80,7 +80,7 @@ class PrimeModule extends Tools
{
$pqstr = (string) $pq;
\danog\MadelineProto\Logging::log('Trying to use the python factorization module');
\danog\MadelineProto\Logger::log('Trying to use the python factorization module');
if (function_exists('shell_exec')) {
try {
$res = json_decode(shell_exec('python '.__DIR__.'/getpq.py '.$pqstr));
@ -91,7 +91,7 @@ class PrimeModule extends Tools
}
}
\danog\MadelineProto\Logging::log('Trying to use the wolfram alpha factorization module');
\danog\MadelineProto\Logger::log('Trying to use the wolfram alpha factorization module');
$query = 'Do prime factorization of '.$pqstr;
$params = [
'async' => true,
@ -120,7 +120,7 @@ class PrimeModule extends Tools
return $res;
}
\danog\MadelineProto\Logging::log('Trying to use the native factorization module');
\danog\MadelineProto\Logger::log('Trying to use the native factorization module');
$res = $this->find_small_multiplier_lopatin((int) $pqstr);
$res = [$res, $pqstr / $res];
if ($res[1] != 1) {

View File

@ -39,7 +39,7 @@ class TL extends \danog\MadelineProto\Tools
public function get_named_method_args($method, $arguments)
{
$tl_method = $this->methods->find_by_method($method);
if ($tl_method == false) {
if ($tl_method === false) {
throw new Exception('Could not extract type: '.$method);
}
@ -57,8 +57,8 @@ class TL extends \danog\MadelineProto\Tools
public function serialize_obj($object, $arguments)
{
$tl_constructor = $this->constructors->find_by_type($object);
if ($tl_constructor == false) {
$tl_constructor = $this->constructors->find_by_predicate($object);
if ($tl_constructor === false) {
throw new Exception('Could not extract type: '.$object);
}
@ -74,7 +74,7 @@ class TL extends \danog\MadelineProto\Tools
public function serialize_method($method, $arguments)
{
$tl_method = $this->methods->find_by_method($method);
if ($tl_method == false) {
if ($tl_method === false) {
throw new Exception('Could not extract type: '.$method);
}
@ -148,7 +148,7 @@ class TL extends \danog\MadelineProto\Tools
case '!X':
return $value;
case 'Vector t':
$concat = \danog\PHP\Struct::pack('<i', $this->constructors->find_by_type('vector')['id']);
$concat = \danog\PHP\Struct::pack('<i', $this->constructors->find_by_predicate('vector')['id']);
$concat .= \danog\PHP\Struct::pack('<l', count($value));
foreach ($value as $curv) {
@ -226,16 +226,16 @@ class TL extends \danog\MadelineProto\Tools
}
$count = \danog\PHP\Struct::unpack('<l', fread($bytes_io, 4)) [0];
$x = [];
foreach ($this->range($count) as $i) {
for ($i = 0; $i < $count; $i++) {
$x[] = $this->deserialize($bytes_io, $subtype);
}
break;
default:
$tl_elem = $this->constructors->find_by_type($type);
if ($tl_elem == false) {
$tl_elem = $this->constructors->find_by_predicate($type);
if ($tl_elem === false) {
$id = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4)) [0];
$tl_elem = $this->constructors->find_by_id($id);
if ($tl_elem == false) {
if ($tl_elem === false) {
throw new Exception('Could not extract type: '.$type.' with id '.$id);
}
}

View File

@ -44,18 +44,19 @@ class TLConstructor
$param['type'] = 'Vector t';
}
if (preg_match('/^\%/', $param['subtype'])) {
$param['subtype'] = lcfirst(preg_replace('/^\%/', '', $param['subtype']));
$param['subtype'] = preg_replace('/^\%/', '', $param['subtype']);
}
//lcfirst
}
}
$this->key++;
}
public function find_by_type($type)
public function find_by_predicate($predicate)
{
$key = array_search($type, $this->type);
$key = array_search($predicate, $this->predicate);
return ($key == false) ? false : [
return ($key === false) ? false : [
'id' => $this->id[$key],
'predicate' => $this->predicate[$key],
'type' => $this->type[$key],
@ -67,7 +68,7 @@ class TLConstructor
{
$key = array_search($id, $this->id);
return ($key == false) ? false : [
return ($key === false) ? false : [
'id' => $this->id[$key],
'predicate' => $this->predicate[$key],
'type' => $this->type[$key],

View File

@ -57,8 +57,7 @@ class TLMethod
public function find_by_method($method)
{
$key = array_search($method, $this->method);
return ($key == false) ? false : [
return ($key === false) ? false : [
'id' => $this->id[$key],
'method' => $this->method[$key],
'type' => $this->type[$key],