Add catch block to channel participant fetching in case the participants are hidden
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from telethon.tl.functions.messages import GetFullChatRequest
|
from telethon.tl.functions.messages import GetFullChatRequest
|
||||||
from telethon.tl.functions.channels import GetParticipantsRequest
|
from telethon.tl.functions.channels import GetParticipantsRequest
|
||||||
|
from telethon.errors.rpc_error_list import ChatAdminRequiredError
|
||||||
from telethon.tl.types import *
|
from telethon.tl.types import *
|
||||||
from .db import Portal as DBPortal, Message as DBMessage
|
from .db import Portal as DBPortal, Message as DBMessage
|
||||||
from . import puppet as p, formatter
|
from . import puppet as p, formatter
|
||||||
@@ -171,10 +172,13 @@ class Portal:
|
|||||||
if self.peer_type == "chat":
|
if self.peer_type == "chat":
|
||||||
return user.client(GetFullChatRequest(chat_id=self.tgid)).users
|
return user.client(GetFullChatRequest(chat_id=self.tgid)).users
|
||||||
elif self.peer_type == "channel":
|
elif self.peer_type == "channel":
|
||||||
participants = user.client(GetParticipantsRequest(
|
try:
|
||||||
entity, ChannelParticipantsRecent(), offset=0, limit=100, hash=0
|
participants = user.client(GetParticipantsRequest(
|
||||||
))
|
entity, ChannelParticipantsRecent(), offset=0, limit=100, hash=0
|
||||||
return participants.users
|
))
|
||||||
|
return participants.users
|
||||||
|
except ChatAdminRequiredError:
|
||||||
|
return []
|
||||||
elif self.peer_type == "user":
|
elif self.peer_type == "user":
|
||||||
return [entity]
|
return [entity]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user