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_id | long | |
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.). |
fwd_limit | int |
Known RPC errors
This request can cause 9 known errors:
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. |
ChatIdInvalidError | Invalid 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. |
InputUserDeactivatedError | The specified user was deleted. |
PeerIdInvalidError | An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations). |
UsersTooMuchError | The maximum number of users has been exceeded (to create a chat, for example). |
UserAlreadyParticipantError | The authenticated user is already a participant of the chat. |
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
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())