Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal ChatAdminRequiredError when receiving messages from deleted channel #1

Open
phillbush opened this issue Nov 28, 2024 · 1 comment

Comments

@phillbush
Copy link

Hi,

A channel I was admin at got deleted, and (i think) that is causing the uncatched ChatAdminRequiredError exception thrown at async for user in self.telegram_client.iter_participants(chat.id): in telegram.py (line 180) to exit irgramd:

Traceback (most recent call last):
  File "/home/lucas/./irgramd/irgramd", line 161, in <module>
    loop.run_until_complete(irc_server.run(options))
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/lucas/./irgramd/irgramd", line 63, in run
    await self.tg_handler.initialize_telegram()
  File "/home/lucas/irgramd/telegram.py", line 137, in initialize_telegram
    await self.continue_auth()
  File "/home/lucas/irgramd/telegram.py", line 143, in continue_auth
    await self.init_mapping()
  File "/home/lucas/irgramd/telegram.py", line 157, in init_mapping
    await self.set_irc_channel_from_telegram(chat)
  File "/home/lucas/irgramd/telegram.py", line 180, in set_irc_channel_from_telegram
    async for user in self.telegram_client.iter_participants(chat.id):
  File "/home/lucas/pip/lib/python3.11/site-packages/telethon/requestiter.py", line 74, in __anext__
    if await self._load_next_chunk():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucas/pip/lib/python3.11/site-packages/telethon/client/chats.py", line 210, in _load_next_chunk
    participants = await self.client(self.requests)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucas/pip/lib/python3.11/site-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucas/pip/lib/python3.11/site-packages/telethon/client/users.py", line 87, in _call
    result = await future
             ^^^^^^^^^^^^
telethon.errors.rpcerrorlist.ChatAdminRequiredError: Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group (caused by GetParticipantsRequest)

I could bandaid-fix it by just ignoring every exception at this loop. There's certainly a proper way to fix that (which i dont know how to help with... my python knowledge is pretty basic (learnt years ago; havent practiced since).

prsai pushed a commit that referenced this issue Jan 23, 2025
@prsai
Copy link
Owner

prsai commented Jan 24, 2025

Hi, sorry for the delay and thanks for your report.

I cannot reproduce this, the error message suggests that, for some reason, there is a channel that you don't have permission to see its members, so I just have caught the exception and sent a warning to the log, this code is in the branch try_participants.

@phillbush please let me know if this fixes your problem, of course the affected channel (you could see in the log which is) will be seen as empty (with no members) from IRC, but hopefully you could still send messages, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants