diff --git a/mautrix_telegram/bot.py b/mautrix_telegram/bot.py index 1dee6ca7..7c4f1e0c 100644 --- a/mautrix_telegram/bot.py +++ b/mautrix_telegram/bot.py @@ -29,6 +29,7 @@ from telethon.tl.types import ( ChatForbidden, ChatParticipantAdmin, ChatParticipantCreator, + ChatParticipantsForbidden, InputChannel, InputUser, MessageActionChatAddUser, @@ -198,6 +199,8 @@ class Bot(AbstractUser): return pcp elif isinstance(chat, PeerChat): chat = await self.client(GetFullChatRequest(chat.chat_id)) + if isinstance(chat.full_chat.participants, ChatParticipantsForbidden): + return None participants = chat.full_chat.participants.participants for p in participants: self._admin_cache[chat.channel_id, tgid] = (p, time.time()) diff --git a/mautrix_telegram/portal_util/participants.py b/mautrix_telegram/portal_util/participants.py index eaa29ff6..c5f0d543 100644 --- a/mautrix_telegram/portal_util/participants.py +++ b/mautrix_telegram/portal_util/participants.py @@ -24,6 +24,7 @@ from telethon.tl.types import ( ChannelParticipantBanned, ChannelParticipantsRecent, ChannelParticipantsSearch, + ChatParticipantsForbidden, InputChannel, InputUser, TypeChannelParticipant, @@ -93,6 +94,8 @@ async def get_users( ) -> list[TypeUser]: if peer_type == "chat": chat = await client(GetFullChatRequest(chat_id=tgid)) + if isinstance(chat.full_chat.participants, ChatParticipantsForbidden): + return [] users = list(_filter_participants(chat.users, chat.full_chat.participants.participants)) return users[:limit] if limit > 0 else users elif peer_type == "channel":