From 27503ec6b158dde6be5043d749d521c7674498c4 Mon Sep 17 00:00:00 2001 From: Lonami Date: Thu, 14 Dec 2017 17:52:31 +0100 Subject: [PATCH] Create Admin Permissions page --- Admin-Permissions.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Admin-Permissions.md diff --git a/Admin-Permissions.md b/Admin-Permissions.md new file mode 100644 index 0000000..a03a47f --- /dev/null +++ b/Admin-Permissions.md @@ -0,0 +1,27 @@ +Giving or revoking admin permissions can be done with the [`EditAdminRequest`](https://lonamiwebs.github.io/Telethon/methods/channels/edit_admin.html): + +```python +from telethon.tl.functions.channels import EditAdminRequest +from telethon.tl.types import ChannelAdminRights + +# You need both the channel and who to grant permissions +# They can either be channel/user or input channel/input user. +# +# ChannelAdminRights is a list of granted permissions. +# Set to True those you want to give. +rights = ChannelAdminRights( + post_messages=None, + add_admins=None, + invite_users=None, + change_info=True, + ban_users=None, + delete_messages=True, + pin_messages=True, + invite_link=None, + edit_messages=None +) + +client(EditAdminRequest(channel, who, rights)) +``` + +Thanks to [**@Kyle2142**](https://github.com/Kyle2142) for [pointing out](https://github.com/LonamiWebs/Telethon/issues/490) that you **cannot** set to `True` the `post_messages` and `edit_messages` fields. Those that are `None` can be omitted (left here so you know [which are available](https://lonamiwebs.github.io/Telethon/constructors/channel_admin_rights.html)). \ No newline at end of file