mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 20:54:42 +01:00
parent
04adbcd115
commit
ed5ac03b7c
@ -13,4 +13,7 @@
|
||||
<file name="src/danog/MadelineProto/InternalDoc.php" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
<issueHandlers>
|
||||
<ParamNameMismatch errorLevel="suppress" />
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
|
@ -21,7 +21,6 @@ declare(strict_types=1);
|
||||
namespace danog\MadelineProto;
|
||||
|
||||
use Amp\Cancellation;
|
||||
use Amp\NullCancellation;
|
||||
use Amp\Socket\ConnectContext;
|
||||
use Amp\Socket\EncryptableSocket;
|
||||
use Amp\Socket\SocketAddress;
|
||||
@ -44,8 +43,9 @@ class ContextConnector implements SocketConnector
|
||||
foreach ($ctxs as $ctx) {
|
||||
try {
|
||||
$ctx->setIsDns($this->fromDns);
|
||||
if ($cancellation)
|
||||
$ctx->setCancellation($cancellation);
|
||||
if ($cancellation) {
|
||||
$ctx->setCancellation($cancellation);
|
||||
}
|
||||
$result = ($ctx->getStream());
|
||||
$logger->logger('OK!', Logger::WARNING);
|
||||
return $result->getSocket();
|
||||
|
@ -20,7 +20,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto;
|
||||
|
||||
use Amp\Dns\Resolver;
|
||||
use Amp\Dns\DnsResolver;
|
||||
use Amp\Http\Client\Cookie\CookieJar;
|
||||
use Amp\Http\Client\HttpClient;
|
||||
use Amp\Http\Client\Request;
|
||||
@ -268,7 +268,7 @@ class DataCenter
|
||||
return $this->dohWrapper->HTTPClient;
|
||||
}
|
||||
|
||||
public function getDNSClient(): Resolver
|
||||
public function getDNSClient(): DnsResolver
|
||||
{
|
||||
return $this->dohWrapper->DoHClient;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto\Db;
|
||||
|
||||
use Amp\Mysql\ConnectionConfig;
|
||||
use Amp\Mysql\MysqlConfig;
|
||||
use danog\MadelineProto\Db\Driver\Mysql;
|
||||
use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Logger;
|
||||
@ -72,7 +72,7 @@ class MysqlArray extends SqlArray
|
||||
*/
|
||||
public function initConnection(DatabaseMysql $settings): void
|
||||
{
|
||||
$config = ConnectionConfig::fromString('host='.\str_replace('tcp://', '', $settings->getUri()));
|
||||
$config = MysqlConfig::fromString('host='.\str_replace('tcp://', '', $settings->getUri()));
|
||||
$host = $config->getHost();
|
||||
$port = $config->getPort();
|
||||
$this->pdo = new PDO(
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto\Db;
|
||||
|
||||
use Amp\Postgres\ConnectionConfig;
|
||||
use Amp\Postgres\PostgresConfig;
|
||||
use danog\MadelineProto\Db\Driver\Postgres;
|
||||
use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Logger;
|
||||
@ -73,7 +73,7 @@ class PostgresArray extends SqlArray
|
||||
*/
|
||||
public function initConnection(DatabasePostgres $settings): void
|
||||
{
|
||||
$config = ConnectionConfig::fromString('host='.\str_replace('tcp://', '', $settings->getUri()));
|
||||
$config = PostgresConfig::fromString('host='.\str_replace('tcp://', '', $settings->getUri()));
|
||||
$host = $config->getHost();
|
||||
$port = $config->getPort();
|
||||
$this->pdo = new PDO(
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types=1);
|
||||
namespace danog\MadelineProto;
|
||||
|
||||
use Amp\DeferredFuture;
|
||||
use Amp\Dns\Resolver;
|
||||
use Amp\Dns\DnsResolver;
|
||||
use Amp\Future;
|
||||
use Amp\Http\Client\HttpClient;
|
||||
use Closure;
|
||||
@ -889,7 +889,7 @@ class MTProto implements TLCallback, LoggerGetter
|
||||
/**
|
||||
* Get async DNS client.
|
||||
*/
|
||||
public function getDNSClient(): Resolver
|
||||
public function getDNSClient(): DnsResolver
|
||||
{
|
||||
return $this->datacenter->getDNSClient();
|
||||
}
|
||||
|
@ -405,6 +405,7 @@ trait AuthKeyHandler
|
||||
if (!$cdn) {
|
||||
throw new SecurityException('Auth Failed, please check the logfile for more information, make sure to install https://prime.madelineproto.xyz!');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Factorize number asynchronously using the wolfram API.
|
||||
@ -436,7 +437,7 @@ trait AuthKeyHandler
|
||||
if (\is_int($newval)) {
|
||||
$fres = $newval;
|
||||
}
|
||||
return $fres;
|
||||
return (int) $fres;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -210,6 +210,6 @@ trait CallHandler
|
||||
$aargs['promise'] ?? null
|
||||
);
|
||||
$aargs['postpone'] ??= false;
|
||||
$this->sendMessage($message, !$aargs['postpone'])->await();
|
||||
$this->sendMessage($message, !$aargs['postpone']);
|
||||
}
|
||||
}
|
||||
|
@ -961,11 +961,6 @@ trait Files
|
||||
*/
|
||||
private function downloadPart(array &$messageMedia, bool &$cdn, int &$datacenter, ?int &$old_dc, ?IGE &$ige, callable $cb, array $offset, callable $callable, bool $seekable, bool $postpone = false): int
|
||||
{
|
||||
static $method = [
|
||||
false => 'upload.getFile',
|
||||
// non-cdn
|
||||
true => 'upload.getCdnFile',
|
||||
];
|
||||
do {
|
||||
if (!$cdn) {
|
||||
$basic_param = ['location' => $messageMedia['InputFileLocation']];
|
||||
@ -975,7 +970,11 @@ trait Files
|
||||
//$x = 0;
|
||||
while (true) {
|
||||
try {
|
||||
$res = $this->methodCallAsyncRead($method[$cdn], $basic_param + $offset, ['heavy' => true, 'file' => true, 'FloodWaitLimit' => 0, 'datacenter' => &$datacenter, 'postpone' => $postpone]);
|
||||
$res = $this->methodCallAsyncRead(
|
||||
$cdn ? 'upload.getCdnFile' : 'upload.getFile',
|
||||
$basic_param + $offset,
|
||||
['heavy' => true, 'file' => true, 'FloodWaitLimit' => 0, 'datacenter' => &$datacenter, 'postpone' => $postpone]
|
||||
);
|
||||
break;
|
||||
} catch (RPCErrorException $e) {
|
||||
if (\strpos($e->rpc, 'FLOOD_WAIT_') === 0) {
|
||||
|
@ -480,7 +480,7 @@ trait PeerHandler
|
||||
if (\is_string($id)) {
|
||||
if (\strpos($id, '#') !== false) {
|
||||
if (\preg_match('/^channel#(\\d*)/', $id, $matches)) {
|
||||
return $this->toSupergroup($matches[1]);
|
||||
return $this->toSupergroup((int) $matches[1]);
|
||||
}
|
||||
if (\preg_match('/^chat#(\\d*)/', $id, $matches)) {
|
||||
$id = '-'.$matches[1];
|
||||
|
@ -35,7 +35,7 @@ trait MessageHandler
|
||||
/**
|
||||
* Secret queue.
|
||||
*
|
||||
* @var array<Promise>
|
||||
* @var array<Future<null>>
|
||||
*/
|
||||
private array $secretQueue = [];
|
||||
/**
|
||||
@ -61,7 +61,7 @@ trait MessageHandler
|
||||
if (isset($this->secretQueue[$chat_id])) {
|
||||
$promise = $this->secretQueue[$chat_id];
|
||||
$this->secretQueue[$chat_id] = $queuePromise->getFuture();
|
||||
$promise;
|
||||
$promise->await();
|
||||
} else {
|
||||
$this->secretQueue[$chat_id] = $queuePromise->getFuture();
|
||||
}
|
||||
|
@ -20,9 +20,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto\TL;
|
||||
|
||||
use danog\MadelineProto\MTProto\OutgoingMessage;
|
||||
|
||||
/**
|
||||
* @psalm-type TBeforeMethodResponseDeserialization=Closure(string): void
|
||||
* @psalm-type TAfterMethodResponseDeserialization=Closure(string, array): void
|
||||
* @psalm-type TAfterMethodResponseDeserialization=Closure(OutgoingMessage, array): void
|
||||
*
|
||||
* @psalm-type TBeforeConstructorSerialization=Closure(array): mixed
|
||||
* @psalm-type TBeforeConstructorDeserialization=Closure(string): void
|
||||
|
Loading…
Reference in New Issue
Block a user