fixed get_pwr_chat

This commit is contained in:
Daniil Gentili 2017-07-27 00:28:31 +02:00
parent bf14298188
commit 5f056d12d7

View File

@ -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) {