From 5722ba83065a9435ccdba658fa78aa41f5e1ebe0 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 7 Oct 2020 09:44:17 +0200 Subject: [PATCH] Revert add_admins property logic since it differs from the rest --- telethon/tl/custom/participantpermissions.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/telethon/tl/custom/participantpermissions.py b/telethon/tl/custom/participantpermissions.py index 34c9d59d..3b9f864b 100644 --- a/telethon/tl/custom/participantpermissions.py +++ b/telethon/tl/custom/participantpermissions.py @@ -79,6 +79,17 @@ class ParticipantPermissions: """ return isinstance(self.participant, types.ChannelParticipantBanned) + @property + def add_admins(self): + """ + Whether the administrator can add new administrators with the same or + less permissions than them. + """ + if not self.is_admin or (self.is_chat and not self.is_creator): + return False + + return self.participant.admin_rights.add_admins + ban_users = property(**_admin_prop('ban_users', """ Whether the administrator can ban other users or not. """)) @@ -87,11 +98,6 @@ class ParticipantPermissions: Whether the administrator can pin messages or not. """)) - add_admins = property(**_admin_prop('add_admins', """ - Whether the administrator can add new administrators with the same or - less permissions than them. - """)) - invite_users = property(**_admin_prop('invite_users', """ Whether the administrator can add new users to the chat. """))