mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-10 16:12:22 +03:00
Create Admin Permissions page
parent
99c7a8b3fb
commit
27503ec6b1
27
Admin-Permissions.md
Normal file
27
Admin-Permissions.md
Normal file
|
@ -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)).
|
Loading…
Reference in New Issue
Block a user