Add IPC support to buttons, start writing PHPDOC documentor
This commit is contained in:
parent
0d1ef0aebe
commit
17ed5c0991
@ -44,12 +44,12 @@
|
|||||||
"amphp/websocket-client": "^1.0"
|
"amphp/websocket-client": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"phpdocumentor/reflection-docblock": "^5.2",
|
||||||
"vlucas/phpdotenv": "^3",
|
"vlucas/phpdotenv": "^3",
|
||||||
"phpdocumentor/reflection-docblock": "^4.3",
|
|
||||||
"ennexa/amp-update-cache": "dev-master",
|
"ennexa/amp-update-cache": "dev-master",
|
||||||
"phpunit/phpunit": "^8",
|
"phpunit/phpunit": "^8",
|
||||||
"amphp/php-cs-fixer-config": "dev-master",
|
"amphp/php-cs-fixer-config": "dev-master",
|
||||||
"haydenpierce/class-finder": "^0.4",
|
"haydenpierce/class-finder": "^0.4.2",
|
||||||
"amphp/http-server": "dev-master",
|
"amphp/http-server": "dev-master",
|
||||||
"amphp/http": "^1.6",
|
"amphp/http": "^1.6",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
|
@ -179,7 +179,7 @@ class API extends InternalDoc
|
|||||||
/**
|
/**
|
||||||
* Connect to MadelineProto.
|
* Connect to MadelineProto.
|
||||||
*
|
*
|
||||||
* @param Settings|SettingsEmpty $settings Settings
|
* @param SettingsAbstract $settings Settings
|
||||||
* @param bool $forceFull Whether to force full initialization
|
* @param bool $forceFull Whether to force full initialization
|
||||||
*
|
*
|
||||||
* @return \Generator
|
* @return \Generator
|
||||||
|
@ -210,4 +210,14 @@ final class APIWrapper
|
|||||||
return true;
|
return true;
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get session path.
|
||||||
|
*
|
||||||
|
* @return SessionPaths
|
||||||
|
*/
|
||||||
|
public function getSession(): SessionPaths
|
||||||
|
{
|
||||||
|
return $this->session;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,10 @@ use danog\MadelineProto\Settings\Database\Postgres;
|
|||||||
use danog\MadelineProto\Settings\Database\Redis;
|
use danog\MadelineProto\Settings\Database\Redis;
|
||||||
use danog\MadelineProto\Settings\DatabaseAbstract;
|
use danog\MadelineProto\Settings\DatabaseAbstract;
|
||||||
|
|
||||||
class DbPropertiesFactory
|
/**
|
||||||
|
* This factory class initializes the correct database backend for MadelineProto.
|
||||||
|
*/
|
||||||
|
abstract class DbPropertiesFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates a simple K-V array stored in a database backend.
|
* Indicates a simple K-V array stored in a database backend.
|
||||||
@ -24,6 +27,8 @@ class DbPropertiesFactory
|
|||||||
*
|
*
|
||||||
* @return Promise<DbType>
|
* @return Promise<DbType>
|
||||||
*
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
* @uses \danog\MadelineProto\Db\MemoryArray
|
* @uses \danog\MadelineProto\Db\MemoryArray
|
||||||
* @uses \danog\MadelineProto\Db\MysqlArray
|
* @uses \danog\MadelineProto\Db\MysqlArray
|
||||||
* @uses \danog\MadelineProto\Db\PostgresArray
|
* @uses \danog\MadelineProto\Db\PostgresArray
|
||||||
|
@ -4,6 +4,15 @@ namespace danog\MadelineProto\Db;
|
|||||||
|
|
||||||
use danog\MadelineProto\MTProto;
|
use danog\MadelineProto\MTProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include this trait and call DbPropertiesTrait::initDb to use MadelineProto's database backend for properties.
|
||||||
|
*
|
||||||
|
* You will have to define a `$dbProperties` static array property, with a list of properties you want to store to a database.
|
||||||
|
*
|
||||||
|
* @see DbPropertiesFactory For a list of allowed property types
|
||||||
|
*
|
||||||
|
* @property array<string, DbPropertiesFactory::TYPE_*> $dbProperties
|
||||||
|
*/
|
||||||
trait DbPropertiesTrait
|
trait DbPropertiesTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,9 @@ use danog\MadelineProto\Settings\Database\Mysql as DatabaseMysql;
|
|||||||
|
|
||||||
use function Amp\Mysql\Pool;
|
use function Amp\Mysql\Pool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL driver wrapper.
|
||||||
|
*/
|
||||||
class Mysql
|
class Mysql
|
||||||
{
|
{
|
||||||
/** @var Pool[] */
|
/** @var Pool[] */
|
||||||
|
@ -9,6 +9,9 @@ use danog\MadelineProto\Settings\Database\Postgres as DatabasePostgres;
|
|||||||
|
|
||||||
use function Amp\Postgres\Pool;
|
use function Amp\Postgres\Pool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postgres driver wrapper.
|
||||||
|
*/
|
||||||
class Postgres
|
class Postgres
|
||||||
{
|
{
|
||||||
/** @var Pool[] */
|
/** @var Pool[] */
|
||||||
|
@ -7,6 +7,9 @@ use Amp\Redis\Redis as RedisRedis;
|
|||||||
use Amp\Redis\RemoteExecutorFactory;
|
use Amp\Redis\RemoteExecutorFactory;
|
||||||
use danog\MadelineProto\Settings\Database\Redis as DatabaseRedis;
|
use danog\MadelineProto\Settings\Database\Redis as DatabaseRedis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis driver wrapper.
|
||||||
|
*/
|
||||||
class Redis
|
class Redis
|
||||||
{
|
{
|
||||||
/** @var RedisRedis[] */
|
/** @var RedisRedis[] */
|
||||||
|
@ -10,6 +10,9 @@ use danog\MadelineProto\Settings\Database\Memory;
|
|||||||
|
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memory database backend.
|
||||||
|
*/
|
||||||
class MemoryArray extends \ArrayIterator implements DbArray
|
class MemoryArray extends \ArrayIterator implements DbArray
|
||||||
{
|
{
|
||||||
protected function __construct($array = [], $flags = 0)
|
protected function __construct($array = [], $flags = 0)
|
||||||
|
@ -13,6 +13,9 @@ use danog\MadelineProto\Settings\Database\Mysql as DatabaseMysql;
|
|||||||
|
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL database backend.
|
||||||
|
*/
|
||||||
class MysqlArray extends SqlArray
|
class MysqlArray extends SqlArray
|
||||||
{
|
{
|
||||||
protected string $table;
|
protected string $table;
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Db\NullCache;
|
|||||||
|
|
||||||
use danog\MadelineProto\Db\MysqlArray as DbMysqlArray;
|
use danog\MadelineProto\Db\MysqlArray as DbMysqlArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL database backend, no caching.
|
||||||
|
*/
|
||||||
class MysqlArray extends DbMysqlArray
|
class MysqlArray extends DbMysqlArray
|
||||||
{
|
{
|
||||||
use NullCacheTrait;
|
use NullCacheTrait;
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Db\NullCache;
|
namespace danog\MadelineProto\Db\NullCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trait that disables database caching.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
trait NullCacheTrait
|
trait NullCacheTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Db\NullCache;
|
|||||||
|
|
||||||
use danog\MadelineProto\Db\PostgresArray as DbPostgresArray;
|
use danog\MadelineProto\Db\PostgresArray as DbPostgresArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postgres database backend, no caching.
|
||||||
|
*/
|
||||||
class PostgresArray extends DbPostgresArray
|
class PostgresArray extends DbPostgresArray
|
||||||
{
|
{
|
||||||
use NullCacheTrait;
|
use NullCacheTrait;
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Db\NullCache;
|
|||||||
|
|
||||||
use danog\MadelineProto\Db\RedisArray as DbRedisArray;
|
use danog\MadelineProto\Db\RedisArray as DbRedisArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis database backend, no caching.
|
||||||
|
*/
|
||||||
class RedisArray extends DbRedisArray
|
class RedisArray extends DbRedisArray
|
||||||
{
|
{
|
||||||
use NullCacheTrait;
|
use NullCacheTrait;
|
||||||
|
@ -13,6 +13,9 @@ use danog\MadelineProto\Settings\Database\Postgres as DatabasePostgres;
|
|||||||
|
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postgres database backend.
|
||||||
|
*/
|
||||||
class PostgresArray extends SqlArray
|
class PostgresArray extends SqlArray
|
||||||
{
|
{
|
||||||
protected string $table;
|
protected string $table;
|
||||||
|
@ -13,6 +13,9 @@ use Generator;
|
|||||||
|
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis database backend.
|
||||||
|
*/
|
||||||
class RedisArray extends SqlArray
|
class RedisArray extends SqlArray
|
||||||
{
|
{
|
||||||
protected DatabaseRedis $dbSettings;
|
protected DatabaseRedis $dbSettings;
|
||||||
|
@ -7,6 +7,9 @@ use danog\MadelineProto\Settings\Database\DatabaseAbstract;
|
|||||||
|
|
||||||
use function Amp\call;
|
use function Amp\call;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic SQL database backend.
|
||||||
|
*/
|
||||||
abstract class SqlArray extends DriverArray
|
abstract class SqlArray extends DriverArray
|
||||||
{
|
{
|
||||||
protected string $table;
|
protected string $table;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic exception.
|
||||||
|
*/
|
||||||
class Exception extends \Exception
|
class Exception extends \Exception
|
||||||
{
|
{
|
||||||
use TL\PrettyException;
|
use TL\PrettyException;
|
||||||
|
@ -6061,13 +6061,6 @@ class InternalDoc extends APIFactory
|
|||||||
{
|
{
|
||||||
$this->__call(__FUNCTION__, [$hook_url, $pem_path]);
|
$this->__call(__FUNCTION__, [$hook_url, $pem_path]);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Set API wrapper needed for triggering serialization functions.
|
|
||||||
*/
|
|
||||||
public function setWrapper(\danog\MadelineProto\APIWrapper $wrapper)
|
|
||||||
{
|
|
||||||
$this->__call(__FUNCTION__, [$wrapper]);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Setup logger.
|
* Setup logger.
|
||||||
*
|
*
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lua interface.
|
||||||
|
*/
|
||||||
class Lua
|
class Lua
|
||||||
{
|
{
|
||||||
use \danog\Serializable;
|
|
||||||
public API $MadelineProto;
|
public API $MadelineProto;
|
||||||
protected $Lua;
|
protected $Lua;
|
||||||
protected $script;
|
protected string $script;
|
||||||
public function __magic_construct($script, $MadelineProto)
|
public function __construct(string $script, API $MadelineProto)
|
||||||
{
|
{
|
||||||
if (!\file_exists($script)) {
|
if (!\file_exists($script)) {
|
||||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['script_not_exist']);
|
throw new Exception(\danog\MadelineProto\Lang::$current_lang['script_not_exist']);
|
||||||
|
@ -601,11 +601,22 @@ class MTProto extends AsyncConstruct implements TLCallback
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set API wrapper needed for triggering serialization functions.
|
* Set API wrapper needed for triggering serialization functions.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function setWrapper(APIWrapper $wrapper): void
|
public function setWrapper(APIWrapper $wrapper): void
|
||||||
{
|
{
|
||||||
$this->wrapper = $wrapper;
|
$this->wrapper = $wrapper;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get API wrapper.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public function getWrapper(): APIWrapper
|
||||||
|
{
|
||||||
|
return $this->wrapper;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Sleep function.
|
* Sleep function.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal error indicating a problem with Telegram's servers.
|
||||||
|
*/
|
||||||
class PTSException extends \Exception
|
class PTSException extends \Exception
|
||||||
{
|
{
|
||||||
use TL\PrettyException;
|
use TL\PrettyException;
|
||||||
|
177
src/danog/MadelineProto/PhpDocBuilder.php
Normal file
177
src/danog/MadelineProto/PhpDocBuilder.php
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PhpDocBuilder module.
|
||||||
|
*
|
||||||
|
* This file is part of MadelineProto.
|
||||||
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU Affero General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @author Daniil Gentili <daniil@daniil.it>
|
||||||
|
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
|
||||||
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||||
|
*
|
||||||
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
use danog\MadelineProto\Async\AsyncConstruct;
|
||||||
|
use danog\MadelineProto\Db\DbPropertiesTrait;
|
||||||
|
use danog\MadelineProto\Files\Server;
|
||||||
|
use danog\MadelineProto\MTProtoTools\Crypt;
|
||||||
|
use danog\MadelineProto\MTProtoTools\GarbageCollector;
|
||||||
|
use danog\MadelineProto\MTProtoTools\MinDatabase;
|
||||||
|
use danog\MadelineProto\MTProtoTools\PasswordCalculator;
|
||||||
|
use danog\MadelineProto\MTProtoTools\ReferenceDatabase;
|
||||||
|
use danog\MadelineProto\MTProtoTools\UpdatesState;
|
||||||
|
use danog\MadelineProto\TL\TL;
|
||||||
|
use danog\MadelineProto\TL\TLConstructors;
|
||||||
|
use danog\MadelineProto\TL\TLMethods;
|
||||||
|
use danog\MadelineProto\TON\ADNLConnection;
|
||||||
|
use danog\MadelineProto\TON\APIFactory as TAPIFactory;
|
||||||
|
use danog\MadelineProto\TON\InternalDoc as TInternalDoc;
|
||||||
|
use danog\MadelineProto\TON\Lite;
|
||||||
|
use HaydenPierce\ClassFinder\ClassFinder;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Property;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||||
|
use phpDocumentor\Reflection\DocBlockFactory;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionClassConstant;
|
||||||
|
|
||||||
|
class PhpDocBuilder
|
||||||
|
{
|
||||||
|
private DocBlockFactory $factory;
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->factory = DocBlockFactory::createInstance();
|
||||||
|
}
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$classes = ClassFinder::getClassesInNamespace('danog\\MadelineProto', ClassFinder::RECURSIVE_MODE);
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
if (\in_array($class, [
|
||||||
|
AnnotationsBuilder::class,
|
||||||
|
APIFactory::class,
|
||||||
|
APIWrapper::class,
|
||||||
|
AbstractAPIFactory::class,
|
||||||
|
Bug74586Exception::class,
|
||||||
|
Connection::class,
|
||||||
|
ContextConnector::class,
|
||||||
|
DataCenter::class,
|
||||||
|
DataCenterConnection::class,
|
||||||
|
DoHConnector::class,
|
||||||
|
DocsBuilder::class,
|
||||||
|
InternalDoc::class,
|
||||||
|
Lang::class,
|
||||||
|
LightState::class,
|
||||||
|
Magic::class,
|
||||||
|
PhpDocBuilder::class,
|
||||||
|
RSA::class,
|
||||||
|
Serialization::class,
|
||||||
|
SessionPaths::class,
|
||||||
|
SettingsEmpty::class,
|
||||||
|
SettingsAbstract::class,
|
||||||
|
Snitch::class,
|
||||||
|
AsyncConstruct::class,
|
||||||
|
Server::class, // Remove when done
|
||||||
|
VoIP::class,
|
||||||
|
|
||||||
|
Crypt::class,
|
||||||
|
NothingInTheSocketException::class,
|
||||||
|
|
||||||
|
GarbageCollector::class,
|
||||||
|
MinDatabase::class,
|
||||||
|
PasswordCalculator::class,
|
||||||
|
ReferenceDatabase::class,
|
||||||
|
UpdatesState::class,
|
||||||
|
|
||||||
|
TL::class,
|
||||||
|
TLConstructors::class,
|
||||||
|
TLMethods::class,
|
||||||
|
|
||||||
|
ADNLConnection::class,
|
||||||
|
TAPIFactory::class,
|
||||||
|
TInternalDoc::class,
|
||||||
|
Lite::class,
|
||||||
|
]) || str_starts_with($class, 'danog\\MadelineProto\\Ipc')
|
||||||
|
|| str_starts_with($class, 'danog\\MadelineProto\\Loop\\Update')
|
||||||
|
|| str_starts_with($class, 'danog\\MadelineProto\\Loop\\Connection')
|
||||||
|
|| str_starts_with($class, 'danog\\MadelineProto\\MTProto\\')
|
||||||
|
|| str_starts_with($class, 'danog\\MadelineProto\\MTProtoSession\\')
|
||||||
|
|| str_starts_with($class, 'danog\\MadelineProto\\Db\\NullCache')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$class = new ReflectionClass($class);
|
||||||
|
if ($class->isTrait()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->generate($class);
|
||||||
|
}
|
||||||
|
$this->generate(new ReflectionClass(DbPropertiesTrait::class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generate(ReflectionClass $class): void
|
||||||
|
{
|
||||||
|
$name = $class->getName();
|
||||||
|
$doc = $class->getDocComment();
|
||||||
|
if (!$doc) {
|
||||||
|
throw new Exception("$name has no PHPDOC!");
|
||||||
|
}
|
||||||
|
$doc = $this->factory->create($doc);
|
||||||
|
$title = $doc->getSummary();
|
||||||
|
$description = $doc->getDescription();
|
||||||
|
$tags = $doc->getTags();
|
||||||
|
|
||||||
|
$seeAlso = [];
|
||||||
|
$properties = [];
|
||||||
|
|
||||||
|
$author = new Author("Daniil Gentili", "daniil@daniil.it");
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if ($tag instanceof Author) {
|
||||||
|
$author = $tag;
|
||||||
|
}
|
||||||
|
if ($tag instanceof Deprecated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($tag instanceof Generic && $tag->getName() === 'internal') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($tag instanceof See) {
|
||||||
|
$seeAlso[$tag->getReference()->__toString()] = $tag->render();
|
||||||
|
}
|
||||||
|
if ($tag instanceof Property) {
|
||||||
|
$properties[$tag->getVariableName()] = [
|
||||||
|
$tag->getType(),
|
||||||
|
$tag->getDescription()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($tag instanceof InvalidTag && $tag->getName() === 'property') {
|
||||||
|
[$type, $description] = \explode(" $", $tag->render(), 2);
|
||||||
|
$description .= ' ';
|
||||||
|
[$varName, $description] = \explode(" ", $description, 2);
|
||||||
|
$properties[$varName] = [
|
||||||
|
\str_replace('@property ', '', $type),
|
||||||
|
$description ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$constants = [];
|
||||||
|
foreach ($class->getConstants() as $key => $value) {
|
||||||
|
$refl = new ReflectionClassConstant($name, $key);
|
||||||
|
$doc = $this->factory->create($refl->getDocComment() ?? '');
|
||||||
|
$constants[$key] = [
|
||||||
|
$value,
|
||||||
|
$description,
|
||||||
|
$doc->getDescription()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,9 @@ namespace danog\MadelineProto;
|
|||||||
use Psr\Log\AbstractLogger;
|
use Psr\Log\AbstractLogger;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PSR-3 wrapper for MadelineProto's Logger.
|
||||||
|
*/
|
||||||
class PsrLogger extends AbstractLogger
|
class PsrLogger extends AbstractLogger
|
||||||
{
|
{
|
||||||
private const LEVEL_MAP = [
|
private const LEVEL_MAP = [
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates an error returned by Telegram's API.
|
||||||
|
*/
|
||||||
class RPCErrorException extends \Exception
|
class RPCErrorException extends \Exception
|
||||||
{
|
{
|
||||||
use TL\PrettyException;
|
use TL\PrettyException;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates an error thrown when an unexpected response is received from telegram's servers.
|
||||||
|
*/
|
||||||
class ResponseException extends \Exception
|
class ResponseException extends \Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates a security error.
|
||||||
|
*/
|
||||||
class SecurityException extends \Exception
|
class SecurityException extends \Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ use danog\MadelineProto\Settings\Serialization;
|
|||||||
use danog\MadelineProto\Settings\Templates;
|
use danog\MadelineProto\Settings\Templates;
|
||||||
use danog\MadelineProto\Settings\TLSchema;
|
use danog\MadelineProto\Settings\TLSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings class used for configuring MadelineProto.
|
||||||
|
*/
|
||||||
class Settings extends SettingsAbstract
|
class Settings extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,9 @@ use danog\MadelineProto\Magic;
|
|||||||
use danog\MadelineProto\MTProto;
|
use danog\MadelineProto\MTProto;
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App information.
|
||||||
|
*/
|
||||||
class AppInfo extends SettingsAbstract
|
class AppInfo extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cryptography settings.
|
||||||
|
*/
|
||||||
class Auth extends SettingsAbstract
|
class Auth extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,9 @@ use danog\MadelineProto\Stream\Transport\DefaultStream;
|
|||||||
use danog\MadelineProto\Stream\Transport\WssStream;
|
use danog\MadelineProto\Stream\Transport\WssStream;
|
||||||
use danog\MadelineProto\Stream\Transport\WsStream;
|
use danog\MadelineProto\Stream\Transport\WsStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection settings.
|
||||||
|
*/
|
||||||
class Connection extends SettingsAbstract
|
class Connection extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings\Database;
|
|||||||
|
|
||||||
use danog\MadelineProto\Settings\DatabaseAbstract;
|
use danog\MadelineProto\Settings\DatabaseAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memory backend settings.
|
||||||
|
*/
|
||||||
class Memory extends DatabaseAbstract
|
class Memory extends DatabaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Settings\Database;
|
namespace danog\MadelineProto\Settings\Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL backend settings.
|
||||||
|
*/
|
||||||
class Mysql extends SqlAbstract
|
class Mysql extends SqlAbstract
|
||||||
{
|
{
|
||||||
public function mergeArray(array $settings): void
|
public function mergeArray(array $settings): void
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Settings\Database;
|
namespace danog\MadelineProto\Settings\Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Postgres backend settings.
|
||||||
|
*/
|
||||||
class Postgres extends SqlAbstract
|
class Postgres extends SqlAbstract
|
||||||
{
|
{
|
||||||
public function mergeArray(array $settings): void
|
public function mergeArray(array $settings): void
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Settings\Database;
|
namespace danog\MadelineProto\Settings\Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis backend settings.
|
||||||
|
*/
|
||||||
class Redis extends DatabaseAbstract
|
class Redis extends DatabaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings\Database;
|
|||||||
|
|
||||||
use danog\MadelineProto\Settings\Database;
|
use danog\MadelineProto\Settings\Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic db backend settings.
|
||||||
|
*/
|
||||||
abstract class SqlAbstract extends DatabaseAbstract
|
abstract class SqlAbstract extends DatabaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File management settings.
|
||||||
|
*/
|
||||||
class Files extends SettingsAbstract
|
class Files extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IPC server settings.
|
||||||
|
*/
|
||||||
class Ipc extends SettingsAbstract
|
class Ipc extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,9 @@ use danog\MadelineProto\Magic;
|
|||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger settings.
|
||||||
|
*/
|
||||||
class Logger extends SettingsAbstract
|
class Logger extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Peer database settings.
|
||||||
|
*/
|
||||||
class Peer extends SettingsAbstract
|
class Peer extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PWRTelegram settings.
|
||||||
|
*/
|
||||||
class Pwr extends SettingsAbstract
|
class Pwr extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RPC settings.
|
||||||
|
*/
|
||||||
class RPC extends SettingsAbstract
|
class RPC extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secret chat settings.
|
||||||
|
*/
|
||||||
class SecretChats extends SettingsAbstract
|
class SecretChats extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialization settings.
|
||||||
|
*/
|
||||||
class Serialization extends SettingsAbstract
|
class Serialization extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Settings;
|
|||||||
|
|
||||||
use danog\MadelineProto\SettingsAbstract;
|
use danog\MadelineProto\SettingsAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TL schema settings.
|
||||||
|
*/
|
||||||
class TLSchema extends SettingsAbstract
|
class TLSchema extends SettingsAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@ abstract class SettingsAbstract
|
|||||||
*
|
*
|
||||||
* @param array $settings Settings array
|
* @param array $settings Settings array
|
||||||
*
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function mergeArray(array $settings): void
|
public function mergeArray(array $settings): void
|
||||||
@ -29,6 +31,8 @@ abstract class SettingsAbstract
|
|||||||
*
|
*
|
||||||
* @param self $other
|
* @param self $other
|
||||||
*
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function merge(self $other): void
|
public function merge(self $other): void
|
||||||
@ -84,6 +88,8 @@ abstract class SettingsAbstract
|
|||||||
/**
|
/**
|
||||||
* Apply changes.
|
* Apply changes.
|
||||||
*
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function applyChanges(): self
|
public function applyChanges(): self
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto;
|
namespace danog\MadelineProto;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Controls script shutdown
|
* Class that controls script shutdown.
|
||||||
*/
|
*/
|
||||||
class Shutdown
|
class Shutdown
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\TL\Conversion;
|
namespace danog\MadelineProto\TL\Conversion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TL conversion exception.
|
||||||
|
*/
|
||||||
class Exception extends \Exception
|
class Exception extends \Exception
|
||||||
{
|
{
|
||||||
use \danog\MadelineProto\TL\PrettyException;
|
use \danog\MadelineProto\TL\PrettyException;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\TL;
|
namespace danog\MadelineProto\TL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TL deserialization exception.
|
||||||
|
*/
|
||||||
class Exception extends \Exception
|
class Exception extends \Exception
|
||||||
{
|
{
|
||||||
use PrettyException;
|
use PrettyException;
|
||||||
|
@ -19,9 +19,13 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\TL\Types;
|
namespace danog\MadelineProto\TL\Types;
|
||||||
|
|
||||||
|
use danog\MadelineProto\API;
|
||||||
use danog\MadelineProto\MTProto;
|
use danog\MadelineProto\MTProto;
|
||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clickable button.
|
||||||
|
*/
|
||||||
class Button implements \JsonSerializable, \ArrayAccess
|
class Button implements \JsonSerializable, \ArrayAccess
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -31,9 +35,15 @@ class Button implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
private array $button;
|
private array $button;
|
||||||
/**
|
/**
|
||||||
* MTProto instance.
|
* Session name.
|
||||||
*/
|
*/
|
||||||
private MTProto $API;
|
private string $session;
|
||||||
|
/**
|
||||||
|
* MTProto instance.
|
||||||
|
*
|
||||||
|
* @var MTProto|API
|
||||||
|
*/
|
||||||
|
private $API;
|
||||||
/**
|
/**
|
||||||
* Message ID.
|
* Message ID.
|
||||||
*/
|
*/
|
||||||
@ -62,6 +72,7 @@ class Button implements \JsonSerializable, \ArrayAccess
|
|||||||
: $message['peer_id'];
|
: $message['peer_id'];
|
||||||
$this->id = $message['id'];
|
$this->id = $message['id'];
|
||||||
$this->API = $API;
|
$this->API = $API;
|
||||||
|
$this->session = $API->getWrapper()->getSession()->getLegacySessionPath();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sleep function.
|
* Sleep function.
|
||||||
@ -70,7 +81,7 @@ class Button implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function __sleep(): array
|
public function __sleep(): array
|
||||||
{
|
{
|
||||||
return ['button', 'peer', 'id', 'API'];
|
return ['button', 'peer', 'id', 'session'];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Click on button.
|
* Click on button.
|
||||||
@ -81,7 +92,11 @@ class Button implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function click(bool $donotwait = true)
|
public function click(bool $donotwait = true)
|
||||||
{
|
{
|
||||||
$async = isset($this->API->wrapper) ? $this->API->wrapper->isAsync() : true;
|
if (!isset($this->API)) {
|
||||||
|
$this->API = new API($this->session);
|
||||||
|
} else {
|
||||||
|
$async = isset($this->API->wrapper) ? $this->API->wrapper->isAsync() : true;
|
||||||
|
}
|
||||||
$method = $donotwait ? 'methodCallAsyncWrite' : 'methodCallAsyncRead';
|
$method = $donotwait ? 'methodCallAsyncWrite' : 'methodCallAsyncRead';
|
||||||
switch ($this->button['_']) {
|
switch ($this->button['_']) {
|
||||||
default:
|
default:
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\TL\Types;
|
namespace danog\MadelineProto\TL\Types;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bytes wrapper.
|
||||||
|
*/
|
||||||
class Bytes implements \JsonSerializable, \ArrayAccess
|
class Bytes implements \JsonSerializable, \ArrayAccess
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user