Various bugfixes

This commit is contained in:
Daniil Gentili 2019-06-02 16:23:49 +02:00
parent f0b51da9cf
commit df98df1446
6 changed files with 12 additions and 10 deletions

View File

@ -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(''));
}
}

View File

@ -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;
}

View File

@ -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') {

View File

@ -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'];

View File

@ -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']);

View File

@ -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]);