2023-10-04 21:57:17 +02:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
use danog\MadelineProto\Logger;
|
|
|
|
use danog\MadelineProto\RPCErrorException;
|
|
|
|
use danog\MadelineProto\Settings\Logger as SettingsLogger;
|
|
|
|
use danog\MadelineProto\Settings\TLSchema;
|
|
|
|
use danog\MadelineProto\TL\TL;
|
|
|
|
|
2024-06-15 21:54:24 +02:00
|
|
|
use function Amp\async;
|
|
|
|
|
2023-10-04 21:57:17 +02:00
|
|
|
/*
|
|
|
|
Copyright 2016-2020 Daniil Gentili
|
|
|
|
(https://daniil.it)
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
$logger = new Logger(new SettingsLogger);
|
|
|
|
|
|
|
|
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
|
|
|
|
|
2024-08-02 19:06:46 +02:00
|
|
|
if ($argc !== 2) {
|
2024-07-21 18:26:48 +02:00
|
|
|
die("Usage: {$argv[0]} layernumber\n");
|
2023-10-04 21:57:17 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get TL info of layer.
|
|
|
|
*
|
|
|
|
* @param int $layer Layer number
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function getTL($layer)
|
|
|
|
{
|
|
|
|
$layerFile = __DIR__."/../schemas/TL_telegram_v$layer.tl";
|
|
|
|
$layer = new TL();
|
|
|
|
$layer->init((new TLSchema)->setAPISchema($layerFile)->setSecretSchema(''));
|
|
|
|
|
|
|
|
return ['methods' => $layer->getMethods(), 'constructors' => $layer->getConstructors()];
|
|
|
|
}
|
2024-07-21 18:26:48 +02:00
|
|
|
$layer = getTL($argv[1]);
|
2023-10-04 21:57:17 +02:00
|
|
|
$res = '';
|
|
|
|
|
|
|
|
$bot = new \danog\MadelineProto\API('bot.madeline');
|
|
|
|
$bot->start();
|
2024-01-22 16:47:14 +01:00
|
|
|
$bot->updateSettings((new TLSchema)->setFuzzMode(true));
|
2023-10-04 21:57:17 +02:00
|
|
|
|
|
|
|
$user = new \danog\MadelineProto\API('secret.madeline');
|
|
|
|
$user->start();
|
2024-01-22 16:47:14 +01:00
|
|
|
$user->updateSettings((new TLSchema)->setFuzzMode(true));
|
2023-10-04 21:57:17 +02:00
|
|
|
|
|
|
|
$methods = [];
|
2024-07-21 18:26:48 +02:00
|
|
|
foreach ($layer['methods']->by_id as $constructor) {
|
2023-10-04 21:57:17 +02:00
|
|
|
$name = $constructor['method'];
|
2024-07-21 18:26:48 +02:00
|
|
|
if (strtolower($name) === 'account.deleteaccount'
|
|
|
|
|| strtolower($name) === 'auth.logout'
|
|
|
|
|| $name === 'auth.resetAuthorizations'
|
|
|
|
|| $name === 'auth.dropTempAuthKeys'
|
|
|
|
|| $name === 'account.resetAuthorization'
|
2024-08-02 18:50:54 +02:00
|
|
|
|| $name === 'account.resetPassword'
|
2024-08-04 13:41:43 +02:00
|
|
|
|| $name === 'account.updateUsername'
|
2024-07-21 18:26:48 +02:00
|
|
|
|| !str_contains($name, '.')) {
|
|
|
|
continue;
|
2023-10-04 21:57:17 +02:00
|
|
|
}
|
2024-07-21 18:26:48 +02:00
|
|
|
[$namespace, $method] = explode('.', $name);
|
|
|
|
|
|
|
|
$methods []= async(static function () use ($namespace, $method, $bot): void {
|
|
|
|
try {
|
|
|
|
$bot->{$namespace}->{$method}();
|
|
|
|
} catch (RPCErrorException) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$methods []= async(static function () use ($namespace, $method, $user): void {
|
|
|
|
try {
|
|
|
|
$user->{$namespace}->{$method}();
|
|
|
|
} catch (RPCErrorException) {
|
|
|
|
}
|
|
|
|
});
|
2023-10-04 21:57:17 +02:00
|
|
|
}
|
2024-06-15 21:54:24 +02:00
|
|
|
|
|
|
|
var_dump(array_map('strval', \Amp\Future\awaitAll($methods)[0]));
|