Apply fixes from StyleCI
This commit is contained in:
parent
9df224cec3
commit
62ce466afc
@ -90,10 +90,7 @@ trait PeerHandler
|
||||
|
||||
public function peer_isset($id)
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
|
||||
return isset($this->chats[$this->get_info($id)['bot_api_id']]);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
return false;
|
||||
@ -137,7 +134,6 @@ trait PeerHandler
|
||||
|
||||
public function get_info($id, $recursive = true)
|
||||
{
|
||||
|
||||
if (is_array($id)) {
|
||||
switch ($id['_']) {
|
||||
case 'inputUserSelf':
|
||||
@ -185,7 +181,6 @@ trait PeerHandler
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (preg_match('/^channel#/', $id)) {
|
||||
$id = preg_replace('|\D+|', '-100', $id);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ trait ResponseHandler
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['users'])) {
|
||||
$this->add_users($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['users']);
|
||||
}
|
||||
|
@ -25,17 +25,20 @@ trait SeqNoHandler
|
||||
|
||||
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(['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);
|
||||
}
|
||||
|
||||
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(['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);
|
||||
}
|
||||
}
|
||||
|
||||
public function generate_in_seq_no($datacenter, $content_related)
|
||||
{
|
||||
$in = $content_related ? 1 : 0;
|
||||
$value = $this->datacenter->sockets[$datacenter]->session_in_seq_no;
|
||||
$this->datacenter->sockets[$datacenter]->session_in_seq_no += $in;
|
||||
|
||||
return ($value * 2) + $in;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ trait UpdateHandler
|
||||
case 'updateEditMessage':
|
||||
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'])) ||
|
||||
|
@ -70,7 +70,6 @@ echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL;
|
||||
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||
echo 'Size of MadelineProto instance is '.strlen(serialize($MadelineProto)).' bytes'.PHP_EOL;
|
||||
|
||||
|
||||
$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
|
||||
|
||||
@ -117,7 +116,6 @@ foreach (json_decode(getenv('TEST_DESTINATION_GROUPS'), true) as $peer) {
|
||||
\danog\MadelineProto\Logger::log([$sentMessage], \danog\MadelineProto\Logger::NOTICE);
|
||||
foreach ($media as $type => $inputMedia) {
|
||||
$type = $MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user