diff --git a/docs b/docs index 648b0a12..a17ccba8 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 648b0a1250e3949c631421b8f1666371567f74c7 +Subproject commit a17ccba895f5e980947264f929611e157aa7c35c diff --git a/examples/combinedBot.php b/examples/combinedBot.php index 43822a11..0bbd0bb5 100755 --- a/examples/combinedBot.php +++ b/examples/combinedBot.php @@ -24,7 +24,6 @@ use danog\MadelineProto\EventHandler; use danog\MadelineProto\Exception; use danog\MadelineProto\Logger; use danog\MadelineProto\RPCErrorException; -use danog\MadelineProto\Tools; /* * Various ways to load MadelineProto @@ -106,4 +105,4 @@ foreach ([ $MadelineProtos []= new API($session); } -API::startAndLoopMulti($MadelineProtos, MyEventHandler::class); \ No newline at end of file +API::startAndLoopMulti($MadelineProtos, MyEventHandler::class); diff --git a/examples/index.php b/examples/index.php index 7674500a..5be305ad 100644 --- a/examples/index.php +++ b/examples/index.php @@ -18,7 +18,7 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -require 'vendor/autoload.php'; +require '../vendor/autoload.php'; $MadelineProto = new \danog\MadelineProto\API('session.madeline'); $me = $MadelineProto->start(); diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index b05f1b90..2e76c7ea 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -139,6 +139,7 @@ class API extends InternalDoc if (isset($this->API)) { $this->storage = $this->API->storage ?? $this->storage; + $unserialized->oldInstance = true; unset($unserialized); yield from $this->API->initAsynchronously(); @@ -172,7 +173,7 @@ class API extends InternalDoc { $this->init(); if (!$this->oldInstance) { - $this->logger('Shutting down MadelineProto (API)'); + $this->logger->logger('Shutting down MadelineProto (API)'); if ($this->API) { $this->API->destructing = true; } @@ -180,18 +181,9 @@ class API extends InternalDoc Tools::wait($this->wrapper->serialize(), true); $this->API->unreference(); } else { - $this->logger('Shutting down MadelineProto (old deserialized instance of API)'); + $this->logger->logger('Shutting down MadelineProto (old deserialized instance of API)'); } } - /** - * Wakeup function. - * - * @return void - */ - public function __wakeup(): void - { - $this->oldInstance = true; - } /** * Init API wrapper. * @@ -230,7 +222,7 @@ class API extends InternalDoc Tools::wait($this->startAndLoopAsync($eventHandler)); return; } catch (\Throwable $e) { - $this->logger((string) $e, Logger::FATAL_ERROR); + $this->logger->logger((string) $e, Logger::FATAL_ERROR); $this->report("Surfaced: $e"); } } @@ -249,7 +241,7 @@ class API extends InternalDoc $eventHandler = \array_fill_keys(\array_keys($instances), $eventHandler); } - $instanceOne = array_values($instances)[0]; + $instanceOne = \array_values($instances)[0]; while (true) { try { $promises = []; @@ -283,7 +275,7 @@ class API extends InternalDoc yield $this->setEventHandler($eventHandler); return yield from $this->API->loop(); } catch (\Throwable $e) { - $this->logger((string) $e, Logger::FATAL_ERROR); + $this->logger->logger((string) $e, Logger::FATAL_ERROR); $this->report("Surfaced: $e"); } }