diff --git a/readthedocs/misc/v2-migration-guide.rst b/readthedocs/misc/v2-migration-guide.rst index 628b7a95..5e9d6a5d 100644 --- a/readthedocs/misc/v2-migration-guide.rst +++ b/readthedocs/misc/v2-migration-guide.rst @@ -225,6 +225,16 @@ The "aggressive" hack in ``get_participants`` (and ``iter_participants``) is now It was not reliable, and was a cause of flood wait errors. +The total value when getting participants has changed +----------------------------------------------------- + +Before, it used to always be the total amount of people inside the chat. Now the filter is also +considered. If you were running ``client.get_participants`` with a ``filter`` other than the +default and accessing the ``list.total``, you will now get a different result. You will need to +perform a separate request with no filter to fetch the total without filter (this is what the +library used to do). + + The TelegramClient is no longer made out of mixins -------------------------------------------------- diff --git a/telethon/_client/chats.py b/telethon/_client/chats.py index 3fcce1b4..1aa0724d 100644 --- a/telethon/_client/chats.py +++ b/telethon/_client/chats.py @@ -184,27 +184,8 @@ class _ParticipantsIter(requestiter.RequestIter): if self.request.offset > self.limit: return True - if self.total is None: - f = self.request.filter - if ( - not isinstance(f, _tl.ChannelParticipantsRecent) - and (not isinstance(f, _tl.ChannelParticipantsSearch) or f.q) - ): - # Only do an additional getParticipants here to get the total - # if there's a filter which would reduce the real total number. - # getParticipants is cheaper than getFull. - self.total = (await self.client(_tl.fn.channels.GetParticipants( - channel=self.request.channel, - filter=_tl.ChannelParticipantsRecent(), - offset=0, - limit=1, - hash=0 - ))).count - participants = await self.client(self.request) - if self.total is None: - # Will only get here if there was one request with a filter that matched all users. - self.total = participants.count + self.total = participants.count self.request.offset += len(participants.participants) users = {user.id: user for user in participants.users}