EditAdminRequest
Both users and bots can use this request. See code examples.
---functions--- channels.editAdmin#d33c8902 channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights rank:string = Updates
Returns
Updates |
This type can be an instance of either:
UpdateShort | UpdateShortChatMessage |
UpdateShortMessage | UpdateShortSentMessage |
Updates | UpdatesCombined |
UpdatesTooLong |
Parameters
channel | InputChannel | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer , User or Channel objects, etc.). |
user_id | InputUser | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer , User or Channel objects, etc.). |
admin_rights | ChatAdminRights | |
rank | string |
Known RPC errors
This request can cause 13 known errors:
AdminsTooMuchError | Too many admins. |
AdminRankEmojiNotAllowedError | Emoji are not allowed in admin titles or ranks. |
AdminRankInvalidError | The given admin title or rank was invalid (possibly larger than 16 characters). |
BotChannelsNaError | Bots can't edit admin privileges. |
ChannelInvalidError | Invalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited. |
ChatAdminInviteRequiredError | You do not have the rights to do this. |
ChatAdminRequiredError | Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group. |
FreshChangeAdminsForbiddenError | Recently logged-in users cannot add or change admins. |
RightForbiddenError | Either your admin rights do not allow you to do this or you passed the wrong rights combination (some rights only apply to channels and vice versa). |
UserCreatorError | You can't leave this channel, because you're its creator. |
UserIdInvalidError | Invalid object ID for a user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited. |
UserNotMutualContactError | The provided user is not a mutual contact. |
UserPrivacyRestrictedError | The user's privacy settings do not allow you to do this. |
You can import these from telethon.errors
.
Example
Please refer to the documentation of client.edit_admin()
to learn about the parameters and see several code examples on how to use it.
The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.
from telethon.sync import TelegramClient from telethon import functions, types with TelegramClient(name, api_id, api_hash) as client: result = client(functions.channels.EditAdminRequest( channel='username', user_id='username', admin_rights=types.ChatAdminRights( change_info=True, post_messages=True, edit_messages=True, delete_messages=True, ban_users=True, invite_users=True, pin_messages=True, add_admins=True, anonymous=True, manage_call=True, other=True, manage_topics=True, post_stories=True, edit_stories=True, delete_stories=True ), rank='some string here' )) print(result.stringify())