diff --git a/schemas b/schemas index 5ac5e7a01..09cdf1a24 160000 --- a/schemas +++ b/schemas @@ -1 +1 @@ -Subproject commit 5ac5e7a012be37cf4931c1edc0d516a72793ac16 +Subproject commit 09cdf1a2424fd117585c5d21eca3e5dcdf2a484f diff --git a/src/Exception.php b/src/Exception.php index 01abc494e..0e2d219f9 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -36,7 +36,7 @@ class Exception extends \Exception { return $this->file === 'MadelineProto' ? $this->message : '\\danog\\MadelineProto\\Exception'.($this->message !== '' ? ': ' : '').$this->message.' in '.$this->file.':'.$this->line.PHP_EOL.Magic::$revision.PHP_EOL.'TL Trace:'.PHP_EOL.$this->getTLTrace(); } - public function __construct($message = null, $code = 0, ?self $previous = null, $file = null, $line = null) + public function __construct($message = null, $code = 0, ?\Throwable $previous = null, $file = null, $line = null) { $this->prettifyTL(); if ($file !== null) { diff --git a/src/GarbageCollector.php b/src/GarbageCollector.php index a2684afd8..185e41e85 100644 --- a/src/GarbageCollector.php +++ b/src/GarbageCollector.php @@ -79,11 +79,11 @@ final class GarbageCollector return; } $client = HttpClientBuilder::buildDefault(); - $request = new Request(MADELINE_RELEASE_URL); $id = null; - $cb = function () use ($client, $request, &$id): void { + $cb = function () use ($client, &$id): void { try { + $request = new Request(MADELINE_RELEASE_URL); $latest = $client->request($request); Magic::$latest_release = \trim($latest->getBody()->buffer()); if (API::RELEASE !== Magic::$latest_release) { diff --git a/src/Ipc/Server.php b/src/Ipc/Server.php index 329d14cfe..2f82981dc 100644 --- a/src/Ipc/Server.php +++ b/src/Ipc/Server.php @@ -20,6 +20,7 @@ declare(strict_types=1); namespace danog\MadelineProto\Ipc; +use Amp\CompositeException; use Amp\DeferredFuture; use Amp\Future; use Amp\Ipc\IpcServer; @@ -101,6 +102,7 @@ class Server extends Loop { $id = Tools::randomInt(2000000000); $started = false; + $e = null; try { Logger::log("Starting IPC server $session (process)"); ProcessRunner::start((string) $session, $id); @@ -115,15 +117,20 @@ class Server extends Loop if (WebRunner::start((string) $session, $id)) { $started = true; } - } catch (Throwable $e) { - Logger::log($e); + } catch (Throwable $e2) { + Logger::log($e2); + if ($e) { + $e = new CompositeException([$e, $e2]); + } else { + $e = $e2; + } } - return async(self::monitor(...), $session, $id, $started); + return async(self::monitor(...), $session, $id, $started, $e); } /** * Monitor session. */ - private static function monitor(SessionPaths $session, int $id, bool $started): bool|Throwable + private static function monitor(SessionPaths $session, int $id, bool $started, ?\Throwable $e): bool|Throwable { if (!$started) { Logger::log("It looks like the server couldn't be started, trying to connect anyway..."); @@ -139,7 +146,7 @@ class Server extends Loop Logger::log('IPC server started successfully!'); return true; } elseif (!$started && $count > 0 && $count > 2*($state ? 3 : 1)) { - return new Exception("We couldn't start the IPC server, please check the logs!"); + return new Exception("We couldn't start the IPC server, please check the logs!", previous: $e); } delay(0.5); $count++; diff --git a/src/TL_botAPI.tl b/src/TL_botAPI.tl deleted file mode 100644 index 8c6dfdd08..000000000 --- a/src/TL_botAPI.tl +++ /dev/null @@ -1,19 +0,0 @@ -bot_thumbnail#0 dc_id:int id:long access_hash:long volume_id:long = File; -bot_profile_photo#1 dc_id:int id:long access_hash:long volume_id:long = File; -bot_photo#2 dc_id:int id:long access_hash:long volume_id:long = File; - -bot_voice#3 dc_id:int id:long access_hash:long = File; -bot_video#4 dc_id:int id:long access_hash:long = File; -bot_document#5 dc_id:int id:long access_hash:long = File; -bot_encrypted#6 dc_id:int id:long access_hash:long = File; -bot_temp#7 dc_id:int id:long access_hash:long = File; -bot_sticker#8 dc_id:int id:long access_hash:long = File; -bot_audio#9 dc_id:int id:long access_hash:long = File; -bot_gif#A dc_id:int id:long access_hash:long = File; -bot_encrypted_thumbnail#B dc_id:int id:long access_hash:long = File; -bot_wallpaper#C dc_id:int id:long access_hash:long = File; -bot_video_note#D dc_id:int id:long access_hash:long = File; -bot_secure_raw#F dc_id:int id:long access_hash:long = File; -bot_secure#10 dc_id:int id:long access_hash:long = File; -bot_background#11 dc_id:int id:long access_hash:long = File; -bot_size#12 dc_id:int id:long access_hash:long = File; diff --git a/src/TL_secret.tl b/src/TL_secret.tl index f13743fd3..364fc117e 100644 --- a/src/TL_secret.tl +++ b/src/TL_secret.tl @@ -95,7 +95,7 @@ messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity; messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; ===143=== -decryptedMessageMediaDocument#8e4c064c thumb:bytes thumb_w:int thumb_h:int mime_type:string size:long key:bytes iv:bytes attributes:Vector caption:string = DecryptedMessageMedia; +decryptedMessageMediaDocument#6abd9782 thumb:bytes thumb_w:int thumb_h:int mime_type:string size:long key:bytes iv:bytes attributes:Vector caption:string = DecryptedMessageMedia; ===144=== messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; diff --git a/tools/build_docs/layerUpgrade.php b/tools/build_docs/layerUpgrade.php index 32b7cf7de..85a4dcfc0 100644 --- a/tools/build_docs/layerUpgrade.php +++ b/tools/build_docs/layerUpgrade.php @@ -13,7 +13,7 @@ function layerUpgrade(int $layer): void file_put_contents('docs/docs/docs/USING_METHODS.md', $doc); array_map(unlink::class, glob('src/*.tl')); - foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret', 'TL_botAPI'] as $schema) { + foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret'] as $schema) { copy("schemas/$schema.tl", "src/$schema.tl"); }