AddChatUserRequest

Only users can use this request. See code examples.

---functions---
messages.addChatUser#cbc6d107 chat_id:long user_id:InputUser fwd_limit:int = messages.InvitedUsers

Returns

messages.InvitedUsers

This type can only be an instance of:

InvitedUsers

Parameters

chat_idlong
user_idInputUserAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
fwd_limitint

Known RPC errors

This request can cause 9 known errors:

ChatAdminRequiredErrorChat 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.
ChatIdInvalidErrorInvalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead.
InputUserDeactivatedErrorThe specified user was deleted.
PeerIdInvalidErrorAn invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations).
UsersTooMuchErrorThe maximum number of users has been exceeded (to create a chat, for example).
UserAlreadyParticipantErrorThe authenticated user is already a participant of the chat.
UserIdInvalidErrorInvalid 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.
UserNotMutualContactErrorThe provided user is not a mutual contact.
UserPrivacyRestrictedErrorThe user's privacy settings do not allow you to do this.

You can import these from telethon.errors.

Example

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.AddChatUserRequest(
        chat_id=-12398745604826,
        user_id='username',
        fwd_limit=42
    ))
    print(result.stringify())