diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index e9746e84..68f025a4 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -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 diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 0e161bc3..9c77ea6e 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -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; } @@ -108,9 +111,9 @@ trait CallHandler $this->datacenter->timedelta = ($this->datacenter->outgoing_messages[$int_message_id]['response'] >> 32) - time(); \danog\MadelineProto\Logger::log('Set time delta to '.$this->datacenter->timedelta); $this->reset_session(); -$this->datacenter->temp_auth_key = null; -$this->init_authorization(); - throw new \danog\MadelineProto\Exception('Resend message'); + $this->datacenter->temp_auth_key = null; + $this->init_authorization(); + 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; diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index edb570da..9781ca89 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -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));