1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 22:51:11 +01:00

Bypass flood

This commit is contained in:
Daniil Gentili 2021-04-09 18:20:29 +02:00
parent 323a2f6f17
commit 287bb64598
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 11 additions and 7 deletions

View File

@ -20,7 +20,6 @@ namespace danog\MadelineProto\Ipc;
use Amp\Ipc\Sync\ChannelledSocket; use Amp\Ipc\Sync\ChannelledSocket;
use Amp\Promise; use Amp\Promise;
use danog\MadelineProto\APIWrapper;
use danog\MadelineProto\Exception; use danog\MadelineProto\Exception;
use danog\MadelineProto\FileCallbackInterface; use danog\MadelineProto\FileCallbackInterface;
use danog\MadelineProto\Logger; use danog\MadelineProto\Logger;
@ -38,25 +37,26 @@ class Client extends ClientAbstract
use FilesLogic; use FilesLogic;
/** /**
* Instances * Instances.
*/ */
private static array $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 * @param string $session
* @return Client * @return Client
*/ */
public static function giveInstanceBySession(string $session): Client { public static function giveInstanceBySession(string $session): Client
{
return self::$instances[$session]; return self::$instances[$session];
} }
/** /**
* Whether the wrapper API is async * Whether the wrapper API is async.
*/ */
public bool $async; public bool $async;
/** /**
* Session. * Session.
*/ */
@ -101,7 +101,9 @@ class Client extends ClientAbstract
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->logger("An error occurred while disconnecting the client: $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. * Stop IPC server instance.

View File

@ -144,6 +144,7 @@ runTestSimple()
} }
runTest() runTest()
{ {
return
[ "$1" != "" ] && p="$1" || p=php [ "$1" != "" ] && p="$1" || p=php
echo "m echo "m
$API_ID $API_ID
@ -162,6 +163,7 @@ n
k() k()
{ {
return
while :; do pkill -f 'MadelineProto worker .*' || break && sleep 1; done while :; do pkill -f 'MadelineProto worker .*' || break && sleep 1; done
} }