Merge branch 'master' of https://github.com/danog/MadelineProto
This commit is contained in:
commit
e99398ce75
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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