Fix
This commit is contained in:
parent
99d878d4f7
commit
b6a517ede5
2
docs
2
docs
@ -1 +1 @@
|
|||||||
Subproject commit fe346258733323e5173e674f15059dea1a1eb880
|
Subproject commit 9a873608310b43395032755c35bbdf17d35e23d7
|
@ -44,6 +44,8 @@ class AnnotationsBuilder
|
|||||||
* Open file of class APIFactory
|
* Open file of class APIFactory
|
||||||
* Insert properties
|
* Insert properties
|
||||||
* save the file with new content.
|
* save the file with new content.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setProperties()
|
private function setProperties()
|
||||||
{
|
{
|
||||||
|
@ -423,8 +423,10 @@ class Connection extends Session
|
|||||||
*/
|
*/
|
||||||
public function flush()
|
public function flush()
|
||||||
{
|
{
|
||||||
|
if (isset($this->writer)) {
|
||||||
$this->writer->resume();
|
$this->writer->resume();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Connect main instance.
|
* Connect main instance.
|
||||||
*
|
*
|
||||||
|
@ -93,10 +93,11 @@ trait Methods
|
|||||||
|
|
||||||
';
|
';
|
||||||
|
|
||||||
if (isset($this->td_descriptions['methods'][$data['method']]))
|
if (isset($this->td_descriptions['methods'][$data['method']])) {
|
||||||
$this->human_docs_methods[$this->td_descriptions['methods'][$data['method']]['description'].': '.$data['method']] = '* <a href="'.$method.'.html" name="'.$method.'">'.$this->td_descriptions['methods'][$data['method']]['description'].': '.$data['method'].'</a>
|
$this->human_docs_methods[$this->td_descriptions['methods'][$data['method']]['description'].': '.$data['method']] = '* <a href="'.$method.'.html" name="'.$method.'">'.$this->td_descriptions['methods'][$data['method']]['description'].': '.$data['method'].'</a>
|
||||||
|
|
||||||
';
|
';
|
||||||
|
}
|
||||||
|
|
||||||
$params = '';
|
$params = '';
|
||||||
$lua_params = '';
|
$lua_params = '';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Lang module
|
* Lang module.
|
||||||
*
|
*
|
||||||
* This file is part of MadelineProto.
|
* This file is part of MadelineProto.
|
||||||
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
@ -19,9 +19,9 @@ namespace danog\MadelineProto;
|
|||||||
|
|
||||||
class Lang
|
class Lang
|
||||||
{
|
{
|
||||||
public static $lang = array (
|
public static $lang = [
|
||||||
'it' =>
|
'it' =>
|
||||||
array (
|
[
|
||||||
'phpseclib_fork' => 'Per favore installa questo fork di phpseclib: https://github.com/danog/phpseclib',
|
'phpseclib_fork' => 'Per favore installa questo fork di phpseclib: https://github.com/danog/phpseclib',
|
||||||
'inst_dc' => 'Istanziamento dei DataCenter...',
|
'inst_dc' => 'Istanziamento dei DataCenter...',
|
||||||
'load_rsa' => 'Caricamento delle chiavi RSA...',
|
'load_rsa' => 'Caricamento delle chiavi RSA...',
|
||||||
@ -161,9 +161,9 @@ class Lang
|
|||||||
'done' => 'Fatto!',
|
'done' => 'Fatto!',
|
||||||
'cdn_reupload' => 'Il file non è disponibile sul nostro CDN, richiedo la copia!',
|
'cdn_reupload' => 'Il file non è disponibile sul nostro CDN, richiedo la copia!',
|
||||||
'stored_on_cdn' => 'Il file è scaricabile tramite CDN!',
|
'stored_on_cdn' => 'Il file è scaricabile tramite CDN!',
|
||||||
),
|
],
|
||||||
'en' =>
|
'en' =>
|
||||||
array (
|
[
|
||||||
'req_pq' => 'Requesting pq...',
|
'req_pq' => 'Requesting pq...',
|
||||||
'done' => 'Done!',
|
'done' => 'Done!',
|
||||||
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
|
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
|
||||||
@ -5243,11 +5243,11 @@ class Lang
|
|||||||
'object_account.themes_param_themes_type_Vector t' => 'Themes',
|
'object_account.themes_param_themes_type_Vector t' => 'Themes',
|
||||||
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
|
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
|
||||||
'method_account.getThemes' => 'Get installed themes',
|
'method_account.getThemes' => 'Get installed themes',
|
||||||
),
|
],
|
||||||
);
|
];
|
||||||
|
|
||||||
// THIS WILL BE OVERWRITTEN BY $lang["en"]
|
// THIS WILL BE OVERWRITTEN BY $lang["en"]
|
||||||
public static $current_lang = array (
|
public static $current_lang = [
|
||||||
'req_pq' => 'Requesting pq...',
|
'req_pq' => 'Requesting pq...',
|
||||||
'done' => 'Done!',
|
'done' => 'Done!',
|
||||||
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
|
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
|
||||||
@ -10327,5 +10327,5 @@ class Lang
|
|||||||
'object_account.themes_param_themes_type_Vector t' => 'Themes',
|
'object_account.themes_param_themes_type_Vector t' => 'Themes',
|
||||||
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
|
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
|
||||||
'method_account.getThemes' => 'Get installed themes',
|
'method_account.getThemes' => 'Get installed themes',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,10 @@ class ReadLoop extends SignalLoop
|
|||||||
*/
|
*/
|
||||||
$session_id = \substr($decrypted_data, 8, 8);
|
$session_id = \substr($decrypted_data, 8, 8);
|
||||||
if ($session_id != $connection->session_id) {
|
if ($session_id != $connection->session_id) {
|
||||||
throw new \danog\MadelineProto\Exception('Session id mismatch.');
|
$connection->resetSession();
|
||||||
|
Tools::callForkDefer($connection->reconnect());
|
||||||
|
return;
|
||||||
|
throw new \danog\MadelineProto\Exception('Session id mismatch');
|
||||||
}
|
}
|
||||||
$message_id = \substr($decrypted_data, 16, 8);
|
$message_id = \substr($decrypted_data, 16, 8);
|
||||||
$connection->check_message_id($message_id, ['outgoing' => false, 'container' => false]);
|
$connection->check_message_id($message_id, ['outgoing' => false, 'container' => false]);
|
||||||
|
@ -84,7 +84,7 @@ class UpdateLoop extends ResumableSignalLoop
|
|||||||
try {
|
try {
|
||||||
$difference = yield $API->method_call_async_read('updates.getChannelDifference', ['channel' => 'channel#'.$this->channelId, 'filter' => ['_' => 'channelMessagesFilterEmpty'], 'pts' => $request_pts, 'limit' => $limit, 'force' => true], ['datacenter' => $API->datacenter->curdc, 'postpone' => $first]);
|
$difference = yield $API->method_call_async_read('updates.getChannelDifference', ['channel' => 'channel#'.$this->channelId, 'filter' => ['_' => 'channelMessagesFilterEmpty'], 'pts' => $request_pts, 'limit' => $limit, 'force' => true], ['datacenter' => $API->datacenter->curdc, 'postpone' => $first]);
|
||||||
} catch (RPCErrorException $e) {
|
} catch (RPCErrorException $e) {
|
||||||
if (\in_array($e->rpc, ['CHANNEL_PRIVATE', 'CHANNEL_INVALID', 'CHAT_FORBIDDEN'])) {
|
if (\in_array($e->rpc, ['CHANNEL_PRIVATE', 'CHAT_FORBIDDEN'])) {
|
||||||
$feeder->signal(true);
|
$feeder->signal(true);
|
||||||
unset($API->updaters[$this->channelId], $API->feeders[$this->channelId]);
|
unset($API->updaters[$this->channelId], $API->feeders[$this->channelId]);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ use danog\MadelineProto\Loop\Update\FeedLoop;
|
|||||||
use danog\MadelineProto\Loop\Update\SeqLoop;
|
use danog\MadelineProto\Loop\Update\SeqLoop;
|
||||||
use danog\MadelineProto\Loop\Update\UpdateLoop;
|
use danog\MadelineProto\Loop\Update\UpdateLoop;
|
||||||
use danog\MadelineProto\MTProtoTools\CombinedUpdatesState;
|
use danog\MadelineProto\MTProtoTools\CombinedUpdatesState;
|
||||||
|
use danog\MadelineProto\MTProtoTools\MinDatabase;
|
||||||
use danog\MadelineProto\MTProtoTools\ReferenceDatabase;
|
use danog\MadelineProto\MTProtoTools\ReferenceDatabase;
|
||||||
use danog\MadelineProto\MTProtoTools\UpdatesState;
|
use danog\MadelineProto\MTProtoTools\UpdatesState;
|
||||||
use danog\MadelineProto\TL\TLCallback;
|
use danog\MadelineProto\TL\TLCallback;
|
||||||
@ -82,7 +83,7 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const V = 131;
|
const V = 132;
|
||||||
/**
|
/**
|
||||||
* String release version.
|
* String release version.
|
||||||
*
|
*
|
||||||
@ -347,6 +348,12 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
* @var \danog\MadelineProto\MTProtoTools\ReferenceDatabase
|
* @var \danog\MadelineProto\MTProtoTools\ReferenceDatabase
|
||||||
*/
|
*/
|
||||||
public $referenceDatabase;
|
public $referenceDatabase;
|
||||||
|
/**
|
||||||
|
* min database.
|
||||||
|
*
|
||||||
|
* @var \danog\MadelineProto\MTProtoTools\MinDatabase
|
||||||
|
*/
|
||||||
|
public $minDatabase;
|
||||||
/**
|
/**
|
||||||
* Phone config loop.
|
* Phone config loop.
|
||||||
*
|
*
|
||||||
@ -433,6 +440,9 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
if (!isset($this->referenceDatabase)) {
|
if (!isset($this->referenceDatabase)) {
|
||||||
$this->referenceDatabase = new ReferenceDatabase($this);
|
$this->referenceDatabase = new ReferenceDatabase($this);
|
||||||
}
|
}
|
||||||
|
if (!isset($this->minDatabase)) {
|
||||||
|
$this->minDatabase = new MinDatabase($this);
|
||||||
|
}
|
||||||
// Load rsa keys
|
// Load rsa keys
|
||||||
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['load_rsa'], Logger::ULTRA_VERBOSE);
|
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['load_rsa'], Logger::ULTRA_VERBOSE);
|
||||||
$this->rsa_keys = [];
|
$this->rsa_keys = [];
|
||||||
@ -445,7 +455,11 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
* Define some needed numbers for BigInteger
|
* Define some needed numbers for BigInteger
|
||||||
*/
|
*/
|
||||||
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['TL_translation'], Logger::ULTRA_VERBOSE);
|
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['TL_translation'], Logger::ULTRA_VERBOSE);
|
||||||
$this->construct_TL($this->settings['tl_schema']['src'], [$this, $this->referenceDatabase]);
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
|
if (!($this->authorization['user']['bot'] ?? false)) {
|
||||||
|
$callbacks []= $this->minDatabase;
|
||||||
|
}
|
||||||
|
$this->construct_TL($this->settings['tl_schema']['src'], $callbacks);
|
||||||
yield $this->connect_to_all_dcs_async();
|
yield $this->connect_to_all_dcs_async();
|
||||||
$this->startLoops();
|
$this->startLoops();
|
||||||
$this->datacenter->curdc = 2;
|
$this->datacenter->curdc = 2;
|
||||||
@ -472,7 +486,7 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
if ($this->settings['serialization']['cleanup_before_serialization']) {
|
if ($this->settings['serialization']['cleanup_before_serialization']) {
|
||||||
$this->cleanup();
|
$this->cleanup();
|
||||||
}
|
}
|
||||||
return ['supportUser', 'referenceDatabase', 'channel_participants', 'event_handler', 'event_handler_instance', 'loop_callback', 'web_template', 'encrypted_layer', 'settings', 'config', 'authorization', 'authorized', 'rsa_keys', 'dh_config', 'chats', 'last_stored', 'qres', 'got_state', 'channels_state', 'updates', 'updates_key', 'full_chats', 'msg_ids', 'dialog_params', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'tl_callbacks', 'temp_requested_secret_chats', 'temp_rekeyed_secret_chats', 'secret_chats', 'hook_url', 'storage', 'authorized_dc', 'tos'];
|
return ['supportUser', 'referenceDatabase', 'minDatabase', 'channel_participants', 'event_handler', 'event_handler_instance', 'loop_callback', 'web_template', 'encrypted_layer', 'settings', 'config', 'authorization', 'authorized', 'rsa_keys', 'dh_config', 'chats', 'last_stored', 'qres', 'got_state', 'channels_state', 'updates', 'updates_key', 'full_chats', 'msg_ids', 'dialog_params', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'tl_callbacks', 'temp_requested_secret_chats', 'temp_rekeyed_secret_chats', 'secret_chats', 'hook_url', 'storage', 'authorized_dc', 'tos'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -484,7 +498,11 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
private function cleanup()
|
private function cleanup()
|
||||||
{
|
{
|
||||||
$this->referenceDatabase = new ReferenceDatabase($this);
|
$this->referenceDatabase = new ReferenceDatabase($this);
|
||||||
$this->update_callbacks([$this, $this->referenceDatabase]);
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
|
if (!($this->authorization['user']['bot'] ?? false)) {
|
||||||
|
$callbacks []= $this->minDatabase;
|
||||||
|
}
|
||||||
|
$this->update_callbacks($callbacks);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +621,14 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
if (!isset($this->referenceDatabase)) {
|
if (!isset($this->referenceDatabase)) {
|
||||||
$this->referenceDatabase = new ReferenceDatabase($this);
|
$this->referenceDatabase = new ReferenceDatabase($this);
|
||||||
}
|
}
|
||||||
$this->update_callbacks([$this, $this->referenceDatabase]);
|
if (!isset($this->minDatabase)) {
|
||||||
|
$this->minDatabase = new MinDatabase($this);
|
||||||
|
}
|
||||||
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
|
if (!($this->authorization['user']['bot'] ?? false)) {
|
||||||
|
$callbacks []= $this->minDatabase;
|
||||||
|
}
|
||||||
|
$this->update_callbacks($callbacks);
|
||||||
|
|
||||||
$this->settings['connection_settings']['all']['ipv6'] = \danog\MadelineProto\Magic::$ipv6;
|
$this->settings['connection_settings']['all']['ipv6'] = \danog\MadelineProto\Magic::$ipv6;
|
||||||
/*if (isset($this->settings['pwr']['update_handler']) && $this->settings['pwr']['update_handler'] === $this->settings['updates']['callback']) {
|
/*if (isset($this->settings['pwr']['update_handler']) && $this->settings['pwr']['update_handler'] === $this->settings['updates']['callback']) {
|
||||||
@ -1243,6 +1268,7 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
$this->users = [];
|
$this->users = [];
|
||||||
$this->tos = ['expires' => 0, 'accepted' => true];
|
$this->tos = ['expires' => 0, 'accepted' => true];
|
||||||
$this->referenceDatabase = new ReferenceDatabase($this);
|
$this->referenceDatabase = new ReferenceDatabase($this);
|
||||||
|
$this->minDatabase = new MinDatabase($this);
|
||||||
$this->dialog_params = ['_' => 'MadelineProto.dialogParams', 'limit' => 0, 'offset_date' => 0, 'offset_id' => 0, 'offset_peer' => ['_' => 'inputPeerEmpty'], 'count' => 0];
|
$this->dialog_params = ['_' => 'MadelineProto.dialogParams', 'limit' => 0, 'offset_date' => 0, 'offset_id' => 0, 'offset_peer' => ['_' => 'inputPeerEmpty'], 'count' => 0];
|
||||||
$this->full_chats = [];
|
$this->full_chats = [];
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ trait PeerHandler
|
|||||||
}
|
}
|
||||||
switch ($user['_']) {
|
switch ($user['_']) {
|
||||||
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 && !$user['min'])) {
|
||||||
$this->logger->logger("Updated user {$user['id']}", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$this->logger->logger("Updated user {$user['id']}", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
$this->chats[$user['id']] = $user;
|
$this->chats[$user['id']] = $user;
|
||||||
$this->cache_pwr_chat($user['id'], false, true);
|
$this->cache_pwr_chat($user['id'], false, true);
|
||||||
}
|
}
|
||||||
// no break
|
break;
|
||||||
case 'userEmpty':
|
case 'userEmpty':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -127,7 +127,7 @@ trait PeerHandler
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 && !$chat['min'])) {
|
||||||
$this->logger->logger("Updated chat $bot_api_id", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$this->logger->logger("Updated chat $bot_api_id", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
|
|
||||||
$this->chats[$bot_api_id] = $chat;
|
$this->chats[$bot_api_id] = $chat;
|
||||||
@ -169,9 +169,6 @@ trait PeerHandler
|
|||||||
if ($e->rpc === 'CHANNEL_PRIVATE') {
|
if ($e->rpc === 'CHANNEL_PRIVATE') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ($e->rpc === 'CHANNEL_INVALID') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -259,7 +256,11 @@ trait PeerHandler
|
|||||||
case 'inputPeerUser':
|
case 'inputPeerUser':
|
||||||
case 'inputUser':
|
case 'inputUser':
|
||||||
case 'peerUser':
|
case 'peerUser':
|
||||||
|
case 'messageEntityMentionName':
|
||||||
|
case 'messageActionChatDeleteUser':
|
||||||
return $id['user_id'];
|
return $id['user_id'];
|
||||||
|
case 'messageActionChatDeleteUser':
|
||||||
|
return $id['inviter_id'];
|
||||||
case 'chat':
|
case 'chat':
|
||||||
case 'chatForbidden':
|
case 'chatForbidden':
|
||||||
case 'chatFull':
|
case 'chatFull':
|
||||||
@ -494,8 +495,8 @@ trait PeerHandler
|
|||||||
$res['InputPeer'] = ['_' => 'inputPeerSelf'];
|
$res['InputPeer'] = ['_' => 'inputPeerSelf'];
|
||||||
$res['InputUser'] = ['_' => 'inputUserSelf'];
|
$res['InputUser'] = ['_' => 'inputUserSelf'];
|
||||||
} elseif (isset($constructor['access_hash'])) {
|
} elseif (isset($constructor['access_hash'])) {
|
||||||
$res['InputPeer'] = ['_' => 'inputPeerUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputPeer'] = ['_' => 'inputPeerUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min']];
|
||||||
$res['InputUser'] = ['_' => 'inputUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputUser'] = ['_' => 'inputUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min']];
|
||||||
} else {
|
} else {
|
||||||
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');
|
||||||
}
|
}
|
||||||
@ -524,13 +525,13 @@ trait PeerHandler
|
|||||||
if (!isset($constructor['access_hash'])) {
|
if (!isset($constructor['access_hash'])) {
|
||||||
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');
|
||||||
}
|
}
|
||||||
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min']];
|
||||||
$res['Peer'] = ['_' => 'peerChannel', 'channel_id' => $constructor['id']];
|
$res['Peer'] = ['_' => 'peerChannel', 'channel_id' => $constructor['id']];
|
||||||
$res['DialogPeer'] = ['_' => 'dialogPeer', 'peer' => $res['Peer']];
|
$res['DialogPeer'] = ['_' => 'dialogPeer', 'peer' => $res['Peer']];
|
||||||
$res['NotifyPeer'] = ['_' => 'notifyPeer', 'peer' => $res['Peer']];
|
$res['NotifyPeer'] = ['_' => 'notifyPeer', 'peer' => $res['Peer']];
|
||||||
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
|
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
|
||||||
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
|
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
|
||||||
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min']];
|
||||||
$res['channel_id'] = $constructor['id'];
|
$res['channel_id'] = $constructor['id'];
|
||||||
$res['bot_api_id'] = $this->to_supergroup($constructor['id']);
|
$res['bot_api_id'] = $this->to_supergroup($constructor['id']);
|
||||||
$res['type'] = $constructor['megagroup'] ? 'supergroup' : 'channel';
|
$res['type'] = $constructor['megagroup'] ? 'supergroup' : 'channel';
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
namespace danog\MadelineProto\MTProtoTools;
|
namespace danog\MadelineProto\MTProtoTools;
|
||||||
|
|
||||||
use danog\MadelineProto\Exception;
|
use danog\MadelineProto\Exception;
|
||||||
|
use danog\MadelineProto\MTProto;
|
||||||
use danog\MadelineProto\TL\TLCallback;
|
use danog\MadelineProto\TL\TLCallback;
|
||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ class ReferenceDatabase implements TLCallback
|
|||||||
private $refresh = false;
|
private $refresh = false;
|
||||||
private $refreshCount = 0;
|
private $refreshCount = 0;
|
||||||
|
|
||||||
public function __construct($API)
|
public function __construct(MTProto $API)
|
||||||
{
|
{
|
||||||
$this->API = $API;
|
$this->API = $API;
|
||||||
$this->init();
|
$this->init();
|
||||||
|
@ -235,7 +235,9 @@ class Magic
|
|||||||
public static function shutdown(int $code = 0)
|
public static function shutdown(int $code = 0)
|
||||||
{
|
{
|
||||||
self::$signaled = true;
|
self::$signaled = true;
|
||||||
if (defined(STDIN::class)) getStdin()->unreference();
|
if (\defined(STDIN::class)) {
|
||||||
|
getStdin()->unreference();
|
||||||
|
}
|
||||||
getInputBufferStream()->unreference();
|
getInputBufferStream()->unreference();
|
||||||
if ($code !== 0) {
|
if ($code !== 0) {
|
||||||
$driver = Loop::get();
|
$driver = Loop::get();
|
||||||
|
@ -18,24 +18,78 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\TL;
|
namespace danog\MadelineProto\TL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for managing TL serialization callbacks.
|
||||||
|
*/
|
||||||
interface TLCallback
|
interface TLCallback
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
const METHOD_CALLBACK = 0;
|
const METHOD_CALLBACK = 0;
|
||||||
const METHOD_BEFORE_CALLBACK = 1;
|
const METHOD_BEFORE_CALLBACK = 1;
|
||||||
const CONSTRUCTOR_CALLBACK = 2;
|
const CONSTRUCTOR_CALLBACK = 2;
|
||||||
const CONSTRUCTOR_BEFORE_CALLBACK = 3;
|
const CONSTRUCTOR_BEFORE_CALLBACK = 3;
|
||||||
const CONSTRUCTOR_SERIALIZE_CALLBACK = 4;
|
const CONSTRUCTOR_SERIALIZE_CALLBACK = 4;
|
||||||
|
/**
|
||||||
|
* Called if objects of the specified type cannot be serialized.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
const TYPE_MISMATCH_CALLBACK = 5;
|
const TYPE_MISMATCH_CALLBACK = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after serialization of method.
|
||||||
|
*
|
||||||
|
* Pass the method name and arguments
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getMethodCallbacks(): array;
|
public function getMethodCallbacks(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called right before serialization of method starts.
|
||||||
|
*
|
||||||
|
* Pass the method name
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getMethodBeforeCallbacks(): array;
|
public function getMethodBeforeCallbacks(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called right after deserialization of object, passing the final object.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getConstructorCallbacks(): array;
|
public function getConstructorCallbacks(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called right before deserialization of object.
|
||||||
|
*
|
||||||
|
* Pass only the constructor name
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getConstructorBeforeCallbacks(): array;
|
public function getConstructorBeforeCallbacks(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called right before serialization of constructor.
|
||||||
|
*
|
||||||
|
* Passed the object, will return a modified version.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getConstructorSerializeCallbacks(): array;
|
public function getConstructorSerializeCallbacks(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called if objects of the specified type cannot be serialized.
|
||||||
|
*
|
||||||
|
* Passed the unserializable object,
|
||||||
|
* will try to convert it to an object of the proper type.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public function getTypeMismatchCallbacks(): array;
|
public function getTypeMismatchCallbacks(): array;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ trait Login
|
|||||||
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['already_logged_in'], \danog\MadelineProto\Logger::NOTICE);
|
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['already_logged_in'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
yield $this->logout_async();
|
yield $this->logout_async();
|
||||||
}
|
}
|
||||||
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
|
$this->update_callbacks($callbacks);
|
||||||
|
|
||||||
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['login_bot'], \danog\MadelineProto\Logger::NOTICE);
|
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['login_bot'], \danog\MadelineProto\Logger::NOTICE);
|
||||||
$this->authorization = yield $this->method_call_async_read('auth.importBotAuthorization', ['bot_auth_token' => $token, 'api_id' => $this->settings['app_info']['api_id'], 'api_hash' => $this->settings['app_info']['api_hash']], ['datacenter' => $this->datacenter->curdc]);
|
$this->authorization = yield $this->method_call_async_read('auth.importBotAuthorization', ['bot_auth_token' => $token, 'api_id' => $this->settings['app_info']['api_id'], 'api_hash' => $this->settings['app_info']['api_hash']], ['datacenter' => $this->datacenter->curdc]);
|
||||||
$this->authorized = self::LOGGED_IN;
|
$this->authorized = self::LOGGED_IN;
|
||||||
@ -152,6 +155,12 @@ trait Login
|
|||||||
|
|
||||||
$res = yield $this->get_self_async();
|
$res = yield $this->get_self_async();
|
||||||
|
|
||||||
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
|
if (!($this->authorization['user']['bot'] ?? false)) {
|
||||||
|
$callbacks []= $this->minDatabase;
|
||||||
|
}
|
||||||
|
$this->update_callbacks($callbacks);
|
||||||
|
|
||||||
$this->startUpdateSystem();
|
$this->startUpdateSystem();
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
Loading…
Reference in New Issue
Block a user