Allow call API methods.

This commit is contained in:
Alexander Pankratov 2023-05-19 17:25:07 +02:00
parent a5d7ea6e13
commit 6ee61530c4

View File

@ -11,6 +11,7 @@ use Amp\Http\Server\Response;
use Amp\Http\Server\Router; use Amp\Http\Server\Router;
use danog\MadelineProto\API; use danog\MadelineProto\API;
use JsonException; use JsonException;
use TelegramApiServer\Client;
use TelegramApiServer\Exceptions\NoticeException; use TelegramApiServer\Exceptions\NoticeException;
use TelegramApiServer\Logger; use TelegramApiServer\Logger;
use TelegramApiServer\MadelineProtoExtensions\ApiExtensions; use TelegramApiServer\MadelineProtoExtensions\ApiExtensions;
@ -163,6 +164,11 @@ abstract class AbstractApiController
$madelineProtoExtensions = new $this->extensionClass($madelineProto, $this->request, $this->file); $madelineProtoExtensions = new $this->extensionClass($madelineProto, $this->request, $this->file);
$result = $madelineProtoExtensions->{$this->api[0]}(...$this->parameters); $result = $madelineProtoExtensions->{$this->api[0]}(...$this->parameters);
} else { } else {
if ($this->api[0] === 'API') {
$madelineProto = Client::getWrapper($madelineProto)->getAPI();
array_shift($this->api);
$pathCount = count($this->api);
}
//Проверяем нет ли в MadilineProto такого метода. //Проверяем нет ли в MadilineProto такого метода.
switch ($pathCount) { switch ($pathCount) {
case 1: case 1: