Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-02-19 12:23:53 +00:00 committed by StyleCI Bot
parent aaa5177607
commit fde7307f1d
8 changed files with 42 additions and 38 deletions

View File

@ -13,7 +13,7 @@ If not, see <http://www.gnu.org/licenses/>.
set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/')); set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/'));
require 'vendor/autoload.php'; require 'vendor/autoload.php';
$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']];//, 'connection_settings' => ['all' => ['test_mode' => true]]]; $settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']]; //, 'connection_settings' => ['all' => ['test_mode' => true]]];
try { try {
$MadelineProto = new \danog\MadelineProto\API('bot.madeline'); $MadelineProto = new \danog\MadelineProto\API('bot.madeline');

View File

@ -84,7 +84,7 @@ if (!extension_loaded('pthreads')) {
} }
$errno = 0; $errno = 0;
$errstr = ''; $errstr = '';
$this->sock = fsockopen($this->protocol.'://'.$address, $port, $errno, $errstr, $this->timeout['sec'] + ($this->timeout['usec']/1000000)); $this->sock = fsockopen($this->protocol.'://'.$address, $port, $errno, $errstr, $this->timeout['sec'] + ($this->timeout['usec'] / 1000000));
stream_set_timeout($this->sock, $this->timeout['sec'], $this->timeout['usec']); stream_set_timeout($this->sock, $this->timeout['sec'], $this->timeout['usec']);
return true; return true;

View File

@ -66,10 +66,8 @@ class DataCenter
$x = 0; $x = 0;
do { do {
$ipv6 = $this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4'; $ipv6 = $this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4';
if (!isset($this->dclist[$test][$ipv6][$dc_number]['ip_address'])) { if (!isset($this->dclist[$test][$ipv6][$dc_number]['ip_address'])) {
unset($this->sockets[$dc_number]); unset($this->sockets[$dc_number]);
@ -103,6 +101,7 @@ class DataCenter
\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) { 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 { try {
if (isset($this->sockets[$dc_number]->old)) { if (isset($this->sockets[$dc_number]->old)) {
$this->sockets[$dc_number]->__construct($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']); $this->sockets[$dc_number]->__construct($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']);
@ -111,6 +110,7 @@ class DataCenter
$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']); $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; return true;
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {
} catch (\danog\MadelineProto\NothingInTheSocketException $e) { } catch (\danog\MadelineProto\NothingInTheSocketException $e) {

View File

@ -601,7 +601,7 @@ trait AuthKeyHandler
$config = $this->method_call('help.getConfig', [], ['datacenter' => $id]); $config = $this->method_call('help.getConfig', [], ['datacenter' => $id]);
$this->sync_authorization($id); $this->sync_authorization($id);
$this->get_config($config); $this->get_config($config);
} else if ($socket->temp_auth_key === null) { } 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); $socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
} }
@ -611,7 +611,7 @@ trait AuthKeyHandler
$config = $this->method_call('help.getConfig', [], ['datacenter' => $id]); $config = $this->method_call('help.getConfig', [], ['datacenter' => $id]);
$this->sync_authorization($id); $this->sync_authorization($id);
$this->get_config($config); $this->get_config($config);
} else if ($socket->temp_auth_key === null) { } 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); $socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
} }

View File

@ -87,7 +87,7 @@ trait CallHandler
'system_lang_code' => $this->settings['app_info']['lang_code'], 'system_lang_code' => $this->settings['app_info']['lang_code'],
'lang_code' => $this->settings['app_info']['lang_code'], 'lang_code' => $this->settings['app_info']['lang_code'],
'lang_pack' => '', 'lang_pack' => '',
'query' => $serialized 'query' => $serialized,
] ]
), ),
]); ]);
@ -271,7 +271,9 @@ trait CallHandler
throw new \danog\MadelineProto\Exception('An error occurred while calling method '.$method.' ('.$last_error.').'); 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; 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;
}
$this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id] = []; $this->datacenter->sockets[$aargs['datacenter']]->outgoing_messages[$message_id] = [];
if (isset($message_chunks) && count($message_chunks)) { if (isset($message_chunks) && count($message_chunks)) {

View File

@ -413,6 +413,7 @@ trait Files
$data = substr($data, $this->cdn_hashes[$file][$offset]['limit']); $data = substr($data, $this->cdn_hashes[$file][$offset]['limit']);
$offset += $this->cdn_hashes[$file][$offset]['limit']; $offset += $this->cdn_hashes[$file][$offset]['limit'];
} }
return true; return true;
} }

View File

@ -246,7 +246,9 @@ trait ResponseHandler
case 'Updates': case 'Updates':
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]); unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
$unset = true; $unset = true;
if (strpos($datacenter, 'cdn') === false) $this->handle_updates($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']); if (strpos($datacenter, 'cdn') === false) {
$this->handle_updates($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);
}
$only_updates = true && $only_updates; $only_updates = true && $only_updates;
break; break;
default: default:

View File

@ -221,7 +221,6 @@ $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 $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
$mention = $mention['user_id']; // Selects only the numeric user id $mention = $mention['user_id']; // Selects only the numeric user id
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]]]); $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);