InviteToChannelRequest

Only users can use this request. See code examples.

---functions---
channels.inviteToChannel#c9e33d54 channel:InputChannel users:Vector<InputUser> = messages.InvitedUsers

Returns

messages.InvitedUsers

This type can only be an instance of:

InvitedUsers

Parameters

channelInputChannelAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
usersInputUserAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.). A list must be supplied.

Known RPC errors

This request can cause 17 known errors:

BotsTooMuchErrorThere are too many bots in this chat/channel.
BotGroupsBlockedErrorThis bot can't be added to groups.
ChannelInvalidErrorInvalid 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.
ChannelPrivateErrorThe channel specified is private and you lack permission to access it. Another reason may be that you were banned from it.
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.
ChatInvalidErrorThe chat is invalid for this request.
ChatWriteForbiddenErrorYou can't write in this chat.
InputUserDeactivatedErrorThe specified user was deleted.
UsersTooMuchErrorThe maximum number of users has been exceeded (to create a chat, for example).
UserBannedInChannelErrorYou're banned from sending messages in supergroups/channels.
UserBlockedErrorUser blocked.
UserBotErrorBots can only be admins in channels..
UserChannelsTooMuchErrorOne of the users you tried to add is already in too many channels/supergroups.
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.
UserKickedErrorThis user was kicked from this supergroup/channel.
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.channels.InviteToChannelRequest(
        channel='username',
        users=['username']
    ))
    print(result.stringify())