From 0d0047ad76a9921364965545eca3bfe4c127a0cf Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 7 Apr 2021 17:28:34 +0200 Subject: [PATCH] BC for GenericLoop --- src/danog/MadelineProto/API.php | 3 +++ .../MadelineProto/Loop/Generic/GenericLoop.php | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index ba3c9d471..b369d80a9 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -225,6 +225,9 @@ class API extends InternalDoc protected function reconnectFull(): \Generator { if ($this->API instanceof Client) { + if (yield $this->API->hasEventHandler()) { + return; + } yield $this->API->stopIpcServer(); yield $this->API->disconnect(); yield from $this->connectToMadelineProto(new SettingsEmpty, true); diff --git a/src/danog/MadelineProto/Loop/Generic/GenericLoop.php b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php index d82b43811..dac88d7d0 100644 --- a/src/danog/MadelineProto/Loop/Generic/GenericLoop.php +++ b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php @@ -19,6 +19,7 @@ namespace danog\MadelineProto\Loop\Generic; +use Amp\Promise; use danog\Loop\Generic\GenericLoop as GenericGenericLoop; use danog\MadelineProto\InternalDoc; use danog\MadelineProto\Loop\APILoop; @@ -45,4 +46,16 @@ class GenericLoop extends GenericGenericLoop $this->init($API); parent::__construct($callable, $name); } + + /** + * Pause the loop. + * + * @param ?int $time For how long to pause the loop, if null will pause forever (until resume is called from outside of the loop) + * + * @return Promise Resolved when the loop is resumed + */ + public function pause(?int $time = null): Promise + { + return parent::pause(is_integer($time) ? $time * 1000 : $time); + } }