diff --git a/bot.php b/bot.php index c006789b5..2c717ef30 100755 --- a/bot.php +++ b/bot.php @@ -16,8 +16,6 @@ set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelinePro * Various ways to load MadelineProto */ if (!file_exists(__DIR__.'/vendor/autoload.php')) { - echo 'You did not run composer update, using madeline.php'.PHP_EOL; - define('MADELINE_BRANCH', ''); if (!file_exists('madeline.php')) { copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php'); } @@ -41,10 +39,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler } $res = json_encode($update, JSON_PRETTY_PRINT); - if ($res == '') { - $res = var_export($update, true); - } - //yield $this->sleep(3); + try { yield $this->messages->sendMessage(['peer' => $update, 'message' => "$res", 'reply_to_msg_id' => isset($update['message']['id']) ? $update['message']['id'] : null, 'parse_mode' => 'HTML']); //'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]); if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') { @@ -52,10 +47,10 @@ class EventHandler extends \danog\MadelineProto\EventHandler //yield $this->download_to_dir($update, '/tmp') } } catch (\danog\MadelineProto\RPCErrorException $e) { - \danog\MadelineProto\Logger::log((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR); + $this->logger((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR); } catch (\danog\MadelineProto\Exception $e) { if (stripos($e->getMessage(), 'invalid constructor given') === false) { - \danog\MadelineProto\Logger::log((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR); + $this->logger((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR); } //$this->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]); } diff --git a/docs b/docs index aa2c729ab..71da319e2 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit aa2c729ab58df6fd79753083bc3c5930d006efce +Subproject commit 71da319e21f27e0c6fdc620d170c16600facf99d diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 7114336de..492ef277a 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -439,11 +439,11 @@ class MTProto extends AsyncConstruct implements TLCallback } } - if (!$this->settings['updates']['handle_old_updates']) { + /*if (!$this->settings['updates']['handle_old_updates']) { $this->channels_state = new CombinedUpdatesState(); $this->msg_ids = []; $this->got_state = false; - } + }*/ yield $this->connect_to_all_dcs_async(); foreach ($this->calls as $id => $controller) { if (!is_object($controller)) { diff --git a/src/danog/MadelineProto/Stream/ConnectionContext.php b/src/danog/MadelineProto/Stream/ConnectionContext.php index 18cd42659..b284e6af6 100644 --- a/src/danog/MadelineProto/Stream/ConnectionContext.php +++ b/src/danog/MadelineProto/Stream/ConnectionContext.php @@ -21,6 +21,7 @@ namespace danog\MadelineProto\Stream; use Amp\CancellationToken; use Amp\Socket\ClientConnectContext; use Amp\Uri\Uri; +use danog\MadelineProto\Stream\Transport\DefaultStream; /** * Connection context class. @@ -360,7 +361,7 @@ class ConnectionContext $string .= ' => '; } $string .= preg_replace('/.*\\\\/', '', $stream[0]); - if ($stream[1]) { + if ($stream[1] && $stream[0] !== DefaultStream::getName()) { $string .= ' ('.json_encode($stream[1]).')'; } }