Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-06-29 16:16:12 +00:00 committed by StyleCI Bot
parent c1e2c93af7
commit 33d95dab58
6 changed files with 9 additions and 13 deletions

View File

@ -54,7 +54,7 @@ class Logger
self::$default = new self($mode, $optional, $prefix, $level, $max_size);
}
public function __construct($mode, $optional = null, $prefix = '', $level = self::NOTICE, $max_size = 100*1024*1024)
public function __construct($mode, $optional = null, $prefix = '', $level = self::NOTICE, $max_size = 100 * 1024 * 1024)
{
if ($mode === null) {
throw new Exception(\danog\MadelineProto\Lang::$current_lang['no_mode_specified']);

View File

@ -542,7 +542,7 @@ trait AuthKeyHandler
$this->logger->logger(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;
} else if ($socket->auth_key === null && $media) {
} elseif ($socket->auth_key === null && $media) {
$socket->auth_key = $this->datacenter->sockets[intval($id)]->auth_key;
$socket->authorized = $this->datacenter->sockets[intval($id)]->authorized;
}

View File

@ -340,7 +340,6 @@ trait ResponseHandler
$aargs['datacenter'] .= '_media';
}
throw new \danog\MadelineProto\Exception('Received request to switch to DC '.$this->datacenter->curdc);
case 401:
switch ($server_answer['error_message']) {

View File

@ -506,15 +506,15 @@ trait BotAPI
$offset = 0;
foreach ($args['entities'] as $entity) {
do {
while ($entity['offset'] > $offset+$this->mb_strlen($multiple_args[$i]['message'])) {
while ($entity['offset'] > $offset + $this->mb_strlen($multiple_args[$i]['message'])) {
$offset += $this->mb_strlen($multiple_args[$i]['message']);
$i++;
}
$entity['offset'] -= $offset;
if ($entity['offset']+$entity['length'] > $this->mb_strlen($multiple_args[$i]['message'])) {
if ($entity['offset'] + $entity['length'] > $this->mb_strlen($multiple_args[$i]['message'])) {
$newentity = $entity;
$newentity['length'] = $entity['length']-($this->mb_strlen($multiple_args[$i]['message'])-$entity['offset']);
$entity['length'] = $this->mb_strlen($multiple_args[$i]['message'])-$entity['offset'];
$newentity['length'] = $entity['length'] - ($this->mb_strlen($multiple_args[$i]['message']) - $entity['offset']);
$entity['length'] = $this->mb_strlen($multiple_args[$i]['message']) - $entity['offset'];
$multiple_args[$i]['entities'][] = $entity;
$offset += $this->mb_strlen($multiple_args[$i]['message']);
@ -529,6 +529,7 @@ trait BotAPI
}
} while (true);
}
return $multiple_args;
}

View File

@ -18,8 +18,8 @@ namespace danog\MadelineProto\Wrappers;
*/
trait TOS
{
public function check_tos()
{
public function check_tos()
{
if ($this->authorized === self::LOGGED_IN && !$this->get_self()['bot']) {
if ($this->tos['expires'] < time()) {
$this->logger->logger('Fetching TOS...');

View File

@ -45,10 +45,8 @@ echo 'Loading MadelineProto...'.PHP_EOL;
$MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings);
$MadelineProto->messages->sendMessage(['peer' => '@pwrtelegramgroupita', 'message' => '<b>'.str_repeat('a b c d', 700).'</b>', 'parse_mode' => 'markdown']);
try {
$MadelineProto->get_self();
} catch (\danog\MadelineProto\Exception $e) {
@ -272,5 +270,3 @@ 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);
}