1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 23:11:19 +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\Promise;
use danog\MadelineProto\APIWrapper;
use danog\MadelineProto\Exception;
use danog\MadelineProto\FileCallbackInterface;
use danog\MadelineProto\Logger;
@ -38,22 +37,23 @@ 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;
@ -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.

View File

@ -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
}