From 7bb9b4dc4be72a4668d1eea7b21425bc5e882030 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 27 Jan 2018 13:11:06 +0200 Subject: [PATCH] Add catch block to channel participant fetching in case the participants are hidden --- mautrix_telegram/portal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 1c8766a4..8dcd46c0 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -15,6 +15,7 @@ # along with this program. If not, see . from telethon.tl.functions.messages import GetFullChatRequest from telethon.tl.functions.channels import GetParticipantsRequest +from telethon.errors.rpc_error_list import ChatAdminRequiredError from telethon.tl.types import * from .db import Portal as DBPortal, Message as DBMessage from . import puppet as p, formatter @@ -171,10 +172,13 @@ class Portal: if self.peer_type == "chat": return user.client(GetFullChatRequest(chat_id=self.tgid)).users elif self.peer_type == "channel": - participants = user.client(GetParticipantsRequest( - entity, ChannelParticipantsRecent(), offset=0, limit=100, hash=0 - )) - return participants.users + try: + participants = user.client(GetParticipantsRequest( + entity, ChannelParticipantsRecent(), offset=0, limit=100, hash=0 + )) + return participants.users + except ChatAdminRequiredError: + return [] elif self.peer_type == "user": return [entity]