From 5f056d12d7a2abe10084d738d2a241c8249d4a4a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 27 Jul 2017 00:28:31 +0200 Subject: [PATCH] fixed get_pwr_chat --- .../MadelineProto/MTProtoTools/PeerHandler.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 0e2866f9..7375587c 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -452,12 +452,16 @@ trait PeerHandler if (!isset($res['participants']) && isset($res['can_view_participants']) && $res['can_view_participants']) { $res['participants'] = []; $limit = 200; - $offset = -$limit; $filters = ['channelParticipantsBanned', 'channelParticipantsAdmins', 'channelParticipantsKicked', 'channelParticipantsBots', 'channelParticipantsRecent']; - $gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => 'channelParticipantsRecent'], 'offset' => $offset += $limit, 'limit' => $limit], ['datacenter' => $this->datacenter->curdc]); - $count = $res['participants_count'] + (isset($res['kicked_count']) ? $res['kicked_count'] : 0) + (isset($res['admins_count']) ? $res['admins_count'] : 0) + (isset($res['banned_count']) ? $res['banned_count'] : 0); while (count($filters)) { $filter = array_pop($filters); + $offset = -$limit; + try { + $gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => $filter, 'q' => ''], 'offset' => $offset += $limit, 'limit' => $limit], ['datacenter' => $this->datacenter->curdc]); + } catch (\danog\MadelineProto\RPCErrorException $e) { + if ($e->rpc === 'CHAT_ADMIN_REQUIRED') continue; else throw $e; + } + $count = $gres['count']; while ($offset <= $count) { foreach ($gres['participants'] as $participant) { $newres = []; @@ -510,9 +514,7 @@ trait PeerHandler break; } } - if ($offset >= $count) { - break; - } + } } if ($fullfetch || $send) {