Apply fixes from StyleCI
This commit is contained in:
parent
632ca413d3
commit
0824470b71
2
bot.php
2
bot.php
@ -10,7 +10,7 @@ if (file_exists('token.php') && $MadelineProto === false) {
|
||||
include_once 'token.php';
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login($token);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
$offset = 0;
|
||||
while (true) {
|
||||
|
@ -14,7 +14,7 @@ require 'vendor/autoload.php';
|
||||
$param = 1;
|
||||
\danog\MadelineProto\Logger::constructor($param);
|
||||
|
||||
\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
|
||||
|
@ -92,6 +92,7 @@ class APIFactory
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$this->API->get_config();
|
||||
|
||||
return $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && is_array($arguments[0])) ? $arguments[0] : []);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,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();
|
||||
}
|
||||
@ -38,7 +38,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());
|
||||
@ -71,7 +71,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->method as $key => $rmethod) {
|
||||
if (!strpos($rmethod, '.')) {
|
||||
|
@ -31,7 +31,7 @@ class DocsBuilder
|
||||
{
|
||||
$types = [];
|
||||
|
||||
\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'].'
|
||||
@ -61,7 +61,7 @@ description: '.$this->settings['description'].'
|
||||
|
||||
$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->method as $key => $rmethod) {
|
||||
$method = str_replace('.', '_', $rmethod);
|
||||
@ -169,7 +169,7 @@ $'.$type.' = $MadelineProto->'.str_replace('_', '->', $method).'(['.$params.']);
|
||||
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($methods);
|
||||
$last_namespace = '';
|
||||
@ -203,7 +203,7 @@ description: List of methods
|
||||
mkdir('constructors');
|
||||
|
||||
$constructors = [];
|
||||
\danog\MadelineProto\Logger::log(['Generating constructors documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Generating constructors documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
foreach ($this->constructors->predicate as $key => $rconstructor) {
|
||||
if (preg_match('/%/', $type)) {
|
||||
@ -336,7 +336,7 @@ $".$constructor." = 'channel#38575794'; // tg-cli style id (channels)
|
||||
file_put_contents('constructors/'.$constructor.'.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($constructors);
|
||||
$last_namespace = '';
|
||||
@ -370,7 +370,7 @@ description: List of constructors
|
||||
ksort($types);
|
||||
$index = '';
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Generating types documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Generating types documentation...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
foreach ($types as $type => $keys) {
|
||||
$new_namespace = preg_replace('/_.*/', '', $method);
|
||||
@ -423,7 +423,7 @@ description: constructors and methods of type '.$type.'
|
||||
$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
|
||||
@ -435,7 +435,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
|
||||
@ -562,6 +562,6 @@ description: Represents a boolean.
|
||||
|
||||
Represents a boolean.');
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Done!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Done!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Exception extends \Exception
|
||||
if (error_reporting() === 0) {
|
||||
return true; // return true to continue through the others error handlers
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$errstr], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
\danog\MadelineProto\Logger::log([$errstr], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
$e = new \danog\MadelineProto\Exception($errstr, $errno);
|
||||
$e->file = $errfile;
|
||||
$e->line = $errline;
|
||||
|
@ -21,7 +21,7 @@ trait AckHandler
|
||||
{
|
||||
// The server acknowledges that it received my message
|
||||
if (!isset($this->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;
|
||||
}
|
||||
@ -33,7 +33,7 @@ trait AckHandler
|
||||
{
|
||||
// I let the server know that I received its message
|
||||
if (!isset($this->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->temp_auth_key['id'] === null || $this->datacenter->temp_auth_key['id'] === str_repeat(chr(0), 8) || (isset($this->datacenter->incoming_messages[$message_id]['ack']) && $this->datacenter->incoming_messages[$message_id]['ack'])) {
|
||||
|
@ -94,7 +94,7 @@ trait CallHandler
|
||||
if ($this->settings['pwr']['pwr']) {
|
||||
$seconds = preg_replace('/[^0-9]+/', '', $server_answer['error_message']);
|
||||
if (is_numeric($seconds) && $seconds < $this->settings['flood_timeout']['wait_if_lt']) {
|
||||
\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...');
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ trait MessageHandler
|
||||
$error = \danog\PHP\Struct::unpack('<i', stream_get_contents($payload, 4))[0];
|
||||
if ($error === -404) {
|
||||
if ($this->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->temp_auth_key = null;
|
||||
$this->init_authorization();
|
||||
$this->config = $this->write_client_info('help.getConfig');
|
||||
@ -81,7 +81,7 @@ trait MessageHandler
|
||||
|
||||
$server_salt = \danog\PHP\Struct::unpack('<q', substr($decrypted_data, 0, 8))[0];
|
||||
if ($server_salt != $this->datacenter->temp_auth_key['server_salt']) {
|
||||
\danog\MadelineProto\Logger::log(['WARNING: Server salt mismatch (my server salt '.$this->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->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);
|
||||
|
@ -201,7 +201,9 @@ trait PeerHandler
|
||||
}
|
||||
}
|
||||
$dbres = file_get_contents('https://id.pwrtelegram.xyz/db/getusername?id='.$id);
|
||||
if ($dbres['ok']) return $this->gen_all('@'.$dbres['username']);
|
||||
if ($dbres['ok']) {
|
||||
return $this->gen_all('@'.$dbres['username']);
|
||||
}
|
||||
throw new \danog\MadelineProto\Exception("Couldn't find peer by provided chat id ".$id);
|
||||
}
|
||||
$id = str_replace('@', '', $id);
|
||||
|
@ -80,7 +80,8 @@ trait TL
|
||||
}
|
||||
}
|
||||
|
||||
public function get_method_namespaces() {
|
||||
public function get_method_namespaces()
|
||||
{
|
||||
return $this->methods->method_namespace;
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ trait FilesHandler
|
||||
}
|
||||
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;
|
||||
@ -539,7 +539,7 @@ trait FilesHandler
|
||||
{
|
||||
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);
|
||||
};
|
||||
}
|
||||
$info = $this->get_download_info($message_media);
|
||||
@ -554,7 +554,7 @@ trait FilesHandler
|
||||
$percent = 0;
|
||||
while ($percent < 100) {
|
||||
$real_part_size = ($offset + $part_size > $end) ? $part_size - (($offset + $part_size) - $end) : $part_size;
|
||||
\danog\MadelineProto\Logger::log([$real_part_size, $offset], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log([$real_part_size, $offset], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$res = $this->API->method_call('upload.getFile', ['location' => $info['InputFileLocation'], 'offset' => $offset, 'limit' => $real_part_size], null, true);
|
||||
$dc = 1;
|
||||
while ($res['type']['_'] === 'storage.fileUnknown' && $res['bytes'] === '') {
|
||||
@ -563,8 +563,8 @@ trait FilesHandler
|
||||
$dc++;
|
||||
}
|
||||
|
||||
\danog\MadelineProto\Logger::log([fwrite($stream, $res['bytes'])], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log([$offset, $size, ftell($stream)], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log([fwrite($stream, $res['bytes'])], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
\danog\MadelineProto\Logger::log([$offset, $size, ftell($stream)], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
$cb($percent = ($offset += $real_part_size) * 100 / $size);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ trait Login
|
||||
$this->API->datacenter->authorized = false;
|
||||
$this->API->datacenter->authorization = null;
|
||||
$this->API->updates = [];
|
||||
\danog\MadelineProto\Logger::log(['Logged out successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logged out successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
$this->API->should_serialize = true;
|
||||
|
||||
@ -35,10 +35,10 @@ trait Login
|
||||
public function bot_login($token)
|
||||
{
|
||||
if ($this->API->datacenter->authorized) {
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a bot...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a bot...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->API->datacenter->authorization = $this->API->method_call(
|
||||
'auth.importBotAuthorization',
|
||||
[
|
||||
@ -55,7 +55,7 @@ trait Login
|
||||
if (!isset($this->API->settings['pwr']['pwr']) || !$this->API->settings['pwr']['pwr']) {
|
||||
file_get_contents('https://api.pwrtelegram.xyz/bot'.$token.'/getme');
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->API->datacenter->authorization;
|
||||
}
|
||||
@ -63,10 +63,10 @@ trait Login
|
||||
public function phone_login($number, $sms_type = 5)
|
||||
{
|
||||
if ($this->API->datacenter->authorized) {
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->logout();
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Sending code...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Sending code...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->API->datacenter->authorization = $this->API->method_call(
|
||||
'auth.sendCode',
|
||||
[
|
||||
@ -83,7 +83,7 @@ trait Login
|
||||
$this->API->updates = [];
|
||||
$this->API->updates_key = 0;
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Code sent successfully! Once you receive the code you should use the complete_phone_login function.'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Code sent successfully! Once you receive the code you should use the complete_phone_login function.'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->API->datacenter->authorization;
|
||||
}
|
||||
@ -94,7 +94,7 @@ trait Login
|
||||
throw new \danog\MadelineProto\Exception("I'm not waiting for the code! Please call the phone_login method first");
|
||||
}
|
||||
$this->API->datacenter->login_temp_status = 'none';
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
try {
|
||||
$authorization = $this->API->method_call(
|
||||
'auth.signIn',
|
||||
@ -106,8 +106,9 @@ trait Login
|
||||
);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->getMessage() === 'SESSION_PASSWORD_NEEDED') {
|
||||
\danog\MadelineProto\Logger::log(['2FA enabled, you will have to call the complete_2fa_login function...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['2FA enabled, you will have to call the complete_2fa_login function...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->API->datacenter->login_temp_status = 'waiting_password';
|
||||
|
||||
return $this->API->datacenter->authorization = $this->account->getPassword();
|
||||
}
|
||||
throw $e;
|
||||
@ -117,19 +118,18 @@ trait Login
|
||||
$this->API->get_updates_state();
|
||||
$this->API->should_serialize = true;
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->API->datacenter->authorization;
|
||||
}
|
||||
|
||||
|
||||
public function complete_2fa_login($password)
|
||||
{
|
||||
if ($this->API->datacenter->login_temp_status !== 'waiting_password') {
|
||||
throw new \danog\MadelineProto\Exception("I'm not waiting for the password! Please call the phone_login and the complete_phone_login methods first!");
|
||||
}
|
||||
$this->API->datacenter->login_temp_status = 'none';
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
$this->API->datacenter->authorization = $this->API->method_call(
|
||||
'auth.checkPassword',
|
||||
[
|
||||
@ -140,7 +140,7 @@ trait Login
|
||||
$this->API->get_updates_state();
|
||||
$this->API->should_serialize = true;
|
||||
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->API->datacenter->authorization;
|
||||
}
|
||||
|
@ -37,23 +37,25 @@ if ($MadelineProto === false) {
|
||||
'phone_number' => getenv('MTPROTO_NUMBER'),
|
||||
]
|
||||
);
|
||||
\danog\MadelineProto\Logger::log([$checkedPhone], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log([$checkedPhone], \danog\MadelineProto\Logger::NOTICE);
|
||||
$sentCode = $MadelineProto->phone_login(getenv('MTPROTO_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);
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline("Please enter your password (hint ".$authorization['hint'].'): '));
|
||||
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));
|
||||
}
|
||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL;
|
||||
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
} else $MadelineProto->bot_login(getenv('BOT_TOKEN'));
|
||||
} else {
|
||||
$MadelineProto->bot_login(getenv('BOT_TOKEN'));
|
||||
}
|
||||
}
|
||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||
|
||||
@ -97,9 +99,9 @@ $media['document'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile,
|
||||
|
||||
foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
$sentMessage = $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => $message, 'entities' => [['_' => 'inputMessageEntityMentionName', 'offset' => 0, 'length' => 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) {
|
||||
\danog\MadelineProto\Logger::log([$MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia])], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log([$MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia])], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +115,7 @@ echo 'Size of MadelineProto instance is '.strlen(serialize($MadelineProto)).' by
|
||||
if ($bot_token = getenv('BOT_TOKEN')) {
|
||||
$MadelineProto = new \danog\MadelineProto\API($settings);
|
||||
$authorization = $MadelineProto->bot_login($bot_token);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
$message = 'yay';
|
||||
$mention = $MadelineProto->get_info(getenv('TEST_USERNAME')); // Returns an array with all of the constructors that can be extracted from a username or an id
|
||||
@ -121,7 +123,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' => strlen($message), 'user_id' => $mention]]]);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
sleep(5);
|
||||
var_dump($MadelineProto->API->get_updates());
|
||||
|
Loading…
x
Reference in New Issue
Block a user