Handle channel difference too long

This commit is contained in:
Daniil Gentili 2017-01-20 01:42:41 +01:00
parent af4b916056
commit b15eab0832
3 changed files with 11 additions and 4 deletions

View File

@ -158,7 +158,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
'protocol' => 'tcp_full', // can be tcp_full, tcp_abridged, tcp_intermediate, http (unsupported), https (unsupported), udp (unsupported)
'test_mode' => false, // decides whether to connect to the main telegram servers or to the testing servers (deep telegram)
'ipv6' => $this->ipv6, // decides whether to use ipv6, ipv6 attribute of API attribute of API class contains autodetected boolean
'timeout' => 5, // timeout for sockets
'timeout' => 3, // timeout for sockets
],
],
'app_info' => [ // obtained in https://my.telegram.org

View File

@ -32,6 +32,7 @@ trait CallHandler
$this->datacenter->new_outgoing[$int_message_id] = ['msg_id' => $int_message_id, 'method' => $method, 'type' => $this->methods->find_by_method($method)['type']];
$res_count = 0;
$server_answer = null;
$update_count = 0;
while ($server_answer === null && $res_count++ < $this->settings['max_tries']['response']) { // Loop until we get a response, loop for a max of $this->settings['max_tries']['response'] times
try {
\danog\MadelineProto\Logger::log('Getting response (try number '.$res_count.' for '.$method.')...');
@ -39,7 +40,9 @@ trait CallHandler
if (!isset($this->datacenter->outgoing_messages[$int_message_id]['response']) || !isset($this->datacenter->incoming_messages[$this->datacenter->outgoing_messages[$int_message_id]['response']]['content'])) { // Checks if I have received the response to the called method, if not continue looping
if ($this->only_updates) {
if ($update_count > 50) { $update_count = 0; continue; }
$res_count--;
$update_count++;
}
continue;
}
@ -110,7 +113,7 @@ trait CallHandler
$this->reset_session();
$this->datacenter->temp_auth_key = null;
$this->init_authorization();
throw new \danog\MadelineProto\Exception('Resend message');
continue 3;
}
throw new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.$this->bad_msg_error_codes[$server_answer['error_code']], $server_answer['error_code']);
break;

View File

@ -147,6 +147,10 @@ trait UpdateHandler
//unset($this->channels_state[$channel]);
//unset($this->chats[$this->get_info('channel#'.$channel)['bot_api_id']]);
$this->handle_update_messages($difference['messages'], $channel);
$this->set_channel_state($channel, $difference);
unset($difference);
unset($input);
$this->get_channel_difference($channel);
break;
default:
throw new \danog\MadelineProto\Exception('Unrecognized update difference received: '.var_export($difference, true));