From 603772650e1b4721a363adbdc09d72d57ea1a461 Mon Sep 17 00:00:00 2001 From: kolay Date: Sat, 3 Oct 2020 14:14:01 +0300 Subject: [PATCH] added a little of docs and return in end of get_permissions --- telethon/client/chats.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/telethon/client/chats.py b/telethon/client/chats.py index a04370ce..55d6494f 100644 --- a/telethon/client/chats.py +++ b/telethon/client/chats.py @@ -1149,7 +1149,24 @@ class ChatMethods: self: 'TelegramClient', entity: 'hints.EntityLike', user: 'hints.EntityLike' - ) -> 'custom.ParticipantPermissions': + ) -> 'typing.Optional[custom.ParticipantPermissions]': + """ + Getting a user's permissions from a chat or channel. + + Arguments + entity (`entity`): + The channel or chat. + + user (`entity`): + Target user. + + Example + .. code-block:: python + + permissions = await client.get_permissions(chat, user) + if permissions.is_admin: + # do something + """ entity = await self.get_input_entity(entity) user = await self.get_input_entity(user) if helpers._entity_type(user) != helpers._EntityType.USER: @@ -1167,6 +1184,7 @@ class ChatMethods: for participant in chat.participants.participants: if participant.user_id == user.id: return custom.ParticipantPermissions(participant.participant, True) + return None raise ValueError('You must pass either a channel or a chat')