Updates for Bot API 5.4.
@@ -29,6 +29,7 @@ ChatRecordAudio = "record_audio"
// Deprecated: use ChatUploadVoice instead. ChatUploadAudio = "upload_audio" ChatUploadDocument = "upload_document" + ChatChooseSticker = "choose_sticker" ChatFindLocation = "find_location" ChatRecordVideoNote = "record_video_note" ChatUploadVideoNote = "upload_video_note"@@ -1395,8 +1396,10 @@ // must have the appropriate admin rights. The link can be revoked using the
// RevokeChatInviteLinkConfig. type CreateChatInviteLinkConfig struct { ChatConfig - ExpireDate int - MemberLimit int + Name string + ExpireDate int + MemberLimit int + CreatesJoinRequest bool } func (CreateChatInviteLinkConfig) method() string {@@ -1406,9 +1409,11 @@
func (config CreateChatInviteLinkConfig) params() (Params, error) { params := make(Params) + params.AddNonEmpty("name", config.Name) params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) params.AddNonZero("expire_date", config.ExpireDate) params.AddNonZero("member_limit", config.MemberLimit) + params.AddBool("creates_join_request", config.CreatesJoinRequest) return params, nil }@@ -1418,9 +1423,11 @@ // by the bot. The bot must be an administrator in the chat for this to work and
// must have the appropriate admin rights. type EditChatInviteLinkConfig struct { ChatConfig - InviteLink string - ExpireDate int - MemberLimit int + InviteLink string + Name string + ExpireDate int + MemberLimit int + CreatesJoinRequest bool } func (EditChatInviteLinkConfig) method() string {@@ -1431,9 +1438,11 @@ func (config EditChatInviteLinkConfig) params() (Params, error) {
params := make(Params) params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + params.AddNonEmpty("name", config.Name) params["invite_link"] = config.InviteLink params.AddNonZero("expire_date", config.ExpireDate) params.AddNonZero("member_limit", config.MemberLimit) + params.AddBool("creates_join_request", config.CreatesJoinRequest) return params, nil }@@ -1456,6 +1465,44 @@ params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) params["invite_link"] = config.InviteLink + + return params, nil +} + +// ApproveChatJoinRequestConfig allows you to approve a chat join request. +type ApproveChatJoinRequestConfig struct { + ChatConfig + UserID int64 +} + +func (ApproveChatJoinRequestConfig) method() string { + return "approveChatJoinRequest" +} + +func (config ApproveChatJoinRequestConfig) params() (Params, error) { + params := make(Params) + + params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + params.AddNonZero("user_id", int(config.UserID)) + + return params, nil +} + +// DeclineChatJoinRequest allows you to decline a chat join request. +type DeclineChatJoinRequest struct { + ChatConfig + UserID int64 +} + +func (DeclineChatJoinRequest) method() string { + return "declineChatJoinRequest" +} + +func (config DeclineChatJoinRequest) params() (Params, error) { + params := make(Params) + + params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + params.AddNonZero("user_id", int(config.UserID)) return params, nil }
@@ -108,6 +108,12 @@ // in the list of allowed_updates to receive these updates.
// // optional ChatMember *ChatMemberUpdated `json:"chat_member"` + // ChatJoinRequest is a request to join the chat has been sent. The bot must + // have the can_invite_users administrator right in the chat to receive + // these updates. + // + // optional + ChatJoinRequest *ChatJoinRequest `json:"chat_join_request"` } // UpdatesChannel is the channel for getting updates.@@ -1421,10 +1427,19 @@ // administrator, then the second part of the link will be replaced with “…”.
InviteLink string `json:"invite_link"` // Creator of the link. Creator User `json:"creator"` + // CreatesJoinRequest is true if users joining the chat via the link need to + // be approved by chat administrators. + // + // optional + CreatesJoinRequest bool `json:"creates_join_request"` // IsPrimary is true, if the link is primary. IsPrimary bool `json:"is_primary"` // IsRevoked is true, if the link is revoked. IsRevoked bool `json:"is_revoked"` + // Name is the name of the invite link. + // + // optional + Name string `json:"name"` // ExpireDate is the point in time (Unix timestamp) when the link will // expire or has been expired. //@@ -1435,6 +1450,11 @@ // chat simultaneously after joining the chat via this invite link; 1-99999.
// // optional MemberLimit int `json:"member_limit"` + // PendingJoinRequestCount is the number of pending join requests created + // using this link. + // + // optional + PendingJoinRequestCount int `json:"pending_join_request_count"` } // ChatMember contains information about one member of a chat.@@ -1583,6 +1603,24 @@ // New information about the chat member.
NewChatMember ChatMember `json:"new_chat_member"` // InviteLink is the link which was used by the user to join the chat; // for joining by invite link events only. + // + // optional + InviteLink *ChatInviteLink `json:"invite_link"` +} + +// ChatJoinRequest represents a join request sent to a chat. +type ChatJoinRequest struct { + // Chat to which the request was sent. + Chat Chat `json:"chat"` + // User that sent the join request. + From User `json:"user"` + // Date the request was sent in Unix time. + Date int `json:"date"` + // Bio of the user. + // + // optional + Bio string `json:"bio"` + // InviteLink is the link that was used by the user to send the join request. // // optional InviteLink *ChatInviteLink `json:"invite_link"`