Skip to main content

messages.addChatUser

Adds a user to a chat and sends a service message on it.

func (c *Client) MessagesAddChatUser(ctx context.Context, request *MessagesAddChatUserRequest) (*MessagesInvitedUsers, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesAddChatUser(ctx, &tg.MessagesAddChatUserRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesInvitedUsers
return nil
})

Parameters

NameTypeRequiredDescription
ChatIDint64yesChat ID
UserIDInputUserClassyesUser ID to be added
FwdLimitintyesNumber of last messages to be forwarded

Returns

*MessagesInvitedUsers

Possible errors

CodeTypeDescription
400BOT_GROUPS_BLOCKEDThis bot can't be added to groups.
403CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400CHAT_INVALIDInvalid chat.
400CHAT_MEMBER_ADD_FAILEDCould not add participants.
403CHAT_WRITE_FORBIDDENYou can't write in this chat.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
400USERS_TOO_MUCHThe maximum number of users has been exceeded (to create a chat, for example).
400USER_ALREADY_PARTICIPANTThe user is already in the group.
400USER_ID_INVALIDThe provided user ID is invalid.
400USER_IS_BLOCKEDYou were blocked by this user.
403USER_NOT_MUTUAL_CONTACTThe provided user is not a mutual contact.
403USER_PRIVACY_RESTRICTEDThe user's privacy settings do not allow you to do this.
400YOU_BLOCKED_USERYou blocked this user.

References