Remove should_serialize check
This commit is contained in:
parent
85b71b2a3e
commit
5b869098b9
@ -445,8 +445,8 @@ $MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeli
|
|||||||
```
|
```
|
||||||
|
|
||||||
THe deserialize method accepts a second optional parameter, `$no_updates`, that can be set to true to avoid fetching updates on deserialization, and postpone parsing of updates received through the socket until the next deserialization.
|
THe deserialize method accepts a second optional parameter, `$no_updates`, that can be set to true to avoid fetching updates on deserialization, and postpone parsing of updates received through the socket until the next deserialization.
|
||||||
That class serializes only if the `$MadelineProto->API->should_serialize` boolean is set to true, using [MagicalSerializer](https://github.com/danog/MagicalSerializer).
|
That class serializes using [MagicalSerializer](https://github.com/danog/MagicalSerializer).
|
||||||
The same operation should be done when serializing to another destination manually, to avoid conflicts with other PHP scripts that are trying to serialize another instance of the class.
|
The same should be done when serializing to another destination manually, to avoid conflicts with other PHP scripts that are trying to serialize another instance of the class.
|
||||||
|
|
||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
---
|
|
||||||
title: MadelineProto documentation
|
|
||||||
description: PHP implementation of telegram's MTProto protocol
|
|
||||||
---
|
|
||||||
# MadelineProto
|
# MadelineProto
|
||||||
[![StyleCI](https://styleci.io/repos/61838413/shield)](https://styleci.io/repos/61838413)
|
[![StyleCI](https://styleci.io/repos/61838413/shield)](https://styleci.io/repos/61838413)
|
||||||
[![Build Status](https://travis-ci.org/danog/MadelineProto.svg?branch=master)](https://travis-ci.org/danog/MadelineProto)
|
[![Build Status](https://travis-ci.org/danog/MadelineProto.svg?branch=master)](https://travis-ci.org/danog/MadelineProto)
|
||||||
@ -449,8 +445,8 @@ $MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeli
|
|||||||
```
|
```
|
||||||
|
|
||||||
THe deserialize method accepts a second optional parameter, `$no_updates`, that can be set to true to avoid fetching updates on deserialization, and postpone parsing of updates received through the socket until the next deserialization.
|
THe deserialize method accepts a second optional parameter, `$no_updates`, that can be set to true to avoid fetching updates on deserialization, and postpone parsing of updates received through the socket until the next deserialization.
|
||||||
That class serializes only if the `$MadelineProto->API->should_serialize` boolean is set to true, using [MagicalSerializer](https://github.com/danog/MagicalSerializer).
|
That class serializes using [MagicalSerializer](https://github.com/danog/MagicalSerializer).
|
||||||
The same operation should be done when serializing to another destination manually, to avoid conflicts with other PHP scripts that are trying to serialize another instance of the class.
|
The same should be done when serializing to another destination manually, to avoid conflicts with other PHP scripts that are trying to serialize another instance of the class.
|
||||||
|
|
||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
|
@ -185,7 +185,6 @@ class MTProto extends \Volatile
|
|||||||
private $twoe2048;
|
private $twoe2048;
|
||||||
|
|
||||||
private $ipv6 = false;
|
private $ipv6 = false;
|
||||||
public $should_serialize = false;
|
|
||||||
public $run_workers = false;
|
public $run_workers = false;
|
||||||
public $threads = false;
|
public $threads = false;
|
||||||
|
|
||||||
@ -244,7 +243,6 @@ class MTProto extends \Volatile
|
|||||||
if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc']) {
|
if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc']) {
|
||||||
$this->datacenter->curdc = (int) $nearest_dc['nearest_dc'];
|
$this->datacenter->curdc = (int) $nearest_dc['nearest_dc'];
|
||||||
$this->settings['connection_settings']['default_dc'] = (int) $nearest_dc['nearest_dc'];
|
$this->settings['connection_settings']['default_dc'] = (int) $nearest_dc['nearest_dc'];
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
} catch (RPCErrorException $e) {
|
} catch (RPCErrorException $e) {
|
||||||
if ($e->rpc !== 'BOT_METHOD_INVALID') {
|
if ($e->rpc !== 'BOT_METHOD_INVALID') {
|
||||||
@ -254,7 +252,6 @@ class MTProto extends \Volatile
|
|||||||
}
|
}
|
||||||
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
||||||
$this->v = $this->getV();
|
$this->v = $this->getV();
|
||||||
$this->should_serialize = true;
|
|
||||||
|
|
||||||
return $this->settings;
|
return $this->settings;
|
||||||
}
|
}
|
||||||
@ -551,7 +548,6 @@ class MTProto extends \Volatile
|
|||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
// Setup logger
|
// Setup logger
|
||||||
$this->setup_logger();
|
$this->setup_logger();
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setup_logger()
|
public function setup_logger()
|
||||||
@ -576,7 +572,6 @@ class MTProto extends \Volatile
|
|||||||
$socket->outgoing_messages = [];
|
$socket->outgoing_messages = [];
|
||||||
$socket->new_outgoing = [];
|
$socket->new_outgoing = [];
|
||||||
$socket->new_incoming = [];
|
$socket->new_incoming = [];
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,7 +605,6 @@ class MTProto extends \Volatile
|
|||||||
$socket->session_id = $this->random(8);
|
$socket->session_id = $this->random(8);
|
||||||
$socket->session_in_seq_no = 0;
|
$socket->session_in_seq_no = 0;
|
||||||
$socket->session_out_seq_no = 0;
|
$socket->session_out_seq_no = 0;
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
if ($socket->temp_auth_key === null || $socket->auth_key === null) {
|
if ($socket->temp_auth_key === null || $socket->auth_key === null) {
|
||||||
if ($socket->auth_key === null) {
|
if ($socket->auth_key === null) {
|
||||||
@ -624,7 +618,6 @@ class MTProto extends \Volatile
|
|||||||
if (in_array($socket->protocol, ['http', 'https'])) {
|
if (in_array($socket->protocol, ['http', 'https'])) {
|
||||||
$this->method_call('http_wait', ['max_wait' => 0, 'wait_after' => 0, 'max_delay' => 0], ['datacenter' => $id]);
|
$this->method_call('http_wait', ['max_wait' => 0, 'wait_after' => 0, 'max_delay' => 0], ['datacenter' => $id]);
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->initing_authorization = false;
|
$this->initing_authorization = false;
|
||||||
@ -646,7 +639,6 @@ class MTProto extends \Volatile
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['Copying authorization from dc '.$authorized_dc.' to dc '.$new_dc.'...'], Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Copying authorization from dc '.$authorized_dc.' to dc '.$new_dc.'...'], Logger::VERBOSE);
|
||||||
$this->should_serialize = true;
|
|
||||||
$exported_authorization = $this->method_call('auth.exportAuthorization', ['dc_id' => $new_dc], ['datacenter' => $authorized_dc]);
|
$exported_authorization = $this->method_call('auth.exportAuthorization', ['dc_id' => $new_dc], ['datacenter' => $authorized_dc]);
|
||||||
$this->method_call('auth.logOut', [], ['datacenter' => $new_dc]);
|
$this->method_call('auth.logOut', [], ['datacenter' => $new_dc]);
|
||||||
$this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
|
$this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
|
||||||
@ -684,7 +676,6 @@ class MTProto extends \Volatile
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->config = empty($config) ? $this->method_call('help.getConfig', $config, $options) : $config;
|
$this->config = empty($config) ? $this->method_call('help.getConfig', $config, $options) : $config;
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->parse_config();
|
$this->parse_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +703,6 @@ class MTProto extends \Volatile
|
|||||||
$this->settings['connection'][$test][$ipv6][$id] = $dc;
|
$this->settings['connection'][$test][$ipv6][$id] = $dc;
|
||||||
}
|
}
|
||||||
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
|
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getV()
|
public function getV()
|
||||||
|
@ -67,7 +67,6 @@ trait AuthKeyHandler
|
|||||||
foreach ($this->method_call('help.getCdnConfig', [], ['datacenter' => $datacenter])['public_keys'] as $curkey) {
|
foreach ($this->method_call('help.getCdnConfig', [], ['datacenter' => $datacenter])['public_keys'] as $curkey) {
|
||||||
$tempkey = new \danog\MadelineProto\RSA($curkey['public_key']);
|
$tempkey = new \danog\MadelineProto\RSA($curkey['public_key']);
|
||||||
$this->rsa_keys[$tempkey->fp] = $tempkey;
|
$this->rsa_keys[$tempkey->fp] = $tempkey;
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ trait PeerHandler
|
|||||||
case 'user':
|
case 'user':
|
||||||
if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) {
|
if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) {
|
||||||
$this->chats[$user['id']] = $user;
|
$this->chats[$user['id']] = $user;
|
||||||
$this->should_serialize = true;
|
|
||||||
try {
|
try {
|
||||||
$this->get_pwr_chat($user['id'], false, true);
|
$this->get_pwr_chat($user['id'], false, true);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -54,7 +53,6 @@ trait PeerHandler
|
|||||||
case 'chatForbidden':
|
case 'chatForbidden':
|
||||||
if (!isset($this->chats[-$chat['id']]) || $this->chats[-$chat['id']] !== $chat) {
|
if (!isset($this->chats[-$chat['id']]) || $this->chats[-$chat['id']] !== $chat) {
|
||||||
$this->chats[-$chat['id']] = $chat;
|
$this->chats[-$chat['id']] = $chat;
|
||||||
$this->should_serialize = true;
|
|
||||||
try {
|
try {
|
||||||
$this->get_pwr_chat(-$chat['id'], true, true);
|
$this->get_pwr_chat(-$chat['id'], true, true);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
@ -74,7 +72,6 @@ trait PeerHandler
|
|||||||
$bot_api_id = $this->to_supergroup($chat['id']);
|
$bot_api_id = $this->to_supergroup($chat['id']);
|
||||||
if (!isset($this->chats[$bot_api_id]) || $this->chats[$bot_api_id] !== $chat) {
|
if (!isset($this->chats[$bot_api_id]) || $this->chats[$bot_api_id] !== $chat) {
|
||||||
$this->chats[$bot_api_id] = $chat;
|
$this->chats[$bot_api_id] = $chat;
|
||||||
$this->should_serialize = true;
|
|
||||||
if (!isset($this->full_chats[$bot_api_id]) || $this->full_chats[$bot_api_id]['full']['participants_count'] !== $this->get_full_info($bot_api_id)['full']['participants_count']) {
|
if (!isset($this->full_chats[$bot_api_id]) || $this->full_chats[$bot_api_id]['full']['participants_count'] !== $this->get_full_info($bot_api_id)['full']['participants_count']) {
|
||||||
try {
|
try {
|
||||||
$this->get_pwr_chat($this->to_supergroup($chat['id']), true, true);
|
$this->get_pwr_chat($this->to_supergroup($chat['id']), true, true);
|
||||||
|
@ -48,7 +48,6 @@ trait UpdateHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->updates[$this->updates_key++] = $update;
|
$this->updates[$this->updates_key++] = $update;
|
||||||
$this->should_serialize = true;
|
|
||||||
//\danog\MadelineProto\Logger::log(['Stored ', $update);
|
//\danog\MadelineProto\Logger::log(['Stored ', $update);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +80,6 @@ trait UpdateHandler
|
|||||||
ksort($supdates);
|
ksort($supdates);
|
||||||
foreach ($supdates as $key => $value) {
|
foreach ($supdates as $key => $value) {
|
||||||
if ($params['offset'] > $key) {
|
if ($params['offset'] > $key) {
|
||||||
$this->should_serialize = true;
|
|
||||||
unset($this->updates[$key]);
|
unset($this->updates[$key]);
|
||||||
} elseif ($params['limit'] === null || count($updates) < $params['limit']) {
|
} elseif ($params['limit'] === null || count($updates) < $params['limit']) {
|
||||||
$updates[] = ['update_id' => $key, 'update' => $value];
|
$updates[] = ['update_id' => $key, 'update' => $value];
|
||||||
@ -103,7 +101,6 @@ trait UpdateHandler
|
|||||||
public function set_channel_state($channel, $data)
|
public function set_channel_state($channel, $data)
|
||||||
{
|
{
|
||||||
if (isset($data['pts']) && $data['pts'] !== 0) {
|
if (isset($data['pts']) && $data['pts'] !== 0) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->get_channel_state($channel)['pts'] = $data['pts'];
|
$this->get_channel_state($channel)['pts'] = $data['pts'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +116,6 @@ trait UpdateHandler
|
|||||||
{
|
{
|
||||||
$id = $this->get_info($peer)['bot_api_id'];
|
$id = $this->get_info($peer)['bot_api_id'];
|
||||||
$this->msg_ids[$id] = $msg_id;
|
$this->msg_ids[$id] = $msg_id;
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_channel_difference($channel)
|
public function get_channel_difference($channel)
|
||||||
@ -185,19 +181,15 @@ trait UpdateHandler
|
|||||||
public function set_update_state($data)
|
public function set_update_state($data)
|
||||||
{
|
{
|
||||||
if (isset($data['pts']) && $data['pts'] !== 0) {
|
if (isset($data['pts']) && $data['pts'] !== 0) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->get_update_state()['pts'] = $data['pts'];
|
$this->get_update_state()['pts'] = $data['pts'];
|
||||||
}
|
}
|
||||||
if (isset($data['qts']) && $data['qts'] !== 0) {
|
if (isset($data['qts']) && $data['qts'] !== 0) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->get_update_state()['qts'] = $data['qts'];
|
$this->get_update_state()['qts'] = $data['qts'];
|
||||||
}
|
}
|
||||||
if (isset($data['seq']) && $data['seq'] !== 0) {
|
if (isset($data['seq']) && $data['seq'] !== 0) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->get_update_state()['seq'] = $data['seq'];
|
$this->get_update_state()['seq'] = $data['seq'];
|
||||||
}
|
}
|
||||||
if (isset($data['date']) && $data['date'] > $this->get_update_state()['date']) {
|
if (isset($data['date']) && $data['date'] > $this->get_update_state()['date']) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->get_update_state()['date'] = $data['date'];
|
$this->get_update_state()['date'] = $data['date'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,11 +197,9 @@ trait UpdateHandler
|
|||||||
public function &get_update_state()
|
public function &get_update_state()
|
||||||
{
|
{
|
||||||
if (!isset($this->updates_state['qts'])) {
|
if (!isset($this->updates_state['qts'])) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->updates_state['qts'] = 0;
|
$this->updates_state['qts'] = 0;
|
||||||
}
|
}
|
||||||
if (!$this->got_state) {
|
if (!$this->got_state) {
|
||||||
$this->got_state = $this->should_serialize = true;
|
|
||||||
$this->get_updates_state();
|
$this->get_updates_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,12 +370,10 @@ trait UpdateHandler
|
|||||||
if ($update['pts'] > $cur_state['pts']) {
|
if ($update['pts'] > $cur_state['pts']) {
|
||||||
\danog\MadelineProto\Logger::log(['Applying pts. current pts: '.$cur_state['pts'].' + pts count: '.(isset($update['pts_count']) ? $update['pts_count'] : 0).' = new pts: '.$new_pts.', channel id: '.$channel_id], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Applying pts. current pts: '.$cur_state['pts'].' + pts count: '.(isset($update['pts_count']) ? $update['pts_count'] : 0).' = new pts: '.$new_pts.', channel id: '.$channel_id], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$cur_state['pts'] = $update['pts'];
|
$cur_state['pts'] = $update['pts'];
|
||||||
$this->should_serialize = true;
|
|
||||||
$pop_pts = true;
|
$pop_pts = true;
|
||||||
}
|
}
|
||||||
if ($channel_id !== false && isset($options['date']) && $this->get_update_state()['date'] < $options['date']) {
|
if ($channel_id !== false && isset($options['date']) && $this->get_update_state()['date'] < $options['date']) {
|
||||||
$this->get_update_state()['date'] = $options['date'];
|
$this->get_update_state()['date'] = $options['date'];
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
} elseif ($channel_id === false && isset($options['seq']) && $options['seq'] > 0) {
|
} elseif ($channel_id === false && isset($options['seq']) && $options['seq'] > 0) {
|
||||||
$seq = $options['seq'];
|
$seq = $options['seq'];
|
||||||
@ -403,7 +391,6 @@ trait UpdateHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($cur_state['seq'] != $seq) {
|
if ($cur_state['seq'] != $seq) {
|
||||||
$this->should_serialize = true;
|
|
||||||
$cur_state['seq'] = $seq;
|
$cur_state['seq'] = $seq;
|
||||||
if (isset($options['date']) && $cur_state['date'] < $options['date']) {
|
if (isset($options['date']) && $cur_state['date'] < $options['date']) {
|
||||||
$cur_state['date'] = $options['date'];
|
$cur_state['date'] = $options['date'];
|
||||||
@ -425,7 +412,6 @@ trait UpdateHandler
|
|||||||
if (!$this->settings['updates']['handle_updates']) {
|
if (!$this->settings['updates']['handle_updates']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
$next_seq = $this->get_update_state()['seq'] + 1;
|
$next_seq = $this->get_update_state()['seq'] + 1;
|
||||||
if (empty($this->get_update_state()['pending_seq_updates'][$next_seq]['updates'])) {
|
if (empty($this->get_update_state()['pending_seq_updates'][$next_seq]['updates'])) {
|
||||||
return false;
|
return false;
|
||||||
@ -448,7 +434,6 @@ trait UpdateHandler
|
|||||||
if (!$this->settings['updates']['handle_updates']) {
|
if (!$this->settings['updates']['handle_updates']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
if ($channel_id === false) {
|
if ($channel_id === false) {
|
||||||
$cur_state = &$this->get_update_state();
|
$cur_state = &$this->get_update_state();
|
||||||
} else {
|
} else {
|
||||||
@ -536,7 +521,6 @@ trait UpdateHandler
|
|||||||
$cur_state = $this->get_update_state();
|
$cur_state = $this->get_update_state();
|
||||||
if ($cur_state['qts'] === -1) {
|
if ($cur_state['qts'] === -1) {
|
||||||
$cur_state['qts'] = $update['qts'];
|
$cur_state['qts'] = $update['qts'];
|
||||||
$this->should_serialize = true;
|
|
||||||
}
|
}
|
||||||
if ($update['qts'] < $cur_state['qts']) {
|
if ($update['qts'] < $cur_state['qts']) {
|
||||||
\danog\MadelineProto\Logger::log(['Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::ERROR);
|
\danog\MadelineProto\Logger::log(['Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::ERROR);
|
||||||
@ -551,7 +535,6 @@ trait UpdateHandler
|
|||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log(['Applying qts: '.$update['qts'].' over current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Applying qts: '.$update['qts'].' over current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$this->method_call('messages.receivedQueue', ['max_qts' => $cur_state['qts'] = $update['qts']], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.receivedQueue', ['max_qts' => $cur_state['qts'] = $update['qts']], ['datacenter' => $this->datacenter->curdc]);
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->handle_encrypted_update($update);
|
$this->handle_encrypted_update($update);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,6 @@ trait AuthKeyHandler
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
$dh_config = $this->get_dh_config();
|
$dh_config = $this->get_dh_config();
|
||||||
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$b = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
$b = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||||
@ -52,7 +51,6 @@ trait AuthKeyHandler
|
|||||||
|
|
||||||
public function request_secret_chat($user)
|
public function request_secret_chat($user)
|
||||||
{
|
{
|
||||||
$this->should_serialize = true;
|
|
||||||
$user = $this->get_info($user);
|
$user = $this->get_info($user);
|
||||||
if (!isset($user['InputUser'])) {
|
if (!isset($user['InputUser'])) {
|
||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
@ -83,7 +81,6 @@ trait AuthKeyHandler
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
$dh_config = $this->get_dh_config();
|
$dh_config = $this->get_dh_config();
|
||||||
$params['g_a_or_b'] = new \phpseclib\Math\BigInteger($params['g_a_or_b'], 256);
|
$params['g_a_or_b'] = new \phpseclib\Math\BigInteger($params['g_a_or_b'], 256);
|
||||||
$this->check_G($params['g_a_or_b'], $dh_config['p']);
|
$this->check_G($params['g_a_or_b'], $dh_config['p']);
|
||||||
@ -115,7 +112,6 @@ trait AuthKeyHandler
|
|||||||
if ($this->secret_chats[$chat]['rekeying'][0] !== 0) {
|
if ($this->secret_chats[$chat]['rekeying'][0] !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
\danog\MadelineProto\Logger::log(['Rekeying secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Rekeying secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$dh_config = $this->get_dh_config();
|
$dh_config = $this->get_dh_config();
|
||||||
\danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
@ -147,7 +143,6 @@ trait AuthKeyHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
\danog\MadelineProto\Logger::log(['Accepting rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Accepting rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$dh_config = $this->get_dh_config();
|
$dh_config = $this->get_dh_config();
|
||||||
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
@ -173,7 +168,6 @@ trait AuthKeyHandler
|
|||||||
if ($this->secret_chats[$chat]['rekeying'][0] !== 1) {
|
if ($this->secret_chats[$chat]['rekeying'][0] !== 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
\danog\MadelineProto\Logger::log(['Committing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Committing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$dh_config = $this->get_dh_config();
|
$dh_config = $this->get_dh_config();
|
||||||
$params['g_b'] = new \phpseclib\Math\BigInteger($params['g_b'], 256);
|
$params['g_b'] = new \phpseclib\Math\BigInteger($params['g_b'], 256);
|
||||||
@ -207,7 +201,6 @@ trait AuthKeyHandler
|
|||||||
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionAbortKey', 'exchange_id' => $params['exchange_id']]]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
||||||
}
|
}
|
||||||
$this->should_serialize = true;
|
|
||||||
\danog\MadelineProto\Logger::log(['Completing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
\danog\MadelineProto\Logger::log(['Completing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$this->secret_chats[$chat]['rekeying'] = [0];
|
$this->secret_chats[$chat]['rekeying'] = [0];
|
||||||
$this->secret_chats[$chat]['old_key'] = $this->secret_chats[$chat]['key'];
|
$this->secret_chats[$chat]['old_key'] = $this->secret_chats[$chat]['key'];
|
||||||
|
@ -24,19 +24,13 @@ class Serialization
|
|||||||
* @param API $instance
|
* @param API $instance
|
||||||
* @param bool $force
|
* @param bool $force
|
||||||
*
|
*
|
||||||
* @return number|bool
|
* @return number
|
||||||
*/
|
*/
|
||||||
public static function serialize($filename, $instance, $force = false)
|
public static function serialize($filename, $instance, $force = false)
|
||||||
{
|
{
|
||||||
if ($instance->API->should_serialize || !(file_exists($filename) && !empty(file_get_contents($filename))) || $force) {
|
|
||||||
$instance->API->should_serialize = false;
|
|
||||||
|
|
||||||
return file_put_contents($filename, \danog\Serialization::serialize($instance, true), LOCK_EX);
|
return file_put_contents($filename, \danog\Serialization::serialize($instance, true), LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize API class.
|
* Deserialize API class.
|
||||||
*
|
*
|
||||||
|
@ -32,7 +32,6 @@ trait Login
|
|||||||
|
|
||||||
\danog\MadelineProto\Logger::log(['Logged out successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Logged out successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
|
|
||||||
$this->should_serialize = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -56,7 +55,6 @@ trait Login
|
|||||||
$this->sync_authorization($this->datacenter->curdc);
|
$this->sync_authorization($this->datacenter->curdc);
|
||||||
$this->updates = [];
|
$this->updates = [];
|
||||||
$this->updates_key = 0;
|
$this->updates_key = 0;
|
||||||
$this->should_serialize = true;
|
|
||||||
if (!isset($this->settings['pwr']['pwr']) || !$this->settings['pwr']['pwr']) {
|
if (!isset($this->settings['pwr']['pwr']) || !$this->settings['pwr']['pwr']) {
|
||||||
@file_get_contents('https://api.pwrtelegram.xyz/bot'.$token.'/getme');
|
@file_get_contents('https://api.pwrtelegram.xyz/bot'.$token.'/getme');
|
||||||
}
|
}
|
||||||
@ -85,7 +83,6 @@ trait Login
|
|||||||
$this->authorization['phone_number'] = $number;
|
$this->authorization['phone_number'] = $number;
|
||||||
//$this->authorization['_'] .= 'MP';
|
//$this->authorization['_'] .= 'MP';
|
||||||
$this->authorized = self::WAITING_CODE;
|
$this->authorized = self::WAITING_CODE;
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->updates = [];
|
$this->updates = [];
|
||||||
$this->updates_key = 0;
|
$this->updates_key = 0;
|
||||||
|
|
||||||
@ -114,7 +111,6 @@ trait Login
|
|||||||
if ($e->rpc === 'SESSION_PASSWORD_NEEDED') {
|
if ($e->rpc === 'SESSION_PASSWORD_NEEDED') {
|
||||||
\danog\MadelineProto\Logger::log(['2FA enabled, you will have to call the complete_2fa_login function...'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['2FA enabled, you will have to call the complete_2fa_login function...'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
$this->authorized = self::WAITING_PASSWORD;
|
$this->authorized = self::WAITING_PASSWORD;
|
||||||
$this->should_serialize = true;
|
|
||||||
|
|
||||||
$this->authorization = $this->method_call('account.getPassword', [], ['datacenter' => $this->datacenter->curdc]);
|
$this->authorization = $this->method_call('account.getPassword', [], ['datacenter' => $this->datacenter->curdc]);
|
||||||
//$this->authorization['_'] .= 'MP';
|
//$this->authorization['_'] .= 'MP';
|
||||||
@ -123,7 +119,6 @@ trait Login
|
|||||||
if ($e->rpc === 'PHONE_NUMBER_UNOCCUPIED') {
|
if ($e->rpc === 'PHONE_NUMBER_UNOCCUPIED') {
|
||||||
\danog\MadelineProto\Logger::log(['An account has not been created for this number, you will have to call the complete_signup function...'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['An account has not been created for this number, you will have to call the complete_signup function...'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
$this->authorized = self::WAITING_SIGNUP;
|
$this->authorized = self::WAITING_SIGNUP;
|
||||||
$this->should_serialize = true;
|
|
||||||
$this->authorization['phone_code'] = $code;
|
$this->authorization['phone_code'] = $code;
|
||||||
|
|
||||||
return ['_' => 'account.needSignup'];
|
return ['_' => 'account.needSignup'];
|
||||||
@ -133,7 +128,6 @@ trait Login
|
|||||||
$this->authorized = self::LOGGED_IN;
|
$this->authorized = self::LOGGED_IN;
|
||||||
$this->authorization = $authorization;
|
$this->authorization = $authorization;
|
||||||
$this->sync_authorization($this->datacenter->curdc);
|
$this->sync_authorization($this->datacenter->curdc);
|
||||||
$this->should_serialize = true;
|
|
||||||
|
|
||||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
|
|
||||||
@ -160,7 +154,6 @@ trait Login
|
|||||||
$this->authorized = self::LOGGED_IN;
|
$this->authorized = self::LOGGED_IN;
|
||||||
$this->authorized = true;
|
$this->authorized = true;
|
||||||
$this->sync_authorization($this->datacenter->curdc);
|
$this->sync_authorization($this->datacenter->curdc);
|
||||||
$this->should_serialize = true;
|
|
||||||
|
|
||||||
\danog\MadelineProto\Logger::log(['Signed up in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Signed up in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
|
|
||||||
@ -182,7 +175,6 @@ trait Login
|
|||||||
);
|
);
|
||||||
$this->authorized = self::LOGGED_IN;
|
$this->authorized = self::LOGGED_IN;
|
||||||
$this->sync_authorization($this->datacenter->curdc);
|
$this->sync_authorization($this->datacenter->curdc);
|
||||||
$this->should_serialize = true;
|
|
||||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
|
|
||||||
return $this->authorization;
|
return $this->authorization;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user