Telethon
Telethon copied to clipboard
TelegramClient.iter_participants errors when encounters a ChannelParticipantLeft
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't a duplicate.
- [x] I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
and triggered the bug in the latest version.
Code that causes the issue
for user in client.iter_participants(some_channel, filter=ChannelParticipantsBanned("")):
pass
Traceback
for user in client.iter_participants(some_channel, filter=ChannelParticipantsBanned("")):
File "/home/manuel/.local/lib/python3.7/site-packages/telethon/requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "/home/manuel/.local/lib/python3.7/site-packages/telethon/client/chats.py", line 242, in _load_next_chunk
user_id = participant.user_id
AttributeError: 'ChannelParticipantLeft' object has no attribute 'user_id'
Ah, I have forgotten about this issue. I confirm this bug and will publish a solution soon.
According to the TDLiib developer these channelParticipantLeft should be ignored: https://t.me/tdlibchat/33266
As a workaround you may change line 236 in chats.py to handle this issue like this:
if isinstance(participant, (types.ChannelParticipantBanned, types.ChannelParticipantLeft)):
According to documentation ChannelParticipantLeft contains Peer like ChannelParticipantBanned.
As a workaround you may change line 236 in chats.py to handle this issue like this:
if isinstance(participant, (types.ChannelParticipantBanned, types.ChannelParticipantLeft)):
According to documentation ChannelParticipantLeft contains Peer like ChannelParticipantBanned.
This would cause the user to be returned though, such users should be skipped as they are not actually banned/restricted
When will this bug be fixed?😑
The bugfix for this will be available in the next version which I plan to release in a few days.