diff --git a/src/Client.php b/src/Client.php index 628f7d8..ab2f75d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -86,15 +86,16 @@ class Client $instance = new MadelineProto\API($file, $settings); $instance->async(true); $this->instances[$session] = $instance; + if($startSession === true) { + $instance->loop(function() use($instance) { + yield $instance->start(); + }); + } if (($instance->API->authorized ?? MTProto::NOT_LOGGED_IN) === MTProto::LOGGED_IN) { $instance->setEventHandler(EventHandler::class); Loop::defer(static function() use($instance) { $instance->loop(['async' => true]); }); - } elseif($startSession === true) { - $instance->loop(function() use($instance) { - yield $instance->start(); - }); } }