Improve update handling logic
This commit is contained in:
parent
0e69468a5a
commit
1e259ae6c8
@ -351,6 +351,7 @@ trait PeerHandler
|
||||
if (is_string($id)) {
|
||||
$id = \danog\MadelineProto\Magic::$bigint ? (float) $id : (int) $id;
|
||||
}
|
||||
|
||||
if (!isset($this->chats[$id])) {
|
||||
try {
|
||||
if ($id < 0) {
|
||||
|
@ -63,7 +63,6 @@ trait ResponseHandler
|
||||
//$n = $this->n++;
|
||||
$only_updates = true;
|
||||
foreach ($this->datacenter->sockets[$datacenter]->new_incoming as $current_msg_id) {
|
||||
//var_dump($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]);
|
||||
$this->logger->logger((isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['from_container']) ? 'Inside of container, received ' : 'Received ').$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' from DC '.$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||
|
||||
switch ($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_']) {
|
||||
@ -305,7 +304,6 @@ trait ResponseHandler
|
||||
|
||||
public function handle_response($request_id, $response_id, $datacenter)
|
||||
{
|
||||
//var_dumP("Response ".bin2hex($request_id));
|
||||
$response = &$this->datacenter->sockets[$datacenter]->incoming_messages[$response_id]['content'];
|
||||
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$response_id]['content']);
|
||||
$request = &$this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id];
|
||||
@ -542,12 +540,10 @@ trait ResponseHandler
|
||||
}
|
||||
if (count($this->pending_updates)) {
|
||||
$this->logger->logger('Parsing pending updates...');
|
||||
foreach (array_keys($this->pending_updates) as $key) {
|
||||
if (isset($this->pending_updates[$key])) {
|
||||
$updates = $this->pending_updates[$key];
|
||||
unset($this->pending_updates[$key]);
|
||||
$this->handle_updates($updates);
|
||||
}
|
||||
$updates = $this->pending_updates;
|
||||
$this->pending_updates = [];
|
||||
foreach ($updates as $update) {
|
||||
$this->handle_updates($update);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -579,6 +575,7 @@ trait ResponseHandler
|
||||
$opts[$key] = $updates[$key];
|
||||
}
|
||||
}
|
||||
|
||||
switch ($updates['_']) {
|
||||
case 'updates':
|
||||
case 'updatesCombined':
|
||||
|
@ -405,7 +405,12 @@ 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']) || isset($update['message']['entities']) && !$this->entities_peer_isset($update['message']['entities']) || isset($update['message']['fwd_from']) && !$this->fwd_peer_isset($update['message']['fwd_from'])) {
|
||||
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']) ||
|
||||
isset($update['message']['entities']) && !$this->entities_peer_isset($update['message']['entities']) // ||
|
||||
//isset($update['message']['fwd_from']) && !$this->fwd_peer_isset($update['message']['fwd_from'])
|
||||
) {
|
||||
$this->logger->logger('Not enough data for message update, getting difference...', \danog\MadelineProto\Logger::VERBOSE);
|
||||
if ($channel_id !== false && $this->peer_isset($this->to_supergroup($channel_id))) {
|
||||
$this->get_channel_difference($channel_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user