Improved logging
This commit is contained in:
parent
eee724cf83
commit
85ec1c6830
10
bot.php
10
bot.php
@ -18,19 +18,19 @@ $settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('bot.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login(readline('Enter a bot token: '));
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
//var_dump($MadelineProto->API->get_config([], ['datacenter' => $MadelineProto->API->datacenter->curdc]));
|
||||
//var_dump($MadelineProto->API->settings['connection']);
|
||||
//\danog\MadelineProto\Logger::log($MadelineProto->API->get_config([], ['datacenter' => $MadelineProto->API->datacenter->curdc]));
|
||||
//\danog\MadelineProto\Logger::log($MadelineProto->API->settings['connection']);
|
||||
$MadelineProto->session = 'bot.madeline';
|
||||
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('bot.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
$offset = 0;
|
||||
while (true) {
|
||||
$updates = $MadelineProto->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
\danog\MadelineProto\Logger::log([$updates]);
|
||||
\danog\MadelineProto\Logger::log($updates);
|
||||
foreach ($updates as $update) {
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
|
@ -15,7 +15,7 @@ $param = 1;
|
||||
\danog\MadelineProto\Logger::constructor($param);
|
||||
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Copying readme...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Copying readme...', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
file_put_contents('docs/index.md', '---
|
||||
title: MadelineProto documentation
|
||||
|
@ -27,28 +27,28 @@ if (!is_object($Lua)) {
|
||||
switch ($res) {
|
||||
case 'u':
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
$Lua = new \danog\MadelineProto\Lua('madeline.lua', $MadelineProto);
|
||||
break;
|
||||
case 'b':
|
||||
$authorization = $MadelineProto->bot_login(readline('Please enter a bot token: '));
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
$Lua = new \danog\MadelineProto\Lua('madeline.lua', $MadelineProto);
|
||||
break;
|
||||
}
|
||||
|
12
lua/td.php
12
lua/td.php
@ -27,28 +27,28 @@ if (!is_object($Lua)) {
|
||||
switch ($res) {
|
||||
case 'u':
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
$Lua = new \danog\MadelineProto\Lua('madeline.lua', $MadelineProto);
|
||||
break;
|
||||
case 'b':
|
||||
$authorization = $MadelineProto->bot_login(readline('Please enter a bot token: '));
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
$Lua = new \danog\MadelineProto\Lua('madeline.lua', $MadelineProto);
|
||||
break;
|
||||
}
|
||||
|
24
magna.php
24
magna.php
@ -23,7 +23,7 @@ $MadelineProto = false;
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
|
||||
if (file_exists('.env')) {
|
||||
@ -42,20 +42,20 @@ if ($MadelineProto === false) {
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
if (getenv('TRAVIS_COMMIT') == '') {
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ if ($MadelineProto === false) {
|
||||
$MadelineProto->bot_login(getenv('BOT_TOKEN'));
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
|
||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||
if (!isset($MadelineProto->programmed_call)) {
|
||||
@ -139,7 +139,7 @@ $MadelineProto->get_updates(['offset' => -1]);
|
||||
}
|
||||
}
|
||||
foreach ($updates as $update) {
|
||||
\danog\MadelineProto\Logger::log([$update]);
|
||||
\danog\MadelineProto\Logger::log($update);
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updateNewEncryptedMessage':
|
||||
|
@ -35,7 +35,7 @@ $MadelineProto = false;
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('testing.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
if (file_exists('.env')) {
|
||||
echo 'Loading .env...'.PHP_EOL;
|
||||
@ -46,43 +46,43 @@ if (getenv('TEST_SECRET_CHAT') == '') {
|
||||
die('TEST_SECRET_CHAT is not defined in .env, please define it.'.PHP_EOL);
|
||||
}
|
||||
echo 'Loading settings...'.PHP_EOL;
|
||||
var_dump(getenv('MTPROTO_SETTINGS'));
|
||||
\danog\MadelineProto\Logger::log(getenv('MTPROTO_SETTINGS'));
|
||||
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
|
||||
//$settings['connection_settings']['all']['proxy'] = '\SocksProxy';
|
||||
//$settings['connection_settings']['all']['proxy_extra'] = ['address' => '127.0.0.1', 'port' => 1080];
|
||||
|
||||
var_dump($settings);
|
||||
\danog\MadelineProto\Logger::log($settings);
|
||||
if ($MadelineProto === false) {
|
||||
echo 'Loading MadelineProto...'.PHP_EOL;
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
if (getenv('TRAVIS_COMMIT') == '') {
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
} else {
|
||||
$MadelineProto->bot_login(getenv('BOT_TOKEN'));
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
//$MadelineProto->phone->createGroupCall(['channel' => -1001333587884
|
||||
|
||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||
@ -98,7 +98,7 @@ if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
//$MadelineProto->messages->sendMessage(['peer' => $controller->getOtherID(), 'message' => 'Emojis: '.implode('', $controller->getVisualization())]);
|
||||
var_dump($controller->configuration);
|
||||
\danog\MadelineProto\Logger::log($controller->configuration);
|
||||
while ($controller->getCallState() < \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
@ -109,7 +109,7 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !==
|
||||
while ($howmany > 0) {
|
||||
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
foreach ($updates as $update) {
|
||||
\danog\MadelineProto\Logger::log([$update]);
|
||||
\danog\MadelineProto\Logger::log($update);
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updatePhoneCall':
|
||||
@ -132,16 +132,16 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y')
|
||||
|
||||
$InputEncryptedChat = $MadelineProto->get_secret_chat($secret)['InputEncryptedChat'];
|
||||
$sentMessage = $MadelineProto->messages->sendEncrypted(['peer' => $InputEncryptedChat, 'message' => ['_' => 'decryptedMessage', 'media' => ['_' => 'decryptedMessageMediaEmpty'], 'ttl' => 10, 'message' => $message, 'entities' => [['_' => 'messageEntityCode', 'offset' => 0, 'length' => mb_strlen($message)]]]]); // should work with all layers
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
/*
|
||||
while (true) {
|
||||
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
//\danog\MadelineProto\Logger::log([$updates]);
|
||||
//\danog\MadelineProto\Logger::log($updates);
|
||||
foreach ($updates as $update) {
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updateNewEncryptedMessage':
|
||||
var_dump($update);
|
||||
\danog\MadelineProto\Logger::log($update);
|
||||
}
|
||||
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('testing.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
}
|
||||
@ -167,7 +167,7 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y')
|
||||
// Document, secrey chat
|
||||
$time = time();
|
||||
$inputEncryptedFile = $MadelineProto->upload_encrypted('tests/60', 'magic'); // This gets an inputFile object with file name magic
|
||||
var_dump(time() - $time);
|
||||
\danog\MadelineProto\Logger::log(time() - $time);
|
||||
$secret_media['document'] = ['peer' => $secret, 'file' => $inputEncryptedFile, 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => 'magic/magic', 'caption' => 'test', 'key' => $inputEncryptedFile['key'], 'iv' => $inputEncryptedFile['iv'], 'file_name' => 'magic.magic', 'size' => filesize('tests/60'), 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'fairy']]]]];
|
||||
|
||||
// Video, secret chat
|
||||
@ -191,7 +191,7 @@ $media = [];
|
||||
|
||||
// Sticker
|
||||
$inputFile = $MadelineProto->upload('tests/lel.webp');
|
||||
var_dump($inputFile);
|
||||
\danog\MadelineProto\Logger::log($inputFile);
|
||||
$media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]];
|
||||
|
||||
// Video
|
||||
@ -208,7 +208,7 @@ $media['voice'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'm
|
||||
// Document
|
||||
$time = time();
|
||||
$inputFile = $MadelineProto->upload('tests/60', 'magic'); // This gets an inputFile object with file name magic
|
||||
var_dump(time() - $time);
|
||||
\danog\MadelineProto\Logger::log(time() - $time);
|
||||
$media['document'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => 'magic/magic', 'caption' => 'This file was uploaded using MadelineProto', 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'magic.magic']]];
|
||||
|
||||
$message = 'yay';
|
||||
@ -217,7 +217,7 @@ $mention = $mention['user_id']; // Selects only the numeric user id
|
||||
|
||||
foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
$sentMessage = $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => $message, 'entities' => [['_' => 'inputMessageEntityMentionName', 'offset' => 0, 'length' => mb_strlen($message), 'user_id' => $mention]]]);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
foreach ($media as $type => $inputMedia) {
|
||||
$type = $MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia, 'message' => '['.$message.'](mention:'.$mention.')', 'parse_mode' => 'markdown']);
|
||||
@ -226,5 +226,5 @@ foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
|
||||
foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
$sentMessage = $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => $message, 'entities' => [['_' => 'inputMessageEntityMentionName', 'offset' => 0, 'length' => mb_strlen($message), 'user_id' => $mention]]]);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ $MadelineProto = false;
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('s.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
if (file_exists('.env')) {
|
||||
echo 'Loading .env...'.PHP_EOL;
|
||||
@ -38,20 +38,20 @@ if ($MadelineProto === false) {
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
if (getenv('TRAVIS_COMMIT') == '') {
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
} else {
|
||||
@ -68,7 +68,7 @@ $offset = 0;
|
||||
while (true) {
|
||||
try {
|
||||
$updates = $MadelineProto->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
//\danog\MadelineProto\Logger::log([$updates]);
|
||||
//\danog\MadelineProto\Logger::log($updates);
|
||||
foreach ($updates as $update) {
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
@ -82,7 +82,7 @@ while (true) {
|
||||
}
|
||||
break;*/
|
||||
case 'updateNewEncryptedMessage':
|
||||
var_dump($MadelineProto->download_to_dir($update['update']['message'], '.'));
|
||||
\danog\MadelineProto\Logger::log($MadelineProto->download_to_dir($update['update']['message'], '.'));
|
||||
if (isset($sent[$update['update']['message']['chat_id']])) {
|
||||
continue;
|
||||
}
|
||||
@ -107,7 +107,7 @@ while (true) {
|
||||
// Document, secrey chat
|
||||
$time = time();
|
||||
$inputEncryptedFile = $MadelineProto->upload_encrypted('tests/60', 'magic'); // This gets an inputFile object with file name magic
|
||||
var_dump(time() - $time);
|
||||
\danog\MadelineProto\Logger::log(time() - $time);
|
||||
$secret_media['document'] = ['peer' => $secret, 'file' => $inputEncryptedFile, 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => 'magic/magic', 'caption' => 'test', 'key' => $inputEncryptedFile['key'], 'iv' => $inputEncryptedFile['iv'], 'file_name' => 'magic.magic', 'size' => filesize('tests/60'), 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'fairy']]]]];
|
||||
|
||||
// Video, secret chat
|
||||
@ -133,9 +133,9 @@ while (true) {
|
||||
}
|
||||
}
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
var_dump($e);
|
||||
\danog\MadelineProto\Logger::log($e);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
//sleep(1);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class API extends APIFactory
|
||||
clearstatcache();
|
||||
}
|
||||
$realpaths['lockfile'] = fopen($realpaths['lockfile'], 'r');
|
||||
\danog\MadelineProto\Logger::log(['Waiting for shared lock of serialization lockfile...']);
|
||||
\danog\MadelineProto\Logger::log('Waiting for shared lock of serialization lockfile...');
|
||||
flock($realpaths['lockfile'], LOCK_SH);
|
||||
|
||||
try {
|
||||
@ -53,7 +53,7 @@ class API extends APIFactory
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
Logger::log((string) $e, Logger::ERROR);
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\\Math\\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $unserialized);
|
||||
}
|
||||
@ -76,14 +76,14 @@ class API extends APIFactory
|
||||
return;
|
||||
}
|
||||
$this->API = new MTProto($params);
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['apifactory_start']], Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['apifactory_start'], Logger::VERBOSE);
|
||||
$this->APIFactory();
|
||||
\danog\MadelineProto\Logger::log(['Ping...'], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Ping...', Logger::ULTRA_VERBOSE);
|
||||
$pong = $this->ping(['ping_id' => 3]);
|
||||
\danog\MadelineProto\Logger::log(['Pong: '.$pong['ping_id']], Logger::ULTRA_VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log(['Getting future salts...'], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Pong: '.$pong['ping_id'], Logger::ULTRA_VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log('Getting future salts...', Logger::ULTRA_VERBOSE);
|
||||
//$this->future_salts = $this->get_future_salts(['num' => 3]);
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['madelineproto_ready']], Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['madelineproto_ready'], Logger::NOTICE);
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
@ -150,7 +150,7 @@ class API extends APIFactory
|
||||
if ($params === '') {
|
||||
$params = $this->session;
|
||||
}
|
||||
Logger::log([\danog\MadelineProto\Lang::$current_lang['serializing_madelineproto']]);
|
||||
Logger::log(\danog\MadelineProto\Lang::$current_lang['serializing_madelineproto']);
|
||||
|
||||
return Serialization::serialize($params, $this);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class APIFactory
|
||||
$aargs = isset($arguments[1]) && is_array($arguments[1]) ? $arguments[1] : [];
|
||||
$aargs['datacenter'] = $this->API->datacenter->curdc;
|
||||
if ($name === 'get_updates' && isset($this->session) && !is_null($this->session) && time() - $this->serialized > $this->API->settings['serialization']['serialization_interval']) {
|
||||
Logger::log(["Didn't serialize in a while, doing that now..."]);
|
||||
Logger::log("Didn't serialize in a while, doing that now...");
|
||||
$this->serialize($this->session);
|
||||
}
|
||||
if ($this->lua === false) {
|
||||
|
@ -28,7 +28,7 @@ class AnnotationsBuilder
|
||||
|
||||
public function mk_annotations()
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Generating annotations...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating annotations...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->setProperties();
|
||||
$this->createInternalClasses();
|
||||
}
|
||||
@ -40,7 +40,7 @@ class AnnotationsBuilder
|
||||
*/
|
||||
private function setProperties()
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Generating properties...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating properties...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$fixture = DocBlockFactory::createInstance();
|
||||
$class = new \ReflectionClass(APIFactory::class);
|
||||
$content = file_get_contents($filename = $class->getFileName());
|
||||
@ -63,7 +63,7 @@ class AnnotationsBuilder
|
||||
*/
|
||||
private function createInternalClasses()
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Creating internal classes...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Creating internal classes...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$handle = fopen(dirname(__FILE__).'/InternalDoc.php', 'w');
|
||||
foreach ($this->methods->by_id as $id => $data) {
|
||||
if (!strpos($data['method'], '.')) {
|
||||
|
@ -194,7 +194,7 @@ class Connection
|
||||
public function close_and_reopen()
|
||||
{
|
||||
$this->__destruct();
|
||||
\danog\MadelineProto\Logger::log(['Reopening...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Reopening...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$this->must_open = true;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ class Connection
|
||||
|
||||
public function read($length)
|
||||
{
|
||||
//\danog\MadelineProto\Logger::log(["Asked to read $length"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log("Asked to read $length", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
switch ($this->protocol) {
|
||||
case 'obfuscated2':
|
||||
$packet = '';
|
||||
@ -309,7 +309,7 @@ class Connection
|
||||
case 'https':
|
||||
$response = $this->read_http_payload();
|
||||
if ($response['code'] !== 200) {
|
||||
Logger::log([$response['body']]);
|
||||
Logger::log($response['body']);
|
||||
|
||||
throw new Exception($response['description'], $response['code']);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class DataCenter
|
||||
$this->settings = $settings;
|
||||
foreach ($this->sockets as $key => $socket) {
|
||||
if ($socket instanceof Connection) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $key)], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $key), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$socket->old = true;
|
||||
$socket->__destruct();
|
||||
} else {
|
||||
@ -51,7 +51,7 @@ class DataCenter
|
||||
$this->curdc = 0;
|
||||
}
|
||||
if (isset($this->sockets[$dc_number])) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $dc_number)], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $dc_number), \danog\MadelineProto\Logger::VERBOSE);
|
||||
unset($this->sockets[$dc_number]);
|
||||
}
|
||||
}
|
||||
@ -96,9 +96,9 @@ class DataCenter
|
||||
}
|
||||
$address = $this->settings[$dc_config_number]['protocol'].'://'.$address.'/api';
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_test_start'], $dc_number, $test, $ipv6, $this->settings[$dc_config_number]['protocol'])], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_test_start'], $dc_number, $test, $ipv6, $this->settings[$dc_config_number]['protocol']), \danog\MadelineProto\Logger::VERBOSE);
|
||||
foreach (array_unique([$port, 443, 80, 88]) as $port) {
|
||||
\danog\MadelineProto\Logger::log(['Trying connection on port '.$port.'...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Trying connection on port '.$port.'...', \danog\MadelineProto\Logger::WARNING);
|
||||
|
||||
try {
|
||||
if (isset($this->sockets[$dc_number]->old)) {
|
||||
@ -107,7 +107,7 @@ class DataCenter
|
||||
} else {
|
||||
$this->sockets[$dc_number] = new Connection($this->settings[$dc_config_number]['proxy'], $this->settings[$dc_config_number]['proxy_extra'], $address, $port, $this->settings[$dc_config_number]['protocol'], $this->settings[$dc_config_number]['timeout'], $this->settings[$dc_config_number]['ipv6']);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['OK!'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('OK!', \danog\MadelineProto\Logger::WARNING);
|
||||
|
||||
return true;
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
@ -117,15 +117,15 @@ class DataCenter
|
||||
switch ($x) {
|
||||
case 0:
|
||||
$this->settings[$dc_config_number]['ipv6'] = !$this->settings[$dc_config_number]['ipv6'];
|
||||
\danog\MadelineProto\Logger::log(['Connection failed, retrying connection with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Connection failed, retrying connection with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...', \danog\MadelineProto\Logger::WARNING);
|
||||
continue;
|
||||
case 1:
|
||||
$this->settings[$dc_config_number]['proxy'] = '\\Socket';
|
||||
\danog\MadelineProto\Logger::log(['Connection failed, retrying connection without the proxy with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Connection failed, retrying connection without the proxy with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...', \danog\MadelineProto\Logger::WARNING);
|
||||
continue;
|
||||
case 2:
|
||||
$this->settings[$dc_config_number]['ipv6'] = !$this->settings[$dc_config_number]['ipv6'];
|
||||
\danog\MadelineProto\Logger::log(['Connection failed, retrying connection without the proxy with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Connection failed, retrying connection without the proxy with '.($this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4').'...', \danog\MadelineProto\Logger::WARNING);
|
||||
continue;
|
||||
default:
|
||||
throw new \danog\MadelineProto\Exception("Could not connect to DC $dc_number");
|
||||
|
@ -53,7 +53,7 @@ class DocsBuilder
|
||||
|
||||
public function mk_docs()
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Generating documentation index...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating documentation index...', \danog\MadelineProto\Logger::NOTICE);
|
||||
file_put_contents($this->index, '---
|
||||
title: '.$this->settings['title'].'
|
||||
description: '.$this->settings['description'].'
|
||||
@ -80,7 +80,7 @@ description: '.$this->settings['description'].'
|
||||
mkdir('types');
|
||||
ksort($this->types);
|
||||
$index = '';
|
||||
\danog\MadelineProto\Logger::log(['Generating types documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating types documentation...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$last_namespace = '';
|
||||
foreach ($this->types as $otype => $keys) {
|
||||
$new_namespace = preg_replace('/_.*/', '', $otype);
|
||||
@ -331,7 +331,7 @@ Easy as pie:
|
||||
|
||||
```
|
||||
$call->storage["pony"] = "fluttershy";
|
||||
var_dump($call->storage["pony"]); // fluttershy
|
||||
\danog\MadelineProto\Logger::log($call->storage["pony"]); // fluttershy
|
||||
```
|
||||
|
||||
Note: when modifying this property, *never* overwrite the previous values. Always either modify the values of the array separately like showed above, or use array_merge.
|
||||
@ -359,12 +359,12 @@ After modifying it, you must always parse the new configuration with a call to `
|
||||
}
|
||||
}
|
||||
if (file_exists('types/'.$type.'.md')) {
|
||||
\danog\MadelineProto\Logger::log([$type]);
|
||||
\danog\MadelineProto\Logger::log($type);
|
||||
}
|
||||
file_put_contents('types/'.$type.'.md', $header.$constructors.$methods);
|
||||
$last_namespace = $new_namespace;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Generating types index...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating types index...', \danog\MadelineProto\Logger::NOTICE);
|
||||
file_put_contents('types/'.$this->index, '---
|
||||
title: Types
|
||||
description: List of types
|
||||
@ -374,7 +374,7 @@ description: List of types
|
||||
|
||||
|
||||
'.$index);
|
||||
\danog\MadelineProto\Logger::log(['Generating additional types...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating additional types...', \danog\MadelineProto\Logger::NOTICE);
|
||||
file_put_contents('types/string.md', '---
|
||||
title: string
|
||||
description: A UTF8 string of variable length
|
||||
@ -519,6 +519,6 @@ description: Any json-encodable data
|
||||
|
||||
Any json-encodable data.
|
||||
');
|
||||
\danog\MadelineProto\Logger::log(['Done!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ trait Constructors
|
||||
}
|
||||
mkdir('constructors');
|
||||
$this->docs_constructors = [];
|
||||
\danog\MadelineProto\Logger::log(['Generating constructors documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating constructors documentation...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$got = [];
|
||||
foreach ($this->constructors->by_predicate_and_layer as $predicate => $id) {
|
||||
$data = $this->constructors->by_id[$id];
|
||||
@ -230,7 +230,7 @@ MadelineProto supports all html entities supported by [html_entity_decode](http:
|
||||
}
|
||||
file_put_contents('constructors/'.$constructor.$layer.'.md', $header.$table.$type.$example);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Generating constructors index...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating constructors index...', \danog\MadelineProto\Logger::NOTICE);
|
||||
ksort($this->docs_constructors);
|
||||
$last_namespace = '';
|
||||
foreach ($this->docs_constructors as $constructor => &$value) {
|
||||
|
@ -28,7 +28,7 @@ trait Methods
|
||||
}
|
||||
mkdir('methods');
|
||||
$this->docs_methods = [];
|
||||
\danog\MadelineProto\Logger::log(['Generating methods documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating methods documentation...', \danog\MadelineProto\Logger::NOTICE);
|
||||
foreach ($this->methods->by_id as $id => $data) {
|
||||
$method = str_replace('.', '_', $data['method']);
|
||||
$php_method = str_replace('.', '->', $data['method']);
|
||||
@ -273,7 +273,7 @@ MadelineProto supports all html entities supported by [html_entity_decode](http:
|
||||
}
|
||||
file_put_contents('methods/'.$method.'.md', $header.$table.$return.$example);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Generating methods index...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Generating methods index...', \danog\MadelineProto\Logger::NOTICE);
|
||||
ksort($this->docs_methods);
|
||||
$last_namespace = '';
|
||||
foreach ($this->docs_methods as $method => &$value) {
|
||||
|
@ -37,7 +37,7 @@ class Exception extends \Exception
|
||||
$this->line = $line;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
\danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log($message.' in '.basename($this->file).':'.$this->line, \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
if (in_array($message, ['The session is corrupted!', 'Re-executing query...', 'I had to recreate the temporary authorization key', 'This peer is not present in the internal peer database', "Couldn't get response", 'Chat forbidden', 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', 'File does not exist', 'Please install this fork of phpseclib: https://github.com/danog/phpseclib'])) {
|
||||
return;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class Logger
|
||||
self::class_exists();
|
||||
}
|
||||
|
||||
public static function log($params, $level = self::NOTICE)
|
||||
public static function log($param, $level = self::NOTICE)
|
||||
{
|
||||
if (self::$mode === 4) {
|
||||
return call_user_func_array(self::$optional, [is_array($params) ? $params : [$params], $level]);
|
||||
@ -100,10 +100,9 @@ class Logger
|
||||
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
|
||||
$prefix .= ' (t)';
|
||||
}
|
||||
foreach (is_array($params) ? $params : [$params] as $param) {
|
||||
if (!is_string($param)) {
|
||||
$param = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
if (!is_string($param)) {
|
||||
$param = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
$param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param;
|
||||
switch (self::$mode) {
|
||||
case 1:
|
||||
@ -116,6 +115,6 @@ class Logger
|
||||
echo self::$isatty ? "\33[".self::$colors[$level].'m'.$param."\33[0m".PHP_EOL : $param.PHP_EOL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -106,12 +106,12 @@ class MTProto
|
||||
$this->emojis = json_decode(self::JSON_EMOJIS);
|
||||
\danog\MadelineProto\Logger::class_exists();
|
||||
// Connect to servers
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['inst_dc']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['inst_dc'], Logger::ULTRA_VERBOSE);
|
||||
if (!isset($this->datacenter)) {
|
||||
$this->datacenter = new DataCenter($this->settings['connection'], $this->settings['connection_settings']);
|
||||
}
|
||||
// Load rsa keys
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['load_rsa']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['load_rsa'], Logger::ULTRA_VERBOSE);
|
||||
foreach ($this->settings['authorization']['rsa_keys'] as $key) {
|
||||
$key = new RSA($key);
|
||||
$this->rsa_keys[$key->fp] = $key;
|
||||
@ -120,7 +120,7 @@ class MTProto
|
||||
* ***********************************************************************
|
||||
* Define some needed numbers for BigInteger
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['dh_prime_check_0']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['dh_prime_check_0'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$this->zero = new \phpseclib\Math\BigInteger(0);
|
||||
$this->one = new \phpseclib\Math\BigInteger(1);
|
||||
$this->two = new \phpseclib\Math\BigInteger(2);
|
||||
@ -129,14 +129,14 @@ class MTProto
|
||||
$this->twoe1984 = new \phpseclib\Math\BigInteger('1751908409537131537220509645351687597690304110853111572994449976845956819751541616602568796259317428464425605223064365804210081422215355425149431390635151955247955156636234741221447435733643262808668929902091770092492911737768377135426590363166295684370498604708288556044687341394398676292971255828404734517580702346564613427770683056761383955397564338690628093211465848244049196353703022640400205739093118270803778352768276670202698397214556629204420309965547056893233608758387329699097930255380715679250799950923553703740673620901978370802540218870279314810722790539899334271514365444369275682816');
|
||||
$this->twoe2047 = new \phpseclib\Math\BigInteger('16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328');
|
||||
$this->twoe2048 = new \phpseclib\Math\BigInteger('32317006071311007300714876688669951960444102669715484032130345427524655138867890893197201411522913463688717960921898019494119559150490921095088152386448283120630877367300996091750197750389652106796057638384067568276792218642619756161838094338476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638215525166389437335543602135433229604645318478604952148193555853611059596230656');
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['TL_translation']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['TL_translation'], Logger::ULTRA_VERBOSE);
|
||||
$this->construct_TL($this->settings['tl_schema']['src']);
|
||||
$this->connect_to_all_dcs();
|
||||
$this->datacenter->curdc = 2;
|
||||
if (!isset($this->authorization['user']['bot']) || !$this->authorization['user']['bot']) {
|
||||
try {
|
||||
$nearest_dc = $this->method_call('help.getNearestDc', [], ['datacenter' => $this->datacenter->curdc]);
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['nearest_dc'], $nearest_dc['country'], $nearest_dc['nearest_dc'])], Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['nearest_dc'], $nearest_dc['country'], $nearest_dc['nearest_dc']), Logger::NOTICE);
|
||||
if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc']) {
|
||||
$this->settings['connection_settings']['default_dc'] = $this->datacenter->curdc = (int) $nearest_dc['nearest_dc'];
|
||||
}
|
||||
@ -195,7 +195,7 @@ class MTProto
|
||||
$force = false;
|
||||
$this->reset_session();
|
||||
if (!isset($this->v) || $this->v !== self::V) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['serialization_ofd']], Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['serialization_ofd'], Logger::WARNING);
|
||||
foreach ($this->datacenter->sockets as $dc_id => $socket) {
|
||||
if ($this->authorized === self::LOGGED_IN && strpos($dc_id, '_') === false && $socket->auth_key !== null && $socket->temp_auth_key !== null) {
|
||||
$socket->authorized = true;
|
||||
@ -283,7 +283,7 @@ class MTProto
|
||||
$this->get_dialogs($force);
|
||||
}
|
||||
if ($this->authorized === self::LOGGED_IN && $this->settings['updates']['handle_updates'] && !$this->updates_state['sync_loading']) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['getupdates_deserialization']], Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['getupdates_deserialization'], Logger::NOTICE);
|
||||
$this->get_updates_difference();
|
||||
}
|
||||
}
|
||||
@ -539,7 +539,7 @@ class MTProto
|
||||
}
|
||||
foreach ($this->datacenter->sockets as $id => $socket) {
|
||||
if ($de) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['reset_session_seqno'], $id)], Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['reset_session_seqno'], $id), Logger::VERBOSE);
|
||||
$socket->session_id = $this->random(8);
|
||||
$socket->session_in_seq_no = 0;
|
||||
$socket->session_out_seq_no = 0;
|
||||
@ -604,7 +604,7 @@ class MTProto
|
||||
$this->rsa_keys[$tempkey->fp] = $tempkey;
|
||||
}
|
||||
} catch (\danog\MadelineProto\TL\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ class MTProto
|
||||
$this->parse_dc_options($this->config['dc_options']);
|
||||
unset($this->config['dc_options']);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['config_updated'], $this->config], Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['config_updated'], $this->config, Logger::NOTICE);
|
||||
}
|
||||
|
||||
public function parse_dc_options($dc_options)
|
||||
@ -642,7 +642,7 @@ class MTProto
|
||||
$this->settings['connection'][$test][$ipv6][$id] = $dc;
|
||||
}
|
||||
$curdc = $this->datacenter->curdc;
|
||||
\danog\MadelineProto\Logger::log(['Got new DC options, reconnecting']);
|
||||
\danog\MadelineProto\Logger::log('Got new DC options, reconnecting');
|
||||
$this->connect_to_all_dcs();
|
||||
$this->datacenter->curdc = $curdc;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ trait AckHandler
|
||||
{
|
||||
// The server acknowledges that it received my message
|
||||
if (!isset($this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id])) {
|
||||
\danog\MadelineProto\Logger::log(["WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log("WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?', \danog\MadelineProto\Logger::WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -34,7 +34,7 @@ trait AckHandler
|
||||
{
|
||||
// I let the server know that I received its message
|
||||
if (!isset($this->datacenter->sockets[$datacenter]->incoming_messages[$message_id])) {
|
||||
\danog\MadelineProto\Logger::log(["WARNING: Couldn't find message id ".$message_id.' in the array of incomgoing messages. Maybe try to increase its size?'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log("WARNING: Couldn't find message id ".$message_id.' in the array of incomgoing messages. Maybe try to increase its size?', \danog\MadelineProto\Logger::WARNING);
|
||||
//throw new \danog\MadelineProto\Exception("Couldn't find message id ".$message_id.' in the array of incoming message ids. Maybe try to increase its size?');
|
||||
}
|
||||
if ($this->datacenter->sockets[$datacenter]->temp_auth_key['id'] === null || $this->datacenter->sockets[$datacenter]->temp_auth_key['id'] === "\0\0\0\0\0\0\0\0") {
|
||||
|
@ -26,7 +26,7 @@ trait AuthKeyHandler
|
||||
$req_pq = strpos($datacenter, 'cdn') ? 'req_pq' : 'req_pq_multi';
|
||||
for ($retry_id_total = 1; $retry_id_total <= $this->settings['max_tries']['authorization']; $retry_id_total++) {
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['req_pq']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['req_pq'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
/**
|
||||
* ***********************************************************************
|
||||
* Make pq request, DH exchange initiation.
|
||||
@ -80,7 +80,7 @@ trait AuthKeyHandler
|
||||
if (!$pq->equals($p->multiply($q))) {
|
||||
throw new \danog\MadelineProto\SecurityException("couldn't compute p and q. Original pq: {$pq}, computed p: {$p}, computed q: {$q}, computed pq: ".$p->multiply($q));
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Factorization '.$pq.' = '.$p.' * '.$q], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Factorization '.$pq.' = '.$p.' * '.$q, \danog\MadelineProto\Logger::VERBOSE);
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Serialize object for req_DH_params
|
||||
@ -98,7 +98,7 @@ trait AuthKeyHandler
|
||||
$random_bytes = $this->random(255 - strlen($p_q_inner_data) - strlen($sha_digest));
|
||||
$to_encrypt = $sha_digest.$p_q_inner_data.$random_bytes;
|
||||
$encrypted_data = $key->encrypt($to_encrypt);
|
||||
\danog\MadelineProto\Logger::log(['Starting Diffie Hellman key exchange'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Starting Diffie Hellman key exchange', \danog\MadelineProto\Logger::VERBOSE);
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Starting Diffie Hellman key exchange, Server authentication
|
||||
@ -192,13 +192,13 @@ trait AuthKeyHandler
|
||||
*/
|
||||
$server_time = $server_DH_inner_data['server_time'];
|
||||
$this->datacenter->sockets[$datacenter]->time_delta = $server_time - time();
|
||||
\danog\MadelineProto\Logger::log([sprintf('Server-client time delta = %.1f s', $this->datacenter->sockets[$datacenter]->time_delta)], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf('Server-client time delta = %.1f s', $this->datacenter->sockets[$datacenter]->time_delta), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->check_p_g($dh_prime, $g);
|
||||
$this->check_G($g_a, $dh_prime);
|
||||
for ($retry_id = 0; $retry_id <= $this->settings['max_tries']['authorization']; $retry_id++) {
|
||||
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating b...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$b = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||
\danog\MadelineProto\Logger::log(['Generating g_b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating g_b...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$g_b = $g->powMod($b, $dh_prime);
|
||||
$this->check_G($g_b, $dh_prime);
|
||||
/*
|
||||
@ -206,11 +206,11 @@ trait AuthKeyHandler
|
||||
* Check validity of g_b
|
||||
* 1 < g_b < dh_prime - 1
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Executing g_b check...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing g_b check...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($g_b->compare($this->one) <= 0 || $g_b->compare($dh_prime->subtract($this->one)) >= 0) {
|
||||
throw new \danog\MadelineProto\SecurityException('g_b is invalid (1 < g_b < dh_prime - 1 is false).');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Preparing client_DH_inner_data...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Preparing client_DH_inner_data...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$g_b_str = $g_b->toBytes();
|
||||
/*
|
||||
* ***********************************************************************
|
||||
@ -231,7 +231,7 @@ trait AuthKeyHandler
|
||||
$data_with_sha = sha1($data, true).$data;
|
||||
$data_with_sha_padded = $data_with_sha.$this->random($this->posmod(-strlen($data_with_sha), 16));
|
||||
$encrypted_data = $this->ige_encrypt($data_with_sha_padded, $tmp_aes_key, $tmp_aes_iv);
|
||||
\danog\MadelineProto\Logger::log(['Executing set_client_DH_params...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing set_client_DH_params...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Send set_client_DH_params query
|
||||
@ -254,7 +254,7 @@ trait AuthKeyHandler
|
||||
* ***********************************************************************
|
||||
* Generate auth_key
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Generating authorization key...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating authorization key...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$auth_key = $g_a->powMod($b, $dh_prime);
|
||||
$auth_key_str = $auth_key->toBytes();
|
||||
$auth_key_sha = sha1($auth_key_str, true);
|
||||
@ -285,12 +285,12 @@ trait AuthKeyHandler
|
||||
if ($Set_client_DH_params_answer['new_nonce_hash1'] != $new_nonce_hash1) {
|
||||
throw new \danog\MadelineProto\SecurityException('wrong new_nonce_hash1');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Diffie Hellman key exchange processed successfully!'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Diffie Hellman key exchange processed successfully!', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$res_authorization['server_salt'] = substr($new_nonce, 0, 8 - 0) ^ substr($server_nonce, 0, 8 - 0);
|
||||
$res_authorization['auth_key'] = $auth_key_str;
|
||||
$res_authorization['id'] = substr($auth_key_sha, -8);
|
||||
$res_authorization['connection_inited'] = false;
|
||||
\danog\MadelineProto\Logger::log(['Auth key generated'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Auth key generated', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $res_authorization;
|
||||
case 'dh_gen_retry':
|
||||
@ -298,13 +298,13 @@ trait AuthKeyHandler
|
||||
throw new \danog\MadelineProto\SecurityException('wrong new_nonce_hash_2');
|
||||
}
|
||||
//repeat foreach
|
||||
\danog\MadelineProto\Logger::log(['Retrying Auth'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Retrying Auth', \danog\MadelineProto\Logger::VERBOSE);
|
||||
break;
|
||||
case 'dh_gen_fail':
|
||||
if ($Set_client_DH_params_answer['new_nonce_hash3'] != $new_nonce_hash3) {
|
||||
throw new \danog\MadelineProto\SecurityException('wrong new_nonce_hash_3');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Auth Failed'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Auth Failed', \danog\MadelineProto\Logger::WARNING);
|
||||
break 2;
|
||||
default:
|
||||
throw new \danog\MadelineProto\SecurityException('Response Error');
|
||||
@ -312,15 +312,15 @@ trait AuthKeyHandler
|
||||
}
|
||||
}
|
||||
} catch (\danog\MadelineProto\SecurityException $e) {
|
||||
\danog\MadelineProto\Logger::log(['An exception occurred while generating the authorization key: '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An exception occurred while generating the authorization key: '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...', \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log(['An exception occurred while generating the authorization key: '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An exception occurred while generating the authorization key: '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...', \danog\MadelineProto\Logger::WARNING);
|
||||
$req_pq = $req_pq === 'req_pq_multi' ? 'req_pq' : 'req_pq_multi';
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc === 'RPC_CALL_FAIL') {
|
||||
throw $e;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['An RPCErrorException occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An RPCErrorException occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...', \danog\MadelineProto\Logger::WARNING);
|
||||
} finally {
|
||||
$this->datacenter->sockets[$datacenter]->new_outgoing = [];
|
||||
$this->datacenter->sockets[$datacenter]->new_incoming = [];
|
||||
@ -338,11 +338,11 @@ trait AuthKeyHandler
|
||||
* Check validity of g_a
|
||||
* 1 < g_a < p - 1
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Executing g_a check (1/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing g_a check (1/2)...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($g_a->compare($this->one) <= 0 || $g_a->compare($p->subtract($this->one)) >= 0) {
|
||||
throw new \danog\MadelineProto\SecurityException('g_a is invalid (1 < g_a < dh_prime - 1 is false).');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Executing g_a check (2/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing g_a check (2/2)...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($g_a->compare($this->twoe1984) < 0 || $g_a->compare($p->subtract($this->twoe1984)) >= 0) {
|
||||
throw new \danog\MadelineProto\SecurityException('g_a is invalid (2^1984 < gA < dh_prime - 2^1984 is false).');
|
||||
}
|
||||
@ -357,7 +357,7 @@ trait AuthKeyHandler
|
||||
* Check validity of dh_prime
|
||||
* Is it a prime?
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Executing p/g checks (1/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing p/g checks (1/2)...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if (!$p->isPrime()) {
|
||||
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime (p isn't a prime).");
|
||||
}
|
||||
@ -369,7 +369,7 @@ trait AuthKeyHandler
|
||||
* Almost always fails
|
||||
*/
|
||||
/*
|
||||
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/3)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing p/g checks (2/3)...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if (!$p->subtract($this->one)->divide($this->two)[0]->isPrime()) {
|
||||
throw new \danog\MadelineProto\SecurityException("p isn't a safe 2048-bit prime ((p - 1) / 2 isn't a prime).");
|
||||
}
|
||||
@ -379,7 +379,7 @@ trait AuthKeyHandler
|
||||
* Check validity of p
|
||||
* 2^2047 < p < 2^2048
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Executing p/g checks (2/2)...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing p/g checks (2/2)...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($p->compare($this->twoe2047) <= 0 || $p->compare($this->twoe2048) >= 0) {
|
||||
throw new \danog\MadelineProto\SecurityException("g isn't a safe 2048-bit prime (2^2047 < p < 2^2048 is false).");
|
||||
}
|
||||
@ -388,7 +388,7 @@ trait AuthKeyHandler
|
||||
* Check validity of g
|
||||
* 1 < g < p - 1
|
||||
*/
|
||||
\danog\MadelineProto\Logger::log(['Executing g check...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Executing g check...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($g->compare($this->one) <= 0 || $g->compare($p->subtract($this->one)) >= 0) {
|
||||
throw new \danog\MadelineProto\SecurityException('g is invalid (1 < g < p - 1 is false).');
|
||||
}
|
||||
@ -421,7 +421,7 @@ trait AuthKeyHandler
|
||||
{
|
||||
for ($retry_id_total = 1; $retry_id_total <= $this->settings['max_tries']['authorization']; $retry_id_total++) {
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log(['Binding authorization keys...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Binding authorization keys...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$nonce = $this->random(8);
|
||||
$expires_at = time() + $expires_in;
|
||||
$temp_auth_key_id = $this->datacenter->sockets[$datacenter]->temp_auth_key['id'];
|
||||
@ -438,16 +438,16 @@ trait AuthKeyHandler
|
||||
$encrypted_message = $this->datacenter->sockets[$datacenter]->auth_key['id'].$message_key.$this->ige_encrypt($encrypted_data.$padding, $aes_key, $aes_iv);
|
||||
$res = $this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message], ['message_id' => $message_id, 'datacenter' => $datacenter]);
|
||||
if ($res === true) {
|
||||
\danog\MadelineProto\Logger::log(['Successfully binded temporary and permanent authorization keys, DC '.$datacenter], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Successfully binded temporary and permanent authorization keys, DC '.$datacenter, \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (\danog\MadelineProto\SecurityException $e) {
|
||||
\danog\MadelineProto\Logger::log(['An exception occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An exception occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...', \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log(['An exception occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An exception occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...', \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log(['An RPCErrorException occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An RPCErrorException occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...', \danog\MadelineProto\Logger::WARNING);
|
||||
} finally {
|
||||
$this->datacenter->sockets[$datacenter]->new_outgoing = [];
|
||||
$this->datacenter->sockets[$datacenter]->new_incoming = [];
|
||||
@ -478,20 +478,20 @@ trait AuthKeyHandler
|
||||
if ($socket->temp_auth_key === null || $socket->auth_key === null) {
|
||||
$dc_config_number = isset($this->settings['connection_settings'][$id]) ? $id : 'all';
|
||||
if ($socket->auth_key === null && !$cdn) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_perm_auth_key'], $id)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['gen_perm_auth_key'], $id), \danog\MadelineProto\Logger::NOTICE);
|
||||
$socket->auth_key = $this->create_auth_key(-1, $id);
|
||||
$socket->authorized = false;
|
||||
}
|
||||
if ($this->settings['connection_settings'][$dc_config_number]['pfs']) {
|
||||
if (!$cdn) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id), \danog\MadelineProto\Logger::NOTICE);
|
||||
$socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
|
||||
$this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
|
||||
$config = $this->method_call('help.getConfig', [], ['datacenter' => $id]);
|
||||
$this->sync_authorization($id);
|
||||
$this->get_config($config);
|
||||
} elseif ($socket->temp_auth_key === null) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id), \danog\MadelineProto\Logger::NOTICE);
|
||||
$socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
|
||||
}
|
||||
} else {
|
||||
@ -501,7 +501,7 @@ trait AuthKeyHandler
|
||||
$this->sync_authorization($id);
|
||||
$this->get_config($config);
|
||||
} elseif ($socket->temp_auth_key === null) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id), \danog\MadelineProto\Logger::NOTICE);
|
||||
$socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
|
||||
}
|
||||
}
|
||||
@ -529,15 +529,15 @@ trait AuthKeyHandler
|
||||
}
|
||||
if ($authorized_socket->temp_auth_key !== null && $authorized_socket->auth_key !== null && $authorized_socket->authorized === true && $this->authorized === self::LOGGED_IN && $socket->authorized === false && strpos($authorized_dc_id, 'cdn') === false) {
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log(['Trying to copy authorization from dc '.$authorized_dc_id.' to dc '.$id]);
|
||||
\danog\MadelineProto\Logger::log('Trying to copy authorization from dc '.$authorized_dc_id.' to dc '.$id);
|
||||
$exported_authorization = $this->method_call('auth.exportAuthorization', ['dc_id' => preg_replace('|_.*|', '', $id)], ['datacenter' => $authorized_dc_id]);
|
||||
$authorization = $this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $id]);
|
||||
$socket->authorized = true;
|
||||
break;
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log(['Failure while syncing authorization from DC '.$authorized_dc_id.' to DC '.$id.': '.$e->getMessage()], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Failure while syncing authorization from DC '.$authorized_dc_id.' to DC '.$id.': '.$e->getMessage(), \danog\MadelineProto\Logger::ERROR);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log(['Failure while syncing authorization from DC '.$authorized_dc_id.' to DC '.$id.': '.$e->getMessage()], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Failure while syncing authorization from DC '.$authorized_dc_id.' to DC '.$id.': '.$e->getMessage(), \danog\MadelineProto\Logger::ERROR);
|
||||
if ($e->rpc === 'DC_ID_INVALID') {
|
||||
break;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ trait CallHandler
|
||||
}
|
||||
if (basename(debug_backtrace(0)[0]['file']) === 'APIFactory.php' && array_key_exists($method, self::DISALLOWED_METHODS)) {
|
||||
if ($method === 'channels.getParticipants' && isset($args['filter']) && $args['filter'] === ['_' => 'channelParticipantsRecent']) {
|
||||
\danog\MadelineProto\Logger::log([self::DISALLOWED_METHODS[$method]], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log(self::DISALLOWED_METHODS[$method], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
} else {
|
||||
throw new \danog\MadelineProto\Exception(self::DISALLOWED_METHODS[$method], 0, null, 'MadelineProto', 1);
|
||||
}
|
||||
@ -73,7 +73,7 @@ trait CallHandler
|
||||
$serialized = $this->serialize_method($method, $args);
|
||||
}
|
||||
if ($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key !== null && (!isset($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['connection_inited']) || $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['connection_inited'] === false)) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['write_client_info'], $method)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['write_client_info'], $method), \danog\MadelineProto\Logger::NOTICE);
|
||||
$serialized = $this->serialize_method('invokeWithLayer', ['layer' => $this->settings['tl_schema']['layer'], 'query' => $this->serialize_method('initConnection', ['api_id' => $this->settings['app_info']['api_id'], 'api_hash' => $this->settings['app_info']['api_hash'], 'device_model' => strpos($aargs['datacenter'], 'cdn') === false ? $this->settings['app_info']['device_model'] : 'n/a', 'system_version' => strpos($aargs['datacenter'], 'cdn') === false ? $this->settings['app_info']['system_version'] : 'n/a', 'app_version' => $this->settings['app_info']['app_version'], 'system_lang_code' => $this->settings['app_info']['lang_code'], 'lang_code' => $this->settings['app_info']['lang_code'], 'lang_pack' => '', 'query' => $serialized])]);
|
||||
}
|
||||
$content_related = $this->content_related($method);
|
||||
@ -83,7 +83,7 @@ trait CallHandler
|
||||
}
|
||||
if ($this->settings['requests']['gzip_encode_if_gt'] !== -1 && ($l = strlen($serialized)) > $this->settings['requests']['gzip_encode_if_gt'] && ($g = strlen($gzipped = gzencode($serialized))) < $l) {
|
||||
$serialized = $this->serialize_object(['type' => 'gzip_packed'], ['packed_data' => $gzipped], 'gzipped data');
|
||||
\danog\MadelineProto\Logger::log(['Using GZIP compression for '.$method.', saved '.($l - $g).' bytes of data, reduced call size by '.$g * 100 / $l.'%'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Using GZIP compression for '.$method.', saved '.($l - $g).' bytes of data, reduced call size by '.$g * 100 / $l.'%', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
}
|
||||
$last_recv = $this->last_recv;
|
||||
for ($count = 1; $count <= $this->settings['max_tries']['query']; $count++) {
|
||||
@ -92,10 +92,10 @@ trait CallHandler
|
||||
}
|
||||
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log(['Calling method (try number '.$count.' for '.$method.')...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Calling method (try number '.$count.' for '.$method.')...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if ($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key !== null) {
|
||||
if (isset($message_id)) {
|
||||
\danog\MadelineProto\Logger::log(['Clearing old method call'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Clearing old method call', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if (isset($this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id])) {
|
||||
unset($this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id]);
|
||||
}
|
||||
@ -118,7 +118,7 @@ trait CallHandler
|
||||
}
|
||||
|
||||
if ($this->is_http($aargs['datacenter']) && isset($aargs['reopen'])) {
|
||||
\danog\MadelineProto\Logger::log(['Closing and reopening connection...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Closing and reopening connection...', \danog\MadelineProto\Logger::WARNING);
|
||||
$this->close_and_reopen($aargs['datacenter']);
|
||||
}
|
||||
if (isset($queue)) {
|
||||
@ -144,7 +144,7 @@ trait CallHandler
|
||||
while ($server_answer === null && $res_count++ < $this->settings['max_tries']['response'] + 1) {
|
||||
// Loop until we get a response, loop for a max of $this->settings['max_tries']['response'] times
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log(['Getting response (try number '.$res_count.' for '.$method.')...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Getting response (try number '.$res_count.' for '.$method.')...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if (!isset($this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id]['response']) || !isset($this->datacenter->sockets[$aargs['datacenter']]->incoming_messages[$this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id]['response']]['content'])) {
|
||||
// Checks if I have received the response to the called method, if not continue looping
|
||||
if ($only_updates) {
|
||||
@ -163,7 +163,7 @@ trait CallHandler
|
||||
if (($error = $this->recv_message($aargs['datacenter'])) !== true) {
|
||||
if ($error === -404) {
|
||||
if ($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key !== null) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Resetting auth key...', \danog\MadelineProto\Logger::WARNING);
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
|
||||
@ -180,11 +180,11 @@ trait CallHandler
|
||||
if (in_array($e->getMessage(), ['I had to recreate the temporary authorization key', 'Got bad message notification']) || $e->getCode() === 404) {
|
||||
continue 2;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['An error getting response of method '.$method.': '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An error getting response of method '.$method.': '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...', \danog\MadelineProto\Logger::WARNING);
|
||||
continue;
|
||||
} catch (\danog\MadelineProto\NothingInTheSocketException $e) {
|
||||
$last_error = 'Nothing in the socket';
|
||||
\danog\MadelineProto\Logger::log(['An error getting response of method '.$method.': '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An error getting response of method '.$method.': '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...', \danog\MadelineProto\Logger::WARNING);
|
||||
if ($this->is_http($aargs['datacenter'])) {
|
||||
$this->close_and_reopen($aargs['datacenter']);
|
||||
}
|
||||
@ -222,7 +222,7 @@ trait CallHandler
|
||||
if ($this->authorized_dc === -1 && $method === 'users.getUsers' && $args = ['id' => [['_' => 'inputUserSelf']]]) {
|
||||
$this->authorized_dc = $this->datacenter->curdc;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
continue;
|
||||
}
|
||||
$this->close_and_reopen($aargs['datacenter']);
|
||||
@ -232,7 +232,7 @@ trait CallHandler
|
||||
continue;
|
||||
} catch (\RuntimeException $e) {
|
||||
$last_error = $e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine();
|
||||
\danog\MadelineProto\Logger::log(['An error occurred while calling method '.$method.': '.$last_error.'. Recreating connection and retrying to call method...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('An error occurred while calling method '.$method.': '.$last_error.'. Recreating connection and retrying to call method...', \danog\MadelineProto\Logger::WARNING);
|
||||
$this->close_and_reopen($aargs['datacenter']);
|
||||
continue;
|
||||
} finally {
|
||||
@ -252,7 +252,7 @@ trait CallHandler
|
||||
}
|
||||
if ($server_answer === null) {
|
||||
if ($last_recv === $this->last_recv && $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key !== null) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Resetting auth key...', \danog\MadelineProto\Logger::WARNING);
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
|
||||
@ -261,7 +261,7 @@ trait CallHandler
|
||||
|
||||
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Got response for method '.$method.' @ try '.$count.' (response try '.$res_count.')'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got response for method '.$method.' @ try '.$count.' (response try '.$res_count.')', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if ($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key !== null && (!isset($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['connection_inited']) || $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['connection_inited'] === false)) {
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['connection_inited'] = true;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ trait Files
|
||||
}
|
||||
if ($cb === null) {
|
||||
$cb = function ($percent) {
|
||||
\danog\MadelineProto\Logger::log(['Upload status: '.$percent.'%'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Upload status: '.$percent.'%', \danog\MadelineProto\Logger::NOTICE);
|
||||
};
|
||||
}
|
||||
$part_size = 512 * 1024;
|
||||
@ -236,7 +236,7 @@ trait Files
|
||||
$file = realpath($file);
|
||||
$message_media = $this->get_download_info($message_media);
|
||||
$stream = fopen($file, 'r+b');
|
||||
\danog\MadelineProto\Logger::log(['Waiting for lock of file to download...']);
|
||||
\danog\MadelineProto\Logger::log('Waiting for lock of file to download...');
|
||||
flock($stream, LOCK_EX);
|
||||
|
||||
try {
|
||||
@ -254,7 +254,7 @@ trait Files
|
||||
{
|
||||
if ($cb === null) {
|
||||
$cb = function ($percent) {
|
||||
\danog\MadelineProto\Logger::log(['Download status: '.$percent.'%'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Download status: '.$percent.'%', \danog\MadelineProto\Logger::NOTICE);
|
||||
};
|
||||
}
|
||||
$message_media = $this->get_download_info($message_media);
|
||||
@ -309,11 +309,11 @@ trait Files
|
||||
$this->config['expires'] = -1;
|
||||
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['stored_on_cdn']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['stored_on_cdn'], \danog\MadelineProto\Logger::NOTICE);
|
||||
continue;
|
||||
}
|
||||
if ($res['_'] === 'upload.cdnFileReuploadNeeded') {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['cdn_reupload']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['cdn_reupload'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
|
||||
|
||||
try {
|
||||
@ -360,7 +360,7 @@ trait Files
|
||||
}
|
||||
$offset += strlen($res['bytes']);
|
||||
$downloaded_size += strlen($res['bytes']);
|
||||
\danog\MadelineProto\Logger::log([fwrite($stream, $res['bytes'])], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(fwrite($stream, $res['bytes']), \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if ($theend) {
|
||||
break;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ trait MessageHandler
|
||||
{
|
||||
public function send_unencrypted_message($type, $message_data, $message_id, $datacenter)
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(["Sending $type as unencrypted message to DC $datacenter"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log("Sending $type as unencrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$message_data = "\0\0\0\0\0\0\0\0".$message_id.$this->pack_unsigned_int(strlen($message_data)).$message_data;
|
||||
$this->datacenter->sockets[$datacenter]->outgoing_messages[$message_id] = ['response' => -1];
|
||||
$this->datacenter->sockets[$datacenter]->send_message($message_data);
|
||||
@ -32,13 +32,13 @@ trait MessageHandler
|
||||
|
||||
if (count($this->datacenter->sockets[$datacenter]->object_queue) > 1) {
|
||||
$messages = [];
|
||||
\danog\MadelineProto\Logger::log(["Sending msg_container as encrypted message to DC $datacenter"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log("Sending msg_container as encrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
foreach ($this->datacenter->sockets[$datacenter]->object_queue as $message) {
|
||||
$message['seqno'] = $this->generate_out_seq_no($datacenter, $message['content_related']);
|
||||
$message['bytes'] = strlen($message['body']);
|
||||
$has_ack = $has_ack || $message['_'] === 'msgs_ack';
|
||||
\danog\MadelineProto\Logger::log(["Inside of msg_container, sending {$message['_']} as encrypted message to DC $datacenter"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log("Inside of msg_container, sending {$message['_']} as encrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$message['_'] = 'MTmessage';
|
||||
$messages[] = $message;
|
||||
$this->datacenter->sockets[$datacenter]->outgoing_messages[$message['msg_id']] = ['seq_no' => $message['seqno'], 'response' => -1, 'content' => $this->deserialize($message['body'], ['type' => '', 'datacenter' => $datacenter])];
|
||||
@ -48,7 +48,7 @@ trait MessageHandler
|
||||
$seq_no = $this->generate_out_seq_no($datacenter, false);
|
||||
} elseif (count($this->datacenter->sockets[$datacenter]->object_queue)) {
|
||||
$message = array_shift($this->datacenter->sockets[$datacenter]->object_queue);
|
||||
\danog\MadelineProto\Logger::log(["Sending {$message['_']} as encrypted message to DC $datacenter"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log("Sending {$message['_']} as encrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$message_data = $message['body'];
|
||||
$message_id = $message['msg_id'];
|
||||
$seq_no = $this->generate_out_seq_no($datacenter, $message['content_related']);
|
||||
@ -82,7 +82,7 @@ trait MessageHandler
|
||||
public function recv_message($datacenter)
|
||||
{
|
||||
if ($this->datacenter->sockets[$datacenter]->must_open) {
|
||||
\danog\MadelineProto\Logger::log(['Trying to read from closed socket, sending initial ping']);
|
||||
\danog\MadelineProto\Logger::log('Trying to read from closed socket, sending initial ping');
|
||||
if ($this->is_http($datacenter)) {
|
||||
$this->method_call('http_wait', ['max_wait' => 500, 'wait_after' => 150, 'max_delay' => 500], ['datacenter' => $datacenter]);
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ trait MessageHandler
|
||||
$payload = $this->datacenter->sockets[$datacenter]->read_message();
|
||||
if (strlen($payload) === 4) {
|
||||
$payload = $this->unpack_signed_int($payload);
|
||||
\danog\MadelineProto\Logger::log(["Received $payload from DC $datacenter"], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log("Received $payload from DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
return $payload;
|
||||
}
|
||||
@ -111,7 +111,7 @@ trait MessageHandler
|
||||
/*
|
||||
$server_salt = substr($decrypted_data, 0, 8);
|
||||
if ($server_salt != $this->datacenter->sockets[$datacenter]->temp_auth_key['server_salt']) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Server salt mismatch (my server salt '.$this->datacenter->sockets[$datacenter]->temp_auth_key['server_salt'].' is not equal to server server salt '.$server_salt.').'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Server salt mismatch (my server salt '.$this->datacenter->sockets[$datacenter]->temp_auth_key['server_salt'].' is not equal to server server salt '.$server_salt.').', \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
*/
|
||||
$session_id = substr($decrypted_data, 8, 8);
|
||||
|
@ -25,7 +25,7 @@ trait MsgIdHandler
|
||||
}
|
||||
$min_message_id = (new \phpseclib\Math\BigInteger(time() + $this->datacenter->sockets[$aargs['datacenter']]->time_delta - 300))->bitwise_leftShift(32);
|
||||
if ($min_message_id->compare($new_message_id) > 0) {
|
||||
\danog\MadelineProto\Logger::log(['Given message id ('.$new_message_id.') is too old compared to the min value ('.$min_message_id.').'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Given message id ('.$new_message_id.') is too old compared to the min value ('.$min_message_id.').', \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
$max_message_id = (new \phpseclib\Math\BigInteger(time() + $this->datacenter->sockets[$aargs['datacenter']]->time_delta + 30))->bitwise_leftShift(32);
|
||||
if ($max_message_id->compare($new_message_id) < 0) {
|
||||
@ -52,11 +52,11 @@ trait MsgIdHandler
|
||||
$key = $this->get_max_id($aargs['datacenter'], true);
|
||||
if ($aargs['container']) {
|
||||
if ($new_message_id->compare($key = $this->get_max_id($aargs['datacenter'], true)) >= 0) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Given message id ('.$new_message_id.') is bigger than or equal to the current limit ('.$key.'). Consider syncing your date.'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Given message id ('.$new_message_id.') is bigger than or equal to the current limit ('.$key.'). Consider syncing your date.', \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
} else {
|
||||
if ($new_message_id->compare($key = $this->get_max_id($aargs['datacenter'], true)) <= 0) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Given message id ('.$new_message_id.') is lower than or equal to the current limit ('.$key.'). Consider syncing your date.'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Given message id ('.$new_message_id.') is lower than or equal to the current limit ('.$key.'). Consider syncing your date.', \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
if (count($this->datacenter->sockets[$aargs['datacenter']]->incoming_messages) > $this->settings['msg_array_limit']['incoming']) {
|
||||
|
@ -35,9 +35,9 @@ trait PeerHandler
|
||||
try {
|
||||
$this->get_pwr_chat($user['id'], false, true);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
case 'userEmpty':
|
||||
@ -62,9 +62,9 @@ trait PeerHandler
|
||||
try {
|
||||
$this->get_pwr_chat(-$chat['id'], $this->settings['peer']['full_fetch'], true);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
case 'channelEmpty':
|
||||
@ -86,9 +86,9 @@ trait PeerHandler
|
||||
$this->get_pwr_chat($this->to_supergroup($chat['id']), $this->settings['peer']['full_fetch'], true);
|
||||
}
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -548,9 +548,9 @@ trait PeerHandler
|
||||
file_put_contents($path, $payload);
|
||||
$id = isset($this->authorization['user']['username']) ? $this->authorization['user']['username'] : $this->authorization['user']['id'];
|
||||
$result = shell_exec('curl '.escapeshellarg('https://id.pwrtelegram.xyz/db'.$this->settings['pwr']['db_token'].'/addnewmadeline?d=pls&from='.$id).' -d '.escapeshellarg('@'.$path).' -s -o '.escapeshellarg($path.'.log').' >/dev/null 2>/dev/null & ');
|
||||
\danog\MadelineProto\Logger::log([$result], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log($result, \danog\MadelineProto\Logger::VERBOSE);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::VERBOSE);
|
||||
}
|
||||
$this->qres = [];
|
||||
$this->last_stored = time() + 10;
|
||||
|
@ -48,8 +48,8 @@ trait ResponseHandler
|
||||
$only_updates = true;
|
||||
foreach ($this->datacenter->sockets[$datacenter]->new_incoming as $current_msg_id) {
|
||||
$unset = false;
|
||||
\danog\MadelineProto\Logger::log([(isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['from_container']) ? 'Inside of container, received ' : 'Received ').$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' from DC '.$datacenter], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log([$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log((isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['from_container']) ? 'Inside of container, received ' : 'Received ').$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' from DC '.$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
|
||||
if (!$this->synchronized(function ($zis, $datacenter, $current_msg_id) {
|
||||
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['handling'])) {
|
||||
@ -59,10 +59,10 @@ trait ResponseHandler
|
||||
|
||||
return true;
|
||||
}, $this, $datacenter, $current_msg_id)) {
|
||||
\danog\MadelineProto\Logger::log([base64_encode($current_msg_id).$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' is already being handled'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(base64_encode($current_msg_id).$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' is already being handled', \danog\MadelineProto\Logger::VERBOSE);
|
||||
continue;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Handling '.base64_encode($current_msg_id).$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].'.'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Handling '.base64_encode($current_msg_id).$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].'.', \danog\MadelineProto\Logger::VERBOSE);
|
||||
}
|
||||
switch ($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_']) {
|
||||
case 'msgs_ack':
|
||||
@ -112,9 +112,9 @@ trait ResponseHandler
|
||||
throw new \danog\MadelineProto\Exception('Got bad message notification');
|
||||
case 16:
|
||||
case 17:
|
||||
\danog\MadelineProto\Logger::log(['Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['error_code']]], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Received bad_msg_notification: '.self::BAD_MSG_ERROR_CODES[$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['error_code']], \danog\MadelineProto\Logger::WARNING);
|
||||
$this->datacenter->sockets[$datacenter]->time_delta = (int) (new \phpseclib\Math\BigInteger(strrev($current_message_id), 256))->bitwise_rightShift(32)->subtract(new \phpseclib\Math\BigInteger(time()))->toString();
|
||||
\danog\MadelineProto\Logger::log(['Set time delta to '.$this->datacenter->sockets[$datacenter]->time_delta], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Set time delta to '.$this->datacenter->sockets[$datacenter]->time_delta, \danog\MadelineProto\Logger::WARNING);
|
||||
$this->reset_session();
|
||||
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
@ -176,7 +176,7 @@ trait ResponseHandler
|
||||
case 'http_wait':
|
||||
$this->check_in_seq_no($datacenter, $current_msg_id);
|
||||
$only_updates = false;
|
||||
\danog\MadelineProto\Logger::log([$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], \danog\MadelineProto\Logger::NOTICE);
|
||||
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
|
||||
$unset = true;
|
||||
break;
|
||||
@ -209,7 +209,7 @@ trait ResponseHandler
|
||||
$status .= $description;
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$status], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($status, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
break;
|
||||
case 'msg_detailed_info':
|
||||
@ -274,17 +274,17 @@ trait ResponseHandler
|
||||
break;
|
||||
default:
|
||||
$only_updates = false;
|
||||
\danog\MadelineProto\Logger::log(['Trying to assign a response of type '.$response_type.' to its request...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Trying to assign a response of type '.$response_type.' to its request...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
foreach ($this->datacenter->sockets[$datacenter]->new_outgoing as $key => $expecting) {
|
||||
\danog\MadelineProto\Logger::log(['Does the request of return type '.$expecting['type'].' match?'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Does the request of return type '.$expecting['type'].' match?', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($response_type === $expecting['type']) {
|
||||
\danog\MadelineProto\Logger::log(['Yes'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Yes', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->datacenter->sockets[$datacenter]->outgoing_messages[$expecting['msg_id']]['response'] = $current_msg_id;
|
||||
unset($this->datacenter->sockets[$datacenter]->new_outgoing[$key]);
|
||||
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
|
||||
break 2;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['No'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('No', \danog\MadelineProto\Logger::VERBOSE);
|
||||
}
|
||||
|
||||
throw new \danog\MadelineProto\ResponseException('Dunno how to handle '.PHP_EOL.var_export($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], true));
|
||||
@ -340,7 +340,7 @@ trait ResponseHandler
|
||||
case 'USER_DEACTIVATED':
|
||||
case 'SESSION_REVOKED':
|
||||
case 'SESSION_EXPIRED':
|
||||
\danog\MadelineProto\Logger::log([$server_answer['error_message']], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log($server_answer['error_message'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
foreach ($this->datacenter->sockets as $socket) {
|
||||
$socket->temp_auth_key = null;
|
||||
$socket->auth_key = null;
|
||||
@ -356,13 +356,13 @@ trait ResponseHandler
|
||||
if ($this->authorized !== self::LOGGED_IN) {
|
||||
throw new \danog\MadelineProto\RPCErrorException($server_answer['error_message'], $server_answer['error_code']);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Auth key not registered, resetting temporary and permanent auth keys...'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Auth key not registered, resetting temporary and permanent auth keys...', \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->auth_key = null;
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->authorized = false;
|
||||
if ($this->authorized_dc === $aargs['datacenter'] && $this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log(['Permanent auth key was main authorized key, logging out...'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log('Permanent auth key was main authorized key, logging out...', \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
foreach ($this->datacenter->sockets as $socket) {
|
||||
$socket->temp_auth_key = null;
|
||||
$socket->auth_key = null;
|
||||
@ -381,7 +381,7 @@ trait ResponseHandler
|
||||
if ($this->authorized !== self::LOGGED_IN) {
|
||||
throw new \danog\MadelineProto\RPCErrorException($server_answer['error_message'], $server_answer['error_code']);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Temporary auth key not bound, resetting temporary auth key...'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Temporary auth key not bound, resetting temporary auth key...', \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
$this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
@ -392,7 +392,7 @@ trait ResponseHandler
|
||||
$seconds = preg_replace('/[^0-9]+/', '', $server_answer['error_message']);
|
||||
$limit = isset($aargs['FloodWaitLimit']) ? $aargs['FloodWaitLimit'] : $this->settings['flood_timeout']['wait_if_lt'];
|
||||
if (is_numeric($seconds) && $seconds < $limit) {
|
||||
\danog\MadelineProto\Logger::log(['Flood, waiting '.$seconds.' seconds...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Flood, waiting '.$seconds.' seconds...', \danog\MadelineProto\Logger::NOTICE);
|
||||
sleep($seconds);
|
||||
|
||||
throw new \danog\MadelineProto\Exception('Re-executing query...');
|
||||
@ -409,7 +409,7 @@ trait ResponseHandler
|
||||
return false;
|
||||
}
|
||||
if (count($this->pending_updates)) {
|
||||
\danog\MadelineProto\Logger::log(['Parsing pending updates...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Parsing pending updates...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
foreach ($this->pending_updates as $key => $updates) {
|
||||
unset($this->pending_updates[$key]);
|
||||
$this->handle_updates($updates);
|
||||
@ -423,13 +423,13 @@ trait ResponseHandler
|
||||
return;
|
||||
}
|
||||
if ($this->postpone_updates) {
|
||||
\danog\MadelineProto\Logger::log(['Postpone update handling'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Postpone update handling', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->pending_updates[] = $updates;
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->handle_pending_updates();
|
||||
\danog\MadelineProto\Logger::log(['Parsing updates received via the socket...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Parsing updates received via the socket...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$opts = [];
|
||||
foreach (['date', 'seq', 'seq_start'] as $key) {
|
||||
if (isset($updates[$key])) {
|
||||
@ -451,7 +451,7 @@ trait ResponseHandler
|
||||
$from_id = isset($updates['from_id']) ? $updates['from_id'] : ($updates['out'] ? $this->authorization['user']['id'] : $updates['user_id']);
|
||||
$to_id = isset($updates['chat_id']) ? -$updates['chat_id'] : ($updates['out'] ? $updates['user_id'] : $this->authorization['user']['id']);
|
||||
if (!$this->peer_isset($from_id) || !$this->peer_isset($to_id) || isset($updates['via_bot_id']) && !$this->peer_isset($updates['via_bot_id']) || isset($updates['entities']) && !$this->entities_peer_isset($updates['entities']) || isset($updates['fwd_from']) && !$this->fwd_peer_isset($updates['fwd_from'])) {
|
||||
\danog\MadelineProto\Logger::log(['getDifference: good - getting user for updateShortMessage'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('getDifference: good - getting user for updateShortMessage', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->get_updates_difference();
|
||||
}
|
||||
$message = $updates;
|
||||
|
@ -23,14 +23,14 @@ trait SeqNoHandler
|
||||
$in = $content_related ? 1 : 0;
|
||||
$value = $this->datacenter->sockets[$datacenter]->session_out_seq_no;
|
||||
$this->datacenter->sockets[$datacenter]->session_out_seq_no += $in;
|
||||
//var_dump("OUT $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_out_seq_no);
|
||||
//\danog\MadelineProto\Logger::log("OUT $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_out_seq_no);
|
||||
return $value * 2 + $in;
|
||||
}
|
||||
|
||||
public function check_in_seq_no($datacenter, $current_msg_id)
|
||||
{
|
||||
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no']) && ($seq_no = $this->generate_in_seq_no($datacenter, $this->content_related($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']))) !== $this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no']) {
|
||||
//\danog\MadelineProto\Logger::log(['SECURITY WARNING: Seqno mismatch (should be '.$seq_no.', is '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no'].', '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].')'], \danog\MadelineProto\Logger::ERROR);
|
||||
//\danog\MadelineProto\Logger::log('SECURITY WARNING: Seqno mismatch (should be '.$seq_no.', is '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no'].', '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].')', \danog\MadelineProto\Logger::ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ trait SeqNoHandler
|
||||
$in = $content_related ? 1 : 0;
|
||||
$value = $this->datacenter->sockets[$datacenter]->session_in_seq_no;
|
||||
$this->datacenter->sockets[$datacenter]->session_in_seq_no += $in;
|
||||
//var_dump("IN $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_in_seq_no);
|
||||
//\danog\MadelineProto\Logger::log("IN $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_in_seq_no);
|
||||
return $value * 2 + $in;
|
||||
}
|
||||
|
||||
|
@ -32,18 +32,18 @@ trait UpdateHandler
|
||||
try {
|
||||
$full_chat = $this->get_pwr_chat($update['message']['to_id']);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
if (isset($update['message']['from_id'])) {
|
||||
try {
|
||||
$full_chat = $this->get_pwr_chat($update['message']['from_id']);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -84,7 +84,7 @@ trait UpdateHandler
|
||||
if (($error = $this->recv_message($this->datacenter->curdc)) !== true) {
|
||||
if ($error === -404) {
|
||||
if ($this->datacenter->sockets[$this->datacenter->curdc]->temp_auth_key !== null) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('WARNING: Resetting auth key...', \danog\MadelineProto\Logger::WARNING);
|
||||
$this->datacenter->sockets[$this->datacenter->curdc]->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
|
||||
@ -177,7 +177,7 @@ trait UpdateHandler
|
||||
return;
|
||||
}
|
||||
if ($this->load_channel_state($channel)['sync_loading']) {
|
||||
\danog\MadelineProto\Logger::log(['Not fetching '.$channel.' difference, I am already fetching it']);
|
||||
\danog\MadelineProto\Logger::log('Not fetching '.$channel.' difference, I am already fetching it');
|
||||
|
||||
return;
|
||||
}
|
||||
@ -197,7 +197,7 @@ trait UpdateHandler
|
||||
$this->load_channel_state($channel)['sync_loading'] = false;
|
||||
}
|
||||
$this->load_channel_state($channel)['sync_loading'] = true;
|
||||
\danog\MadelineProto\Logger::log(['Fetching '.$channel.' difference...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Fetching '.$channel.' difference...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
try {
|
||||
$difference = $this->method_call('updates.getChannelDifference', ['channel' => $input, 'filter' => ['_' => 'channelMessagesFilterEmpty'], 'pts' => $this->load_channel_state($channel)['pts'], 'limit' => 30], ['datacenter' => $this->datacenter->curdc]);
|
||||
@ -236,7 +236,7 @@ trait UpdateHandler
|
||||
}
|
||||
break;
|
||||
case 'updates.channelDifferenceTooLong':
|
||||
\danog\MadelineProto\Logger::log(['Got '.$difference['_']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got '.$difference['_'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->load_channel_state($channel)['sync_loading'] = true;
|
||||
|
||||
try {
|
||||
@ -289,12 +289,12 @@ trait UpdateHandler
|
||||
return;
|
||||
}
|
||||
if ($this->updates_state['sync_loading']) {
|
||||
\danog\MadelineProto\Logger::log(['Not fetching normal difference, I am already fetching it']);
|
||||
\danog\MadelineProto\Logger::log('Not fetching normal difference, I am already fetching it');
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->updates_state['sync_loading'] = true;
|
||||
\danog\MadelineProto\Logger::log(['Fetching normal difference...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Fetching normal difference...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
while (!isset($difference)) {
|
||||
try {
|
||||
$difference = $this->method_call('updates.getDifference', ['pts' => $this->load_update_state()['pts'], 'date' => $this->load_update_state()['date'], 'qts' => $this->load_update_state()['qts']], ['datacenter' => $this->datacenter->curdc]);
|
||||
@ -305,7 +305,7 @@ trait UpdateHandler
|
||||
$this->updates_state['sync_loading'] = false;
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Got '.$difference['_']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got '.$difference['_'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
try {
|
||||
switch ($difference['_']) {
|
||||
@ -359,13 +359,13 @@ trait UpdateHandler
|
||||
if (!$this->settings['updates']['handle_updates']) {
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Handling an update of type '.$update['_'].'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Handling an update of type '.$update['_'].'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$channel_id = false;
|
||||
switch ($update['_']) {
|
||||
case 'updateNewChannelMessage':
|
||||
case 'updateEditChannelMessage':
|
||||
if ($update['message']['_'] === 'messageEmpty') {
|
||||
\danog\MadelineProto\Logger::log(['Got message empty, not saving'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got message empty, not saving', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -376,9 +376,9 @@ trait UpdateHandler
|
||||
break;
|
||||
case 'updateChannelTooLong':
|
||||
$channel_id = $update['channel_id'];
|
||||
\danog\MadelineProto\Logger::log(['Got channel too long update, getting difference...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got channel too long update, getting difference...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if (!isset($this->channels_state[$channel_id]) && !isset($update['pts'])) {
|
||||
\danog\MadelineProto\Logger::log(['I do not have the channel in the states and the pts is not set.'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('I do not have the channel in the states and the pts is not set.', \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -391,7 +391,7 @@ trait UpdateHandler
|
||||
}
|
||||
/*
|
||||
if ($cur_state['sync_loading'] && in_array($update['_'], ['updateNewMessage', 'updateEditMessage', 'updateNewChannelMessage', 'updateEditChannelMessage'])) {
|
||||
\danog\MadelineProto\Logger::log(['Sync loading, not handling update'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Sync loading, not handling update', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return false;
|
||||
}*/
|
||||
@ -405,7 +405,7 @@ trait UpdateHandler
|
||||
case 'updateNewChannelMessage':
|
||||
case 'updateEditChannelMessage':
|
||||
if (isset($update['message']['from_id']) && !$this->peer_isset($update['message']['from_id']) || !$this->peer_isset($update['message']['to_id']) || isset($update['message']['via_bot_id']) && !$this->peer_isset($update['message']['via_bot_id']) || isset($update['message']['entities']) && !$this->entities_peer_isset($update['message']['entities']) || isset($update['message']['fwd_from']) && !$this->fwd_peer_isset($update['message']['fwd_from'])) {
|
||||
\danog\MadelineProto\Logger::log(['Not enough data for message update, getting difference...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Not enough data for message update, getting difference...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($channel_id !== false && $this->peer_isset($this->to_supergroup($channel_id))) {
|
||||
$this->get_channel_difference($channel_id);
|
||||
} else {
|
||||
@ -417,7 +417,7 @@ trait UpdateHandler
|
||||
break;
|
||||
default:
|
||||
if ($channel_id !== false && !$this->peer_isset($this->to_supergroup($channel_id))) {
|
||||
\danog\MadelineProto\Logger::log(['Skipping update, I do not have the channel id '.$channel_id], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Skipping update, I do not have the channel id '.$channel_id, \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -425,12 +425,12 @@ trait UpdateHandler
|
||||
}
|
||||
if (isset($update['pts'])) {
|
||||
if ($update['pts'] < $cur_state['pts']) {
|
||||
\danog\MadelineProto\Logger::log(['Duplicate update, channel id: '.$channel_id], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Duplicate update, channel id: '.$channel_id, \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($cur_state['pts'] + (isset($update['pts_count']) ? $update['pts_count'] : 0) !== $update['pts']) {
|
||||
\danog\MadelineProto\Logger::log(['Pts hole. current pts: '.$cur_state['pts'].', pts count: '.(isset($update['pts_count']) ? $update['pts_count'] : 0).', pts: '.$update['pts'].', channel id: '.$channel_id], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Pts hole. current pts: '.$cur_state['pts'].', pts count: '.(isset($update['pts_count']) ? $update['pts_count'] : 0).', pts: '.$update['pts'].', channel id: '.$channel_id, \danog\MadelineProto\Logger::ERROR);
|
||||
if ($channel_id !== false && $this->peer_isset($this->to_supergroup($channel_id))) {
|
||||
$this->get_channel_difference($channel_id);
|
||||
} else {
|
||||
@ -441,12 +441,12 @@ trait UpdateHandler
|
||||
}
|
||||
if (isset($update['message']['id'], $update['message']['to_id'])) {
|
||||
if (!$this->check_msg_id($update['message'])) {
|
||||
\danog\MadelineProto\Logger::log(['Duplicate update by message id, channel id: '.$channel_id], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Duplicate update by message id, channel id: '.$channel_id, \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Applying pts. current pts: '.$cur_state['pts'].', new pts: '.$update['pts'].', channel id: '.$channel_id], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Applying pts. current pts: '.$cur_state['pts'].', new pts: '.$update['pts'].', channel id: '.$channel_id, \danog\MadelineProto\Logger::VERBOSE);
|
||||
$cur_state['pts'] = $update['pts'];
|
||||
if ($channel_id === false && isset($options['date']) && $cur_state['date'] < $options['date']) {
|
||||
$cur_state['date'] = $options['date'];
|
||||
@ -456,7 +456,7 @@ trait UpdateHandler
|
||||
$seq = $options['seq'];
|
||||
$seq_start = isset($options['seq_start']) ? $options['seq_start'] : $options['seq'];
|
||||
if ($seq_start != $cur_state['seq'] + 1 && $seq_start > $cur_state['seq']) {
|
||||
\danog\MadelineProto\Logger::log(['Seq hole. seq_start: '.$seq_start.' != cur seq: '.$cur_state['seq'].' + 1'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Seq hole. seq_start: '.$seq_start.' != cur seq: '.$cur_state['seq'].' + 1', \danog\MadelineProto\Logger::ERROR);
|
||||
$this->get_updates_difference();
|
||||
|
||||
return false;
|
||||
@ -505,14 +505,14 @@ trait UpdateHandler
|
||||
}
|
||||
});
|
||||
if ($update['_'] === 'updateDcOptions') {
|
||||
\danog\MadelineProto\Logger::log(['Got new dc options'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Got new dc options', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->parse_dc_options($update['dc_options']);
|
||||
|
||||
return;
|
||||
}
|
||||
if ($update['_'] === 'updatePhoneCall') {
|
||||
if (!class_exists('\\danog\\MadelineProto\\VoIP')) {
|
||||
\danog\MadelineProto\Logger::log(['The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', \danog\MadelineProto\Logger::WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -551,17 +551,17 @@ trait UpdateHandler
|
||||
$cur_state['qts'] = $update['qts'];
|
||||
}
|
||||
if ($update['qts'] < $cur_state['qts']) {
|
||||
\danog\MadelineProto\Logger::log(['Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($update['qts'] > $cur_state['qts'] + 1) {
|
||||
\danog\MadelineProto\Logger::log(['Qts hole. Fetching updates manually: update qts: '.$update['qts'].' > current qts '.$cur_state['qts'].'+1, chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('Qts hole. Fetching updates manually: update qts: '.$update['qts'].' > current qts '.$cur_state['qts'].'+1, chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);
|
||||
$this->get_updates_difference();
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Applying qts: '.$update['qts'].' over current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Applying qts: '.$update['qts'].' over current qts '.$cur_state['qts'].', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->method_call('messages.receivedQueue', ['max_qts' => $cur_state['qts'] = $update['qts']], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->handle_encrypted_update($update);
|
||||
|
||||
@ -578,11 +578,11 @@ trait UpdateHandler
|
||||
if ($this->settings['secret_chats']['accept_chats'] === false || is_array($this->settings['secret_chats']['accept_chats']) && !in_array($update['chat']['admin_id'], $this->settings['secret_chats']['accept_chats'])) {
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Accepting secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Accepting secret chat '.$update['chat']['id'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->accept_secret_chat($update['chat']);
|
||||
break;
|
||||
case 'encryptedChatDiscarded':
|
||||
\danog\MadelineProto\Logger::log(['Deleting secret chat '.$update['chat']['id'].' because it was revoked by the other user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Deleting secret chat '.$update['chat']['id'].' because it was revoked by the other user', \danog\MadelineProto\Logger::NOTICE);
|
||||
if (isset($this->secret_chats[$update['chat']['id']])) {
|
||||
unset($this->secret_chats[$update['chat']['id']]);
|
||||
}
|
||||
@ -591,11 +591,11 @@ trait UpdateHandler
|
||||
}
|
||||
break;
|
||||
case 'encryptedChat':
|
||||
\danog\MadelineProto\Logger::log(['Completing creation of secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Completing creation of secret chat '.$update['chat']['id'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->complete_secret_chat($update['chat']);
|
||||
break;
|
||||
}
|
||||
//\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::NOTICE);
|
||||
//\danog\MadelineProto\Logger::log($update, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
if (!$this->settings['updates']['handle_updates']) {
|
||||
return;
|
||||
@ -606,7 +606,7 @@ trait UpdateHandler
|
||||
if (isset($update['message']['from_id']) && $update['message']['from_id'] === $this->authorization['user']['id']) {
|
||||
$update['message']['out'] = true;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Saving an update of type '.$update['_'].'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Saving an update of type '.$update['_'].'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if (isset($this->settings['pwr']['strict']) && $this->settings['pwr']['strict'] && isset($this->settings['pwr']['update_handler'])) {
|
||||
$this->pwr_update_handler($update);
|
||||
} else {
|
||||
@ -617,9 +617,9 @@ trait UpdateHandler
|
||||
public function pwr_webhook($update)
|
||||
{
|
||||
$payload = json_encode($update);
|
||||
\danog\MadelineProto\Logger::log([$update, $payload, json_last_error()]);
|
||||
\danog\MadelineProto\Logger::log($update, $payload, json_last_error());
|
||||
if ($payload === '') {
|
||||
\danog\MadelineProto\Logger::log(['EMPTY UPDATE']);
|
||||
\danog\MadelineProto\Logger::log('EMPTY UPDATE');
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -640,11 +640,11 @@ trait UpdateHandler
|
||||
}
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
\danog\MadelineProto\Logger::log(['Result of webhook query is '.$result], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Result of webhook query is '.$result, \danog\MadelineProto\Logger::NOTICE);
|
||||
$result = json_decode($result, true);
|
||||
if (is_array($result) && isset($result['method']) && $result['method'] != '' && is_string($result['method'])) {
|
||||
try {
|
||||
\danog\MadelineProto\Logger::log(['Reverse webhook command returned', $this->method_call($result['method'], $result, ['datacenter' => $this->datacenter->curdc])]);
|
||||
\danog\MadelineProto\Logger::log('Reverse webhook command returned', $this->method_call($result['method'], $result, ['datacenter' => $this->datacenter->curdc]));
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
} catch (\danog\MadelineProto\TL\Exception $e) {
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
|
@ -25,13 +25,13 @@ class RSA
|
||||
public function __magic_construct($rsa_key)
|
||||
{
|
||||
//if ($this->unserialized($rsa_key)) return true;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['rsa_init']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['rsa_init'], Logger::ULTRA_VERBOSE);
|
||||
$key = new \phpseclib\Crypt\RSA();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['loading_key']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['loading_key'], Logger::ULTRA_VERBOSE);
|
||||
$key->load($rsa_key);
|
||||
$this->n = \phpseclib\Common\Functions\Objects::getVar($key, 'modulus');
|
||||
$this->e = \phpseclib\Common\Functions\Objects::getVar($key, 'exponent');
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['computing_fingerprint']], Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['computing_fingerprint'], Logger::ULTRA_VERBOSE);
|
||||
$this->fp = substr(sha1($this->serialize_object(['type' => 'bytes'], $this->n->toBytes(), 'key').$this->serialize_object(['type' => 'bytes'], $this->e->toBytes(), 'key'), true), -8);
|
||||
|
||||
return true;
|
||||
@ -44,7 +44,7 @@ class RSA
|
||||
|
||||
public function encrypt($data)
|
||||
{
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['rsa_encrypting']], Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['rsa_encrypting'], Logger::VERBOSE);
|
||||
|
||||
return (new \phpseclib\Math\BigInteger($data, 256))->powMod($this->e, $this->n)->toBytes();
|
||||
}
|
||||
|
@ -25,20 +25,20 @@ trait AuthKeyHandler
|
||||
|
||||
public function accept_secret_chat($params)
|
||||
{
|
||||
//var_dump($params['id'],$this->secret_chat_status($params['id']));
|
||||
//\danog\MadelineProto\Logger::log($params['id'],$this->secret_chat_status($params['id']));
|
||||
if ($this->secret_chat_status($params['id']) !== 0) {
|
||||
//var_dump($this->secret_chat_status($params['id']));
|
||||
\danog\MadelineProto\Logger::log(["I've already accepted secret chat ".$params['id']]);
|
||||
//\danog\MadelineProto\Logger::log($this->secret_chat_status($params['id']));
|
||||
\danog\MadelineProto\Logger::log("I've already accepted secret chat ".$params['id']);
|
||||
|
||||
return false;
|
||||
}
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating b...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$b = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||
$params['g_a'] = new \phpseclib\Math\BigInteger($params['g_a'], 256);
|
||||
$this->check_G($params['g_a'], $dh_config['p']);
|
||||
$key = ['auth_key' => str_pad($params['g_a']->powMod($b, $dh_config['p'])->toBytes(), 256, chr(0), \STR_PAD_LEFT)];
|
||||
//var_dump($key);
|
||||
//\danog\MadelineProto\Logger::log($key);
|
||||
$key['fingerprint'] = substr(sha1($key['auth_key'], true), -8);
|
||||
$key['visualization_orig'] = substr(sha1($key['auth_key'], true), 16);
|
||||
$key['visualization_46'] = substr(hash('sha256', $key['auth_key'], true), 20);
|
||||
@ -48,7 +48,7 @@ trait AuthKeyHandler
|
||||
$this->method_call('messages.acceptEncryption', ['peer' => $params['id'], 'g_b' => $g_b->toBytes(), 'key_fingerprint' => $key['fingerprint']], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->notify_layer($params['id']);
|
||||
$this->handle_pending_updates();
|
||||
\danog\MadelineProto\Logger::log(['Secret chat '.$params['id'].' accepted successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Secret chat '.$params['id'].' accepted successfully!', \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
||||
public function request_secret_chat($user)
|
||||
@ -58,18 +58,18 @@ trait AuthKeyHandler
|
||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||
}
|
||||
$user = $user['InputUser'];
|
||||
\danog\MadelineProto\Logger::log(['Creating secret chat with '.$user['user_id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Creating secret chat with '.$user['user_id'].'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating a...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$a = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||
\danog\MadelineProto\Logger::log(['Generating g_a...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating g_a...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$g_a = $dh_config['g']->powMod($a, $dh_config['p']);
|
||||
$this->check_G($g_a, $dh_config['p']);
|
||||
$res = $this->method_call('messages.requestEncryption', ['user_id' => $user, 'g_a' => $g_a->toBytes()], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->temp_requested_secret_chats[$res['id']] = $a;
|
||||
$this->handle_pending_updates();
|
||||
$this->get_updates_difference();
|
||||
\danog\MadelineProto\Logger::log(['Secret chat '.$res['id'].' requested successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Secret chat '.$res['id'].' requested successfully!', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $res['id'];
|
||||
}
|
||||
@ -77,8 +77,8 @@ trait AuthKeyHandler
|
||||
public function complete_secret_chat($params)
|
||||
{
|
||||
if ($this->secret_chat_status($params['id']) !== 1) {
|
||||
//var_dump($this->secret_chat_status($params['id']));
|
||||
\danog\MadelineProto\Logger::log(['Could not find and complete secret chat '.$params['id']]);
|
||||
//\danog\MadelineProto\Logger::log($this->secret_chat_status($params['id']));
|
||||
\danog\MadelineProto\Logger::log('Could not find and complete secret chat '.$params['id']);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -88,7 +88,7 @@ trait AuthKeyHandler
|
||||
$key = ['auth_key' => str_pad($params['g_a_or_b']->powMod($this->temp_requested_secret_chats[$params['id']], $dh_config['p'])->toBytes(), 256, chr(0), \STR_PAD_LEFT)];
|
||||
unset($this->temp_requested_secret_chats[$params['id']]);
|
||||
$key['fingerprint'] = substr(sha1($key['auth_key'], true), -8);
|
||||
//var_dump($key);
|
||||
//\danog\MadelineProto\Logger::log($key);
|
||||
if ($key['fingerprint'] !== $params['key_fingerprint']) {
|
||||
$this->discard_secret_chat($params['id']);
|
||||
|
||||
@ -99,7 +99,7 @@ trait AuthKeyHandler
|
||||
$this->secret_chats[$params['id']] = ['key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputEncryptedChat' => ['chat_id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputEncryptedChat'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'in_seq_no' => 0, 'out_seq_no' => 0, 'layer' => 8, 'ttl' => 0, 'ttr' => 100, 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'rekeying' => [0], 'key_x' => 'to server', 'mtproto' => 1];
|
||||
$this->notify_layer($params['id']);
|
||||
$this->handle_pending_updates();
|
||||
\danog\MadelineProto\Logger::log(['Secret chat '.$params['id'].' completed successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Secret chat '.$params['id'].' completed successfully!', \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
||||
public function notify_layer($chat)
|
||||
@ -114,11 +114,11 @@ trait AuthKeyHandler
|
||||
if ($this->secret_chats[$chat]['rekeying'][0] !== 0) {
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Rekeying secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Rekeying secret chat '.$chat.'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating a...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$a = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||
\danog\MadelineProto\Logger::log(['Generating g_a...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating g_a...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$g_a = $dh_config['g']->powMod($a, $dh_config['p']);
|
||||
$this->check_G($g_a, $dh_config['p']);
|
||||
$e = $this->random(8);
|
||||
@ -136,7 +136,7 @@ trait AuthKeyHandler
|
||||
if ($this->secret_chats[$chat]['rekeying'][0] !== 0) {
|
||||
$my_exchange_id = new \phpseclib\Math\BigInteger($this->secret_chats[$chat]['rekeying'][1], -256);
|
||||
$other_exchange_id = new \phpseclib\Math\BigInteger($params['exchange_id'], -256);
|
||||
//var_dump($my, $params);
|
||||
//\danog\MadelineProto\Logger::log($my, $params);
|
||||
if ($my_exchange_id > $other_exchange_id) {
|
||||
return;
|
||||
}
|
||||
@ -146,9 +146,9 @@ trait AuthKeyHandler
|
||||
return;
|
||||
}
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Accepting rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Accepting rekeying of secret chat '.$chat.'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Generating b...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$b = new \phpseclib\Math\BigInteger($this->random(256), 256);
|
||||
$params['g_a'] = new \phpseclib\Math\BigInteger($params['g_a'], 256);
|
||||
$this->check_G($params['g_a'], $dh_config['p']);
|
||||
@ -172,7 +172,7 @@ trait AuthKeyHandler
|
||||
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Committing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Committing rekeying of secret chat '.$chat.'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
$params['g_b'] = new \phpseclib\Math\BigInteger($params['g_b'], 256);
|
||||
$this->check_G($params['g_b'], $dh_config['p']);
|
||||
@ -206,7 +206,7 @@ trait AuthKeyHandler
|
||||
|
||||
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Completing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Completing rekeying of secret chat '.$chat.'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->secret_chats[$chat]['rekeying'] = [0];
|
||||
$this->secret_chats[$chat]['old_key'] = $this->secret_chats[$chat]['key'];
|
||||
$this->secret_chats[$chat]['key'] = $this->temp_rekeyed_secret_chats[$chat];
|
||||
@ -214,7 +214,7 @@ trait AuthKeyHandler
|
||||
$this->secret_chats[$chat]['updated'] = time();
|
||||
unset($this->temp_rekeyed_secret_chats[$params['exchange_id']]);
|
||||
$this->method_call('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionNoop']]], ['datacenter' => $this->datacenter->curdc]);
|
||||
\danog\MadelineProto\Logger::log(['Secret chat '.$chat.' rekeyed successfully!'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('Secret chat '.$chat.' rekeyed successfully!', \danog\MadelineProto\Logger::VERBOSE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -238,8 +238,8 @@ trait AuthKeyHandler
|
||||
|
||||
public function discard_secret_chat($chat)
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Discarding secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
//var_dump(debug_backtrace(0)[0]);
|
||||
\danog\MadelineProto\Logger::log('Discarding secret chat '.$chat.'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log(debug_backtrace(0)[0]);
|
||||
if (isset($this->secret_chats[$chat])) {
|
||||
unset($this->secret_chats[$chat]);
|
||||
}
|
||||
|
@ -80,27 +80,27 @@ trait MessageHandler
|
||||
$message_key = substr($message['message']['bytes'], 8, 16);
|
||||
$encrypted_data = substr($message['message']['bytes'], 24);
|
||||
if ($this->secret_chats[$message['message']['chat_id']]['mtproto'] === 2) {
|
||||
\danog\MadelineProto\Logger::log(['Trying MTProto v2 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Trying MTProto v2 decryption for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
try {
|
||||
$message_data = $this->try_mtproto_v2_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v2 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v2 decryption OK for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
} catch (\danog\MadelineProto\SecurityException $e) {
|
||||
\danog\MadelineProto\Logger::log(['MTProto v2 decryption failed with message '.$e->getMessage().', trying MTProto v1 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v2 decryption failed with message '.$e->getMessage().', trying MTProto v1 decryption for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$message_data = $this->try_mtproto_v1_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v1 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v1 decryption OK for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->secret_chats[$message['message']['chat_id']]['mtproto'] = 1;
|
||||
}
|
||||
} else {
|
||||
\danog\MadelineProto\Logger::log(['Trying MTProto v1 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Trying MTProto v1 decryption for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
try {
|
||||
$message_data = $this->try_mtproto_v1_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v1 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v1 decryption OK for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
} catch (\danog\MadelineProto\SecurityException $e) {
|
||||
\danog\MadelineProto\Logger::log(['MTProto v1 decryption failed with message '.$e->getMessage().', trying MTProto v2 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v1 decryption failed with message '.$e->getMessage().', trying MTProto v2 decryption for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$message_data = $this->try_mtproto_v2_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v2 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('MTProto v2 decryption OK for chat '.$message['message']['chat_id'].'...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->secret_chats[$message['message']['chat_id']]['mtproto'] = 2;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ trait ResponseHandler
|
||||
$update['message']['decrypted_message']['action']['end_seq_no'] -= $this->secret_chats[$update['message']['chat_id']]['out_seq_no_x'];
|
||||
$update['message']['decrypted_message']['action']['start_seq_no'] /= 2;
|
||||
$update['message']['decrypted_message']['action']['end_seq_no'] /= 2;
|
||||
\danog\MadelineProto\Logger::log(['Resending messages for secret chat '.$update['message']['chat_id']], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('Resending messages for secret chat '.$update['message']['chat_id'], \danog\MadelineProto\Logger::WARNING);
|
||||
foreach ($this->secret_chats[$update['message']['chat_id']]['outgoing'] as $seq => $message) {
|
||||
if ($seq >= $update['message']['decrypted_message']['action']['start_seq_no'] && $seq <= $update['message']['decrypted_message']['action']['end_seq_no']) {
|
||||
//throw new \danog\MadelineProto\ResponseException(\danog\MadelineProto\Lang::$current_lang['resending_unsupported']);
|
||||
|
@ -56,10 +56,10 @@ trait SeqNoHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($C, $seqno);
|
||||
//\danog\MadelineProto\Logger::log($C, $seqno);
|
||||
if ($seqno < $C) {
|
||||
// <= C
|
||||
\danog\MadelineProto\Logger::log(['WARNING: dropping repeated message with seqno '.$seqno]);
|
||||
\danog\MadelineProto\Logger::log('WARNING: dropping repeated message with seqno '.$seqno);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class Serialization
|
||||
clearstatcache();
|
||||
}
|
||||
$realpaths['lockfile'] = fopen($realpaths['lockfile'], 'w');
|
||||
\danog\MadelineProto\Logger::log(['Waiting for exclusive lock of serialization lockfile...']);
|
||||
\danog\MadelineProto\Logger::log('Waiting for exclusive lock of serialization lockfile...');
|
||||
flock($realpaths['lockfile'], LOCK_EX);
|
||||
|
||||
try {
|
||||
@ -93,7 +93,7 @@ class Serialization
|
||||
clearstatcache();
|
||||
}
|
||||
$realpaths['lockfile'] = fopen($realpaths['lockfile'], 'r');
|
||||
\danog\MadelineProto\Logger::log(['Waiting for shared lock of serialization lockfile...']);
|
||||
\danog\MadelineProto\Logger::log('Waiting for shared lock of serialization lockfile...');
|
||||
flock($realpaths['lockfile'], LOCK_SH);
|
||||
|
||||
try {
|
||||
@ -114,7 +114,7 @@ class Serialization
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
Logger::log((string) $e, Logger::ERROR);
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\\Math\\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $unserialized);
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ trait TL
|
||||
|
||||
public function construct_tl($files)
|
||||
{
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['TL_loading']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['TL_loading'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->constructors = new TLConstructor();
|
||||
$this->methods = new TLMethod();
|
||||
$this->td_constructors = new TLConstructor();
|
||||
$this->td_methods = new TLMethod();
|
||||
$this->td_descriptions = ['types' => [], 'constructors' => [], 'methods' => []];
|
||||
foreach ($files as $scheme_type => $file) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['file_parsing'], basename($file))], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['file_parsing'], basename($file)), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$filec = file_get_contents($file);
|
||||
$TL_dict = json_decode($filec, true);
|
||||
if ($TL_dict === null) {
|
||||
@ -104,7 +104,7 @@ trait TL
|
||||
if (preg_match('/^[^\\s]+#/', $line)) {
|
||||
$nid = str_pad(preg_replace(['/^[^#]+#/', '/\\s.+/'], '', $line), 8, '0', \STR_PAD_LEFT);
|
||||
if ($id !== $nid && $scheme_type !== 'botAPI') {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['crc32_mismatch'], $id, $nid, $line)], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['crc32_mismatch'], $id, $nid, $line), \danog\MadelineProto\Logger::ERROR);
|
||||
}
|
||||
$id = $nid;
|
||||
}
|
||||
@ -144,14 +144,14 @@ trait TL
|
||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['src_file_invalid'].$file);
|
||||
}
|
||||
$orig = $this->encrypted_layer;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['translating_obj']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['translating_obj'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
foreach ($TL_dict['constructors'] as $elem) {
|
||||
if ($scheme_type === 'secret') {
|
||||
$this->encrypted_layer = max($this->encrypted_layer, $elem['layer']);
|
||||
}
|
||||
$this->{($scheme_type === 'td' ? 'td_' : '').'constructors'}->add($elem, $scheme_type);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['translating_methods']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['translating_methods'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
foreach ($TL_dict['methods'] as $elem) {
|
||||
$this->{($scheme_type === 'td' ? 'td_' : '').'methods'}->add($elem);
|
||||
if ($scheme_type === 'secret') {
|
||||
@ -350,7 +350,7 @@ trait TL
|
||||
$predicate = $object['_'];
|
||||
$constructorData = $this->constructors->find_by_predicate($predicate, $layer);
|
||||
if ($constructorData === false) {
|
||||
\danog\MadelineProto\Logger::log([$object], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log($object, \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
|
||||
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['type_extract_error'], $predicate));
|
||||
}
|
||||
@ -410,7 +410,7 @@ trait TL
|
||||
foreach ($tl['params'] as $current_argument) {
|
||||
if (!isset($arguments[$current_argument['name']])) {
|
||||
if (isset($current_argument['pow']) && (in_array($current_argument['type'], ['true', 'false']) || ($flags & $current_argument['pow']) === 0)) {
|
||||
//\danog\MadelineProto\Logger::log(['Skipping '.$current_argument['name'].' of type '.$current_argument['type']);
|
||||
//\danog\MadelineProto\Logger::log('Skipping '.$current_argument['name'].' of type '.$current_argument['type');
|
||||
continue;
|
||||
}
|
||||
if ($current_argument['name'] === 'random_bytes') {
|
||||
@ -454,7 +454,7 @@ trait TL
|
||||
if ($current_argument['type'] === 'DataJSON') {
|
||||
$arguments[$current_argument['name']] = ['_' => 'dataJSON', 'data' => json_encode($arguments[$current_argument['name']])];
|
||||
}
|
||||
//\danog\MadelineProto\Logger::log(['Serializing '.$current_argument['name'].' of type '.$current_argument['type']);
|
||||
//\danog\MadelineProto\Logger::log('Serializing '.$current_argument['name'].' of type '.$current_argument['type');
|
||||
$serialized .= $this->serialize_object($current_argument, $arguments[$current_argument['name']], $current_argument['name'], $layer);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class SocketHandler extends \Threaded implements \Collectable
|
||||
if ($this->error !== true) {
|
||||
if ($this->error === -404) {
|
||||
if ($this->API->datacenter->sockets[$this->current]->temp_auth_key !== null) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['resetting_auth_key']], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['resetting_auth_key'], \danog\MadelineProto\Logger::WARNING);
|
||||
$this->API->datacenter->sockets[$this->current]->temp_auth_key = null;
|
||||
$this->API->init_authorization();
|
||||
|
||||
|
@ -33,7 +33,7 @@ class SocketReader extends \Threaded implements \Collectable
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['shutting_down_reader_pool'].$this->current], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['shutting_down_reader_pool'].$this->current, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,18 +47,18 @@ class SocketReader extends \Threaded implements \Collectable
|
||||
while ($this->API->run_workers) {
|
||||
try {
|
||||
$this->API->datacenter->sockets[$this->current]->reading = true;
|
||||
//var_dump('RECEIVING');
|
||||
//\danog\MadelineProto\Logger::log('RECEIVING');
|
||||
$error = $this->API->recv_message($this->current);
|
||||
var_dump('NOW HANDLE');
|
||||
\danog\MadelineProto\Logger::log('NOW HANDLE');
|
||||
$handler_pool->submit(new SocketHandler($this->API, $this->current, $error));
|
||||
var_dump('SUBMITTED');
|
||||
\danog\MadelineProto\Logger::log('SUBMITTED');
|
||||
$this->API->datacenter->sockets[$this->current]->reading = false;
|
||||
} catch (\danog\MadelineProto\NothingInTheSocketException $e) {
|
||||
//\danog\MadelineProto\Logger::log(['Nothing in the socket for dc '.$this->current], \danog\MadelineProto\Logger::VERBOSE);
|
||||
//\danog\MadelineProto\Logger::log('Nothing in the socket for dc '.$this->current, \danog\MadelineProto\Logger::VERBOSE);
|
||||
}
|
||||
}
|
||||
while ($number = $handler_pool->collect()) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['shutting_down_handler_pool'], $this->current, $number)], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['shutting_down_handler_pool'], $this->current, $number), \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
$this->setGarbage();
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ trait AuthKeyHandler
|
||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
|
||||
}
|
||||
$user = $user['InputUser'];
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['calling_user'], $user['user_id'])], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['calling_user'], $user['user_id']), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_a']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['generating_a'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$a = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_g_a']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['generating_g_a'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$g_a = $dh_config['g']->powMod($a, $dh_config['p']);
|
||||
$this->check_G($g_a, $dh_config['p']);
|
||||
$res = $this->method_call('phone.requestCall', ['user_id' => $user, 'g_a_hash' => hash('sha256', $g_a->toBytes(), true), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_p2p' => true, 'udp_reflector' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
||||
@ -65,13 +65,13 @@ trait AuthKeyHandler
|
||||
}
|
||||
});
|
||||
if ($this->call_status($call['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_1'], $call['id'])]);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_1'], $call['id']));
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['accepting_call'], $this->calls[$call['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['accepting_call'], $this->calls[$call['id']]->getOtherID()), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_b']], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['generating_b'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
$b = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
|
||||
$g_b = $dh_config['g']->powMod($b, $dh_config['p']);
|
||||
$this->check_G($g_b, $dh_config['p']);
|
||||
@ -80,12 +80,12 @@ trait AuthKeyHandler
|
||||
$res = $this->method_call('phone.acceptCall', ['peer' => $call, 'g_b' => $g_b->toBytes(), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_reflector' => true, 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc === 'CALL_ALREADY_ACCEPTED') {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_already_accepted'], $call['id'])]);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_already_accepted'], $call['id']));
|
||||
|
||||
return true;
|
||||
}
|
||||
if ($e->rpc === 'CALL_ALREADY_DECLINED') {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['call_already_declined']]);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['call_already_declined']);
|
||||
$this->discard_call($call['id'], 'phoneCallDiscardReasonHangup');
|
||||
|
||||
return false;
|
||||
@ -111,11 +111,11 @@ trait AuthKeyHandler
|
||||
}
|
||||
});
|
||||
if ($this->call_status($params['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_REQUESTED) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_2'], $params['id'])]);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_2'], $params['id']));
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_confirming'], $this->calls[$params['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_confirming'], $this->calls[$params['id']]->getOtherID()), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
$params['g_b'] = new \phpseclib\Math\BigInteger($params['g_b'], 256);
|
||||
$this->check_G($params['g_b'], $dh_config['p']);
|
||||
@ -149,11 +149,11 @@ trait AuthKeyHandler
|
||||
}
|
||||
});
|
||||
if ($this->call_status($params['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED || !isset($this->calls[$params['id']]->storage['b'])) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_3'], $params['id'])]);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_3'], $params['id']));
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_completing'], $this->calls[$params['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_completing'], $this->calls[$params['id']]->getOtherID()), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$dh_config = $this->get_dh_config();
|
||||
if (hash('sha256', $params['g_a_or_b'], true) != $this->calls[$params['id']]->storage['g_a_hash']) {
|
||||
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['invalid_g_a']);
|
||||
@ -218,7 +218,7 @@ trait AuthKeyHandler
|
||||
if (!isset($this->calls[$call['id']])) {
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_discarding'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_discarding'], $call['id']), \danog\MadelineProto\Logger::VERBOSE);
|
||||
|
||||
try {
|
||||
$res = $this->method_call('phone.discardCall', ['peer' => $call, 'duration' => time() - $this->calls[$call['id']]->whenCreated(), 'connection_id' => $this->calls[$call['id']]->getPreferredRelayID(), 'reason' => $reason], ['datacenter' => $this->datacenter->curdc]);
|
||||
@ -228,12 +228,12 @@ trait AuthKeyHandler
|
||||
}
|
||||
}
|
||||
if (!empty($rating)) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_set_rating'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_set_rating'], $call['id']), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->method_call('phone.setCallRating', ['peer' => $call, 'rating' => $rating['rating'], 'comment' => $rating['comment']], ['datacenter' => $this->datacenter->curdc]);
|
||||
}
|
||||
if ($need_debug) {
|
||||
//} && isset($this->calls[$call['id']]->storage['not_modified'])) {
|
||||
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_debug_saving'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['call_debug_saving'], $call['id']), \danog\MadelineProto\Logger::VERBOSE);
|
||||
$this->method_call('phone.saveCallDebug', ['peer' => $call, 'debug' => $this->calls[$call['id']]->getDebugLog()], ['datacenter' => $this->datacenter->curdc]);
|
||||
}
|
||||
$update = ['_' => 'updatePhoneCall', 'phone_call' => $this->calls[$call['id']]];
|
||||
|
@ -28,7 +28,7 @@ trait DialogHandler
|
||||
|
||||
try {
|
||||
while ($this->dialog_params['count'] < $res['count']) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['getting_dialogs']]);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['getting_dialogs']);
|
||||
$res = $this->method_call('messages.getDialogs', $this->dialog_params, ['datacenter' => $datacenter, 'FloodWaitLimit' => 100]);
|
||||
foreach ($res['dialogs'] as $dialog) {
|
||||
if (!in_array($dialog['peer'], $peers)) {
|
||||
|
@ -34,7 +34,7 @@ trait Login
|
||||
if (!$this->method_call('auth.logOut', [], ['datacenter' => $this->datacenter->curdc])) {
|
||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['logout_error']);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['logout_ok']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['logout_ok'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -42,10 +42,10 @@ trait Login
|
||||
public function bot_login($token)
|
||||
{
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['already_logged_in'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_bot']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_bot'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorization = $this->method_call('auth.importBotAuthorization', ['bot_auth_token' => $token, 'api_id' => $this->settings['app_info']['api_id'], 'api_hash' => $this->settings['app_info']['api_hash']], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->authorized = self::LOGGED_IN;
|
||||
$this->authorized_dc = $this->datacenter->curdc;
|
||||
@ -56,7 +56,7 @@ trait Login
|
||||
@file_get_contents('https://api.pwrtelegram.xyz/bot'.$token.'/getme');
|
||||
}
|
||||
$this->init_authorization();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_ok'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->authorization;
|
||||
}
|
||||
@ -64,10 +64,10 @@ trait Login
|
||||
public function phone_login($number, $sms_type = 5)
|
||||
{
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['already_logged_in'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_code_sending']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_code_sending'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorization = $this->method_call('auth.sendCode', ['phone_number' => $number, 'sms_type' => $sms_type, 'api_id' => $this->settings['app_info']['api_id'], 'api_hash' => $this->settings['app_info']['api_hash'], 'lang_code' => $this->settings['app_info']['lang_code']], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->authorized_dc = $this->datacenter->curdc;
|
||||
$this->authorization['phone_number'] = $number;
|
||||
@ -75,7 +75,7 @@ trait Login
|
||||
$this->authorized = self::WAITING_CODE;
|
||||
$this->updates = [];
|
||||
$this->updates_key = 0;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_code_sent']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_code_sent'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->authorization;
|
||||
}
|
||||
@ -86,20 +86,20 @@ trait Login
|
||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['login_code_uncalled']);
|
||||
}
|
||||
$this->authorized = self::NOT_LOGGED_IN;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_user']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
try {
|
||||
$authorization = $this->method_call('auth.signIn', ['phone_number' => $this->authorization['phone_number'], 'phone_code_hash' => $this->authorization['phone_code_hash'], 'phone_code' => $code], ['datacenter' => $this->datacenter->curdc]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc === 'SESSION_PASSWORD_NEEDED') {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_2fa_enabled']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_2fa_enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorized = self::WAITING_PASSWORD;
|
||||
$this->authorization = $this->method_call('account.getPassword', [], ['datacenter' => $this->datacenter->curdc]);
|
||||
//$this->authorization['_'] .= 'MP';
|
||||
return $this->authorization;
|
||||
}
|
||||
if ($e->rpc === 'PHONE_NUMBER_UNOCCUPIED') {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_need_signup']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_need_signup'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorized = self::WAITING_SIGNUP;
|
||||
$this->authorization['phone_code'] = $code;
|
||||
|
||||
@ -112,7 +112,7 @@ trait Login
|
||||
$this->authorization = $authorization;
|
||||
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
|
||||
$this->init_authorization();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_ok'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->authorization;
|
||||
}
|
||||
@ -120,10 +120,10 @@ trait Login
|
||||
public function import_authorization($authorization)
|
||||
{
|
||||
if ($this->authorized === self::LOGGED_IN) {
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['already_logged_in'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_auth_key']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_auth_key'], \danog\MadelineProto\Logger::NOTICE);
|
||||
list($dc_id, $auth_key) = $authorization;
|
||||
if (!is_array($auth_key)) {
|
||||
$auth_key = ['auth_key' => $auth_key, 'id' => substr(sha1($auth_key, true), -8), 'server_salt' => ''];
|
||||
@ -162,12 +162,12 @@ trait Login
|
||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['signup_uncalled']);
|
||||
}
|
||||
$this->authorized = self::NOT_LOGGED_IN;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['signing_up']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['signing_up'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorization = $this->method_call('auth.signUp', ['phone_number' => $this->authorization['phone_number'], 'phone_code_hash' => $this->authorization['phone_code_hash'], 'phone_code' => $this->authorization['phone_code'], 'first_name' => $first_name, 'last_name' => $last_name], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->authorized = self::LOGGED_IN;
|
||||
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
|
||||
$this->init_authorization();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['signup_ok']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['signup_ok'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->authorization;
|
||||
}
|
||||
@ -178,12 +178,12 @@ trait Login
|
||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['2fa_uncalled']);
|
||||
}
|
||||
$this->authorized = self::NOT_LOGGED_IN;
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_user']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->authorization = $this->method_call('auth.checkPassword', ['password_hash' => hash('sha256', $this->authorization['current_salt'].$password.$this->authorization['current_salt'], true)], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->authorized = self::LOGGED_IN;
|
||||
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
|
||||
$this->init_authorization();
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(\danog\MadelineProto\Lang::$current_lang['login_ok'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->authorization;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ $MadelineProto = false;
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('testing.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
if (file_exists('.env')) {
|
||||
echo 'Loading .env...'.PHP_EOL;
|
||||
@ -51,31 +51,31 @@ if (getenv('TEST_SECRET_CHAT') == '') {
|
||||
die('TEST_SECRET_CHAT is not defined in .env, please define it.'.PHP_EOL);
|
||||
}
|
||||
echo 'Loading settings...'.PHP_EOL;
|
||||
var_dump(getenv('MTPROTO_SETTINGS'));
|
||||
\danog\MadelineProto\Logger::log(getenv('MTPROTO_SETTINGS'));
|
||||
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
|
||||
//$settings['connection_settings']['all']['proxy'] = '\SocksProxy';
|
||||
//$settings['connection_settings']['all']['proxy_extra'] = ['address' => '127.0.0.1', 'port' => 1080];
|
||||
|
||||
var_dump($settings);
|
||||
\danog\MadelineProto\Logger::log($settings);
|
||||
if ($MadelineProto === false) {
|
||||
echo 'Loading MadelineProto...'.PHP_EOL;
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
if (getenv('TRAVIS_COMMIT') == '') {
|
||||
$sentCode = $MadelineProto->phone_login(readline('Enter your phone number: '));
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
if ($authorization['_'] === 'account.needSignup') {
|
||||
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('Registering new user', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $MadelineProto->complete_signup(readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
|
||||
}
|
||||
} else {
|
||||
@ -83,12 +83,12 @@ if ($MadelineProto === false) {
|
||||
}
|
||||
}
|
||||
$MadelineProto->session = 'testing.madeline';
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::WARNING);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ERROR);
|
||||
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
//$MadelineProto->phone->createGroupCall(['channel' => -1001333587884
|
||||
|
||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||
@ -104,7 +104,7 @@ if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
//$MadelineProto->messages->sendMessage(['peer' => $controller->getOtherID(), 'message' => 'Emojis: '.implode('', $controller->getVisualization())]);
|
||||
var_dump($controller->configuration);
|
||||
\danog\MadelineProto\Logger::log($controller->configuration);
|
||||
while ($controller->getCallState() < \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
@ -115,7 +115,7 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !==
|
||||
while ($howmany > 0) {
|
||||
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
foreach ($updates as $update) {
|
||||
\danog\MadelineProto\Logger::log([$update]);
|
||||
\danog\MadelineProto\Logger::log($update);
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updatePhoneCall':
|
||||
@ -138,16 +138,16 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y')
|
||||
|
||||
$InputEncryptedChat = $MadelineProto->get_secret_chat($secret)['InputEncryptedChat'];
|
||||
$sentMessage = $MadelineProto->messages->sendEncrypted(['peer' => $InputEncryptedChat, 'message' => ['_' => 'decryptedMessage', 'media' => ['_' => 'decryptedMessageMediaEmpty'], 'ttl' => 10, 'message' => $message, 'entities' => [['_' => 'messageEntityCode', 'offset' => 0, 'length' => mb_strlen($message)]]]]); // should work with all layers
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
/*
|
||||
while (true) {
|
||||
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
|
||||
//\danog\MadelineProto\Logger::log([$updates]);
|
||||
//\danog\MadelineProto\Logger::log($updates);
|
||||
foreach ($updates as $update) {
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updateNewEncryptedMessage':
|
||||
var_dump($update);
|
||||
\danog\MadelineProto\Logger::log($update);
|
||||
}
|
||||
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('testing.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
}
|
||||
@ -173,7 +173,7 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y')
|
||||
// Document, secrey chat
|
||||
$time = time();
|
||||
$inputEncryptedFile = $MadelineProto->upload_encrypted('tests/60', 'magic'); // This gets an inputFile object with file name magic
|
||||
var_dump(time() - $time);
|
||||
\danog\MadelineProto\Logger::log(time() - $time);
|
||||
$secret_media['document'] = ['peer' => $secret, 'file' => $inputEncryptedFile, 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => '', 'media' => ['_' => 'decryptedMessageMediaDocument', 'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb_w' => 90, 'thumb_h' => 90, 'mime_type' => 'magic/magic', 'caption' => 'test', 'key' => $inputEncryptedFile['key'], 'iv' => $inputEncryptedFile['iv'], 'file_name' => 'magic.magic', 'size' => filesize('tests/60'), 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'fairy']]]]];
|
||||
|
||||
// Video, secret chat
|
||||
@ -197,7 +197,7 @@ $media = [];
|
||||
|
||||
// Sticker
|
||||
$inputFile = $MadelineProto->upload('tests/lel.webp');
|
||||
var_dump($inputFile);
|
||||
\danog\MadelineProto\Logger::log($inputFile);
|
||||
$media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]];
|
||||
|
||||
// Video
|
||||
@ -214,7 +214,7 @@ $media['voice'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'm
|
||||
// Document
|
||||
$time = time();
|
||||
$inputFile = $MadelineProto->upload('tests/60', 'magic'); // This gets an inputFile object with file name magic
|
||||
var_dump(time() - $time);
|
||||
\danog\MadelineProto\Logger::log(time() - $time);
|
||||
$media['document'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => 'magic/magic', 'caption' => 'This file was uploaded using MadelineProto', 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'magic.magic']]];
|
||||
|
||||
$message = 'yay';
|
||||
@ -223,7 +223,7 @@ $mention = $mention['user_id']; // Selects only the numeric user id
|
||||
|
||||
foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
$sentMessage = $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => $message, 'entities' => [['_' => 'inputMessageEntityMentionName', 'offset' => 0, 'length' => mb_strlen($message), 'user_id' => $mention]]]);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
foreach ($media as $type => $inputMedia) {
|
||||
$type = $MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia, 'message' => '['.$message.'](mention:'.$mention.')', 'parse_mode' => 'markdown']);
|
||||
@ -232,5 +232,5 @@ foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
|
||||
foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
$sentMessage = $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => $message, 'entities' => [['_' => 'inputMessageEntityMentionName', 'offset' => 0, 'length' => mb_strlen($message), 'user_id' => $mention]]]);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ try {
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login(readline('Enter a bot token: '));
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
||||
if (file_exists('token.php') && $MadelineProto === false) {
|
||||
include_once 'token.php';
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login($MadelineProto_token);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
$offset = 0;
|
||||
$reply_markup = ['inline_keyboard' => [
|
||||
|
@ -19,34 +19,34 @@ $uMadelineProto = false;
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('pipesbot.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$uMadelineProto = new \danog\MadelineProto\API('pwr.madeline');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
if (file_exists('token.php') && $MadelineProto === false) {
|
||||
include_once 'token.php';
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login($pipes_token);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
if ($uMadelineProto === false) {
|
||||
echo 'Loading MadelineProto...'.PHP_EOL;
|
||||
$uMadelineProto = new \danog\MadelineProto\API(array_merge($settings, ['updates' => ['handle_updates' => false]]));
|
||||
$sentCode = $uMadelineProto->phone_login(readline());
|
||||
\danog\MadelineProto\Logger::log([$sentCode], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($sentCode, \danog\MadelineProto\Logger::NOTICE);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $uMadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
if ($authorization['_'] === 'account.noPassword') {
|
||||
throw new \danog\MadelineProto\Exception('2FA is enabled but no password is set!');
|
||||
}
|
||||
if ($authorization['_'] === 'account.password') {
|
||||
\danog\MadelineProto\Logger::log(['2FA is enabled'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log('2FA is enabled', \danog\MadelineProto\Logger::NOTICE);
|
||||
$authorization = $uMadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL;
|
||||
@ -199,36 +199,36 @@ while (true) {
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['user_id'], 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$toset['switch_pm'] = $sswitch;
|
||||
$MadelineProto->messages->setInlineBotResults($toset);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
try {
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['user_id'], 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$toset['switch_pm'] = $sswitch;
|
||||
$MadelineProto->messages->setInlineBotResults($toset);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
\danog\MadelineProto\Logger::log($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ try {
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login($pwrtelegram_debug_token);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log($authorization, \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
function base64url_decode($data)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user