InviteToChannelRequest
Only users can use this method. See code examples.
---functions--- channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = 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.). |
| users | InputUser | Anything 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:
BotsTooMuchError | There are too many bots in this chat/channel. |
BotGroupsBlockedError | This bot can't be added to groups. |
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. |
ChannelPrivateError | The channel specified is private and you lack permission to access it. Another reason may be that you were banned from it. |
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. |
ChatInvalidError | The chat is invalid for this request. |
ChatWriteForbiddenError | You can't write in this chat. |
InputUserDeactivatedError | The specified user was deleted. |
UsersTooMuchError | The maximum number of users has been exceeded (to create a chat, for example). |
UserBannedInChannelError | You're banned from sending messages in supergroups/channels. |
UserBlockedError | User blocked. |
UserBotError | Bots can only be admins in channels.. |
UserChannelsTooMuchError | One of the users you tried to add is already in too many channels/supergroups. |
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. |
UserKickedError | This user was kicked from this supergroup/channel. |
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.channels.InviteToChannelRequest(
channel='username',
users=['username']
))
print(result.stringify())