diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index 45f4d3b1..00885c1e 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -26,6 +26,8 @@ use Amp\ByteStream\ResourceOutputStream; class Logger { + use Tools; + const foreground = ['default' => 39, 'black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'light_gray' => 37, 'dark_gray' => 90, 'light_red' => 91, 'light_green' => 92, 'light_yellow' => 93, 'light_blue' => 94, 'light_magenta' => 95, 'light_cyan' => 96, 'white' => 97]; const background = ['default' => 49, 'black' => 40, 'red' => 41, 'magenta' => 45, 'yellow' => 43, 'green' => 42, 'blue' => 44, 'cyan' => 46, 'light_gray' => 47, 'dark_gray' => 100, 'light_red' => 101, 'light_green' => 102, 'light_yellow' => 103, 'light_blue' => 104, 'light_magenta' => 105, 'light_cyan' => 106, 'white' => 107]; const set = ['bold' => 1, 'dim' => 2, 'underlined' => 3, 'blink' => 4, 'reverse' => 5, 'hidden' => 6]; @@ -159,4 +161,8 @@ class Logger break; } } + public function __destruct() + { + $this->wait($this->stdout->write('')); + } } diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index 8458fc3d..9757f94d 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -163,7 +163,7 @@ class FeedLoop extends ResumableSignalLoop $channelId = $update['channel_id']; break; case 'updateChannelTooLong': - $channelId = $update['channel_id']; + $channelId = isset($update['channel_id']) ? $update['channel_id'] : false; if (!isset($update['pts'])) { $update['pts'] = 1; } diff --git a/src/danog/MadelineProto/MTProtoTools/PasswordCalculator.php b/src/danog/MadelineProto/MTProtoTools/PasswordCalculator.php index 056a8c40..2120b037 100644 --- a/src/danog/MadelineProto/MTProtoTools/PasswordCalculator.php +++ b/src/danog/MadelineProto/MTProtoTools/PasswordCalculator.php @@ -39,11 +39,6 @@ class PasswordCalculator private $srp_BForHash; private $srp_id; - public function __construct($logger) - { - $this->logger = $logger; - } - public function addInfo(array $object) { if ($object['_'] !== 'account.password') { diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 9293d4ea..1ec386bb 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -255,11 +255,11 @@ trait PeerHandler case 'updateChannel': case 'updateChannelWebPage': case 'updateChannelMessageViews': - case 'updateChannelTooLong': case 'updateReadChannelInbox': case 'updateReadChannelOutbox': case 'updateDeleteChannelMessages': case 'updateChannelPinnedMessage': + case 'updateChannelTooLong': return $this->to_supergroup($id['channel_id']); case 'updateChatParticipants': $id = $id['participants']; diff --git a/src/danog/MadelineProto/Magic.php b/src/danog/MadelineProto/Magic.php index 99d1aa09..fb2579fb 100644 --- a/src/danog/MadelineProto/Magic.php +++ b/src/danog/MadelineProto/Magic.php @@ -102,6 +102,7 @@ class Magic if (php_sapi_name() === 'cli' && !(class_exists('\\Phar') && \Phar::running())) { try { $back = debug_backtrace(0); + define('AMP_WORKER', 1); $promise = \Amp\File\get(end($back)['file']); do { try { @@ -119,7 +120,7 @@ class Magic } } if (!self::$can_parallel && !defined('AMP_WORKER') || true) { - define('AMP_WORKER', 1); + //define('AMP_WORKER', 1); } $backtrace = debug_backtrace(0); self::$script_cwd = self::$cwd = dirname(end($backtrace)['file']); diff --git a/src/danog/MadelineProto/Wrappers/Login.php b/src/danog/MadelineProto/Wrappers/Login.php index a4406ea7..1a119acc 100644 --- a/src/danog/MadelineProto/Wrappers/Login.php +++ b/src/danog/MadelineProto/Wrappers/Login.php @@ -198,7 +198,7 @@ trait Login throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['2fa_uncalled']); } $this->authorized = self::NOT_LOGGED_IN; - $hasher = new PasswordCalculator($this->logger); + $hasher = new PasswordCalculator(); $hasher->addInfo($this->authorization); $this->logger->logger(\danog\MadelineProto\Lang::$current_lang['login_user'], \danog\MadelineProto\Logger::NOTICE); $this->authorization = yield $this->method_call_async_read('auth.checkPassword', ['password' => $hasher->getCheckPassword($password)], ['datacenter' => $this->datacenter->curdc]); @@ -214,7 +214,7 @@ trait Login public function update_2fa_async(array $params) { - $hasher = new PasswordCalculator($this->logger); + $hasher = new PasswordCalculator(); $hasher->addInfo(yield $this->method_call_async_read('account.getPassword', [], ['datacenter' => $this->datacenter->curdc])); return yield $this->method_call_async_read('account.updatePasswordSettings', $hasher->getPassword($params), ['datacenter' => $this->datacenter->curdc]);