Merge branch 'master' of https://github.com/danog/Madelineproto
This commit is contained in:
commit
35fade1535
@ -674,9 +674,11 @@ class MTProto extends \Volatile
|
||||
\danog\MadelineProto\Logger::log(['Copying authorization from dc '.$authorized_dc.' to dc '.$new_dc.'...'], Logger::VERBOSE);
|
||||
$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.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
|
||||
$authorization = $this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
|
||||
}
|
||||
$this->updates_state['sync_loading'] = false;
|
||||
|
||||
return $authorization;
|
||||
}
|
||||
|
||||
public function write_client_info($method, $arguments = [], $options = [])
|
||||
|
@ -37,7 +37,7 @@ trait Login
|
||||
|
||||
public function bot_login($token)
|
||||
{
|
||||
if ($this->authorized) {
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
@ -64,7 +64,7 @@ trait Login
|
||||
|
||||
public function phone_login($number, $sms_type = 5)
|
||||
{
|
||||
if ($this->authorized) {
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
@ -133,6 +133,39 @@ trait Login
|
||||
return $this->authorization;
|
||||
}
|
||||
|
||||
public function import_authorization($authorization)
|
||||
{
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Logging in using auth key...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
list($dc_id, $auth_key) = $authorization;
|
||||
$this->datacenter->sockets[$dc_id]->session_id = $this->random(8);
|
||||
$this->datacenter->sockets[$dc_id]->session_in_seq_no = 0;
|
||||
$this->datacenter->sockets[$dc_id]->session_out_seq_no = 0;
|
||||
$this->datacenter->sockets[$dc_id]->auth_key = $auth_key;
|
||||
$this->datacenter->sockets[$dc_id]->temp_auth_key = null;
|
||||
$this->datacenter->sockets[$dc_id]->incoming_messages = [];
|
||||
$this->datacenter->sockets[$dc_id]->outgoing_messages = [];
|
||||
$this->datacenter->sockets[$dc_id]->new_outgoing = [];
|
||||
$this->datacenter->sockets[$dc_id]->new_incoming = [];
|
||||
|
||||
$this->authorized = self::LOGGED_IN;
|
||||
$this->init_authorization();
|
||||
|
||||
return $this->authorization = $this->sync_authorization($dc_id);
|
||||
}
|
||||
|
||||
public function export_authorization()
|
||||
{
|
||||
if ($this->authorized !== self::LOGGED_IN) {
|
||||
throw new \danog\MadelineProto\Exception("I'm not logged in!");
|
||||
}
|
||||
|
||||
return [$this->datacenter->curdc, $this->datacenter->sockets[$this->datacenter->curdc]->auth_key];
|
||||
}
|
||||
|
||||
public function complete_signup($first_name, $last_name)
|
||||
{
|
||||
if ($this->authorized !== self::WAITING_SIGNUP) {
|
||||
@ -151,7 +184,6 @@ trait Login
|
||||
], ['datacenter' => $this->datacenter->curdc]
|
||||
);
|
||||
$this->authorized = self::LOGGED_IN;
|
||||
$this->authorized = true;
|
||||
$this->sync_authorization($this->datacenter->curdc);
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Signed up in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
@ -78,9 +78,11 @@ if ($MadelineProto === false) {
|
||||
|
||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||
|
||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote
|
||||
'.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
|
||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
/*
|
||||
$m = new \danog\MadelineProto\API($settings);
|
||||
$m->import_authorization($MadelineProto->export_authorization());
|
||||
*/
|
||||
if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
|
||||
$controller = $MadelineProto->request_call(getenv('TEST_SECRET_CHAT'))->play('input.raw')->then('input.raw')->playOnHold(['input.raw'])->setOutputFile('output.raw');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user