From 287bb645985d611f5993b088d43e3f4cfe1e4076 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 9 Apr 2021 18:20:29 +0200 Subject: [PATCH] Bypass flood --- src/danog/MadelineProto/Ipc/Client.php | 16 +++++++++------- tests/makephar.sh | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/danog/MadelineProto/Ipc/Client.php b/src/danog/MadelineProto/Ipc/Client.php index ae330737a..b0e5f5b34 100644 --- a/src/danog/MadelineProto/Ipc/Client.php +++ b/src/danog/MadelineProto/Ipc/Client.php @@ -20,7 +20,6 @@ namespace danog\MadelineProto\Ipc; use Amp\Ipc\Sync\ChannelledSocket; use Amp\Promise; -use danog\MadelineProto\APIWrapper; use danog\MadelineProto\Exception; use danog\MadelineProto\FileCallbackInterface; use danog\MadelineProto\Logger; @@ -38,25 +37,26 @@ class Client extends ClientAbstract use FilesLogic; /** - * Instances + * Instances. */ private static array $instances = []; /** - * Returns an instance of a client by session name + * Returns an instance of a client by session name. * * @param string $session * @return Client */ - public static function giveInstanceBySession(string $session): Client { + public static function giveInstanceBySession(string $session): Client + { return self::$instances[$session]; } /** - * Whether the wrapper API is async + * Whether the wrapper API is async. */ public bool $async; - + /** * Session. */ @@ -101,7 +101,9 @@ class Client extends ClientAbstract } catch (\Throwable $e) { $this->logger("An error occurred while disconnecting the client: $e"); } - unset(self::$instances[$this->session->getLegacySessionPath()]); + if (isset(self::$instances[$this->session->getLegacySessionPath()])) { + unset(self::$instances[$this->session->getLegacySessionPath()]); + } } /** * Stop IPC server instance. diff --git a/tests/makephar.sh b/tests/makephar.sh index 0a1225980..2ea093343 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -144,6 +144,7 @@ runTestSimple() } runTest() { +return [ "$1" != "" ] && p="$1" || p=php echo "m $API_ID @@ -162,6 +163,7 @@ n k() { +return while :; do pkill -f 'MadelineProto worker .*' || break && sleep 1; done }