From 97e4d83593d1c67a137cc1824c08cf4cf8475a35 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 6 Jul 2019 19:30:21 +0200 Subject: [PATCH] Rename and clarify docs for edit_permissions --- readthedocs/quick-references/client-reference.rst | 2 ++ telethon/client/chats.py | 15 +++++++++++---- telethon_generator/data/friendly.csv | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/readthedocs/quick-references/client-reference.rst b/readthedocs/quick-references/client-reference.rst index 7a3e71ef..11774ab0 100644 --- a/readthedocs/quick-references/client-reference.rst +++ b/readthedocs/quick-references/client-reference.rst @@ -134,6 +134,8 @@ Chats get_admin_log iter_profile_photos get_profile_photos + edit_admin + edit_permissions action Parse Mode diff --git a/telethon/client/chats.py b/telethon/client/chats.py index 45658ffd..74111ffb 100644 --- a/telethon/client/chats.py +++ b/telethon/client/chats.py @@ -876,7 +876,7 @@ class ChatMethods: else: raise ValueError('You can only edit permissions in groups and channels') - async def edit_restrictions( + async def edit_permissions( self: 'TelegramClient', entity: 'hints.EntityLike', user: 'typing.Optional[hints.EntityLike]' = None, @@ -890,15 +890,19 @@ class ChatMethods: send_games: bool = True, send_inline: bool = True, send_polls: bool = True, - change_info: bool = True, - invite_users: bool = True, - pin_messages: bool = True) -> types.Updates: + change_info: bool = False, + invite_users: bool = False, + pin_messages: bool = False) -> types.Updates: """ Edits user restrictions in a chat. Raises an error if wrong a combination of rights are given (e.g. you don't have enough permissions to revoke one). + Each of the boolean arguments answer the question "can the given + user do this?", which by default is `True` for all permissions + except those which state otherwise. + Arguments entity (`entity`): The channel or megagroup where the restriction should happen. @@ -941,12 +945,15 @@ class ChatMethods: change_info (`bool`, optional): Whether the user is able to change info or not. + Unlike the rest of the arguments, this is `False` by default. invite_users (`bool`, optional): Whether the user is able to invite other users or not. + Unlike the rest of the arguments, this is `False` by default. pin_messages (`bool`, optional): Whether the user is able to pin messages or not. + Unlike the rest of the arguments, this is `False` by default. Returns The resulting :tl:`Updates` object. diff --git a/telethon_generator/data/friendly.csv b/telethon_generator/data/friendly.csv index ea754cff..739b536a 100644 --- a/telethon_generator/data/friendly.csv +++ b/telethon_generator/data/friendly.csv @@ -8,7 +8,7 @@ auth.AuthMethods,edit_2fa,account.updatePasswordSettings bots.BotMethods,inline_query,messages.getInlineBotResults chats.ChatMethods,action,messages.setTyping chats.ChatMethods,edit_admin,functions.channels.editAdminRequest functions.messages.editChatAdminRequest -chats.ChatMethods,edit_restrictions,functions.channels.editBannedRequest functions.messages.editChatDefaultBannedRightsRequest +chats.ChatMethods,edit_permissions,functions.channels.editBannedRequest functions.messages.editChatDefaultBannedRightsRequest chats.ChatMethods,iter_participants,channels.getParticipants chats.ChatMethods,iter_admin_log,channels.getAdminLog dialogs.DialogMethods,iter_dialogs,messages.getDialogs