mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 02:43:45 +03:00
Updated Admin Permissions (markdown)
parent
30866da9ce
commit
d11d158891
|
@ -1,27 +1,14 @@
|
|||
Giving or revoking admin permissions can be done with the [`EditAdminRequest`](https://lonamiwebs.github.io/Telethon/methods/channels/edit_admin.html):
|
||||
Giving or revoking admin permissions can be done with the following code:
|
||||
|
||||
```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
|
||||
)
|
||||
# Give admin permissions to user in chat/channel
|
||||
client.edit_admin(channel, who, is_admin=True)
|
||||
|
||||
client(EditAdminRequest(channel, who, rights))
|
||||
# Revoke admin for user in chat/channel
|
||||
client.edit_admin(channel, who, is_admin=False)
|
||||
```
|
||||
Note that you can also deny/allow specific permissions for an admin using the positional arguments of `edit_admin`. More about this method and the arguments it takes [here](https://docs.telethon.dev/en/latest/modules/client.html#telethon.client.chats.ChatMethods.edit_admin).
|
||||
|
||||
|
||||
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)).
|
Loading…
Reference in New Issue
Block a user