From cd9f2223e78b51feb2a9ff9604b331f2bc16b479 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 3 May 2018 15:45:57 +0200 Subject: [PATCH] Some little fixes in case of ChatForbidden. Thanks @i-Naji --- pyrogram/client/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/utils.py b/pyrogram/client/utils.py index 4e76a15b..3c4436b6 100644 --- a/pyrogram/client/utils.py +++ b/pyrogram/client/utils.py @@ -127,12 +127,17 @@ def parse_user_chat(user: types.User) -> pyrogram_types.Chat: def parse_chat_chat(chat: types.Chat) -> pyrogram_types.Chat: + admins_enabled = getattr(chat, "admins_enabled", None) + + if admins_enabled is not None: + admins_enabled = not admins_enabled + return pyrogram_types.Chat( id=-chat.id, type="group", title=chat.title, - all_members_are_administrators=not chat.admins_enabled, - photo=parse_chat_photo(chat.photo) + all_members_are_administrators=admins_enabled, + photo=parse_chat_photo(getattr(chat, "photo", None)) )