diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index fca58f99..ec52cff6 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -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', [])] ) ), ] diff --git a/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php b/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php index 4b6bcb67..b730347b 100644 --- a/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php @@ -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; } diff --git a/src/danog/MadelineProto/PrimeModule.php b/src/danog/MadelineProto/PrimeModule.php index 7f9ae7b0..077b09f2 100644 --- a/src/danog/MadelineProto/PrimeModule.php +++ b/src/danog/MadelineProto/PrimeModule.php @@ -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) { diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index e58bd3ba..81750250 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -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('constructors->find_by_type('vector')['id']); + $concat = \danog\PHP\Struct::pack('constructors->find_by_predicate('vector')['id']); $concat .= \danog\PHP\Struct::pack('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('constructors->find_by_id($id); - if ($tl_elem == false) { + if ($tl_elem === false) { throw new Exception('Could not extract type: '.$type.' with id '.$id); } } diff --git a/src/danog/MadelineProto/TL/TLConstructor.php b/src/danog/MadelineProto/TL/TLConstructor.php index a77297dd..93c54b4d 100644 --- a/src/danog/MadelineProto/TL/TLConstructor.php +++ b/src/danog/MadelineProto/TL/TLConstructor.php @@ -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], diff --git a/src/danog/MadelineProto/TL/TLMethod.php b/src/danog/MadelineProto/TL/TLMethod.php index 4897afe7..4969b418 100644 --- a/src/danog/MadelineProto/TL/TLMethod.php +++ b/src/danog/MadelineProto/TL/TLMethod.php @@ -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],