Updates for Bot API 5.4.
parent
309d612d70
commit
04f547ba7c
57
configs.go
57
configs.go
|
@ -29,6 +29,7 @@ const (
|
||||||
// Deprecated: use ChatUploadVoice instead.
|
// Deprecated: use ChatUploadVoice instead.
|
||||||
ChatUploadAudio = "upload_audio"
|
ChatUploadAudio = "upload_audio"
|
||||||
ChatUploadDocument = "upload_document"
|
ChatUploadDocument = "upload_document"
|
||||||
|
ChatChooseSticker = "choose_sticker"
|
||||||
ChatFindLocation = "find_location"
|
ChatFindLocation = "find_location"
|
||||||
ChatRecordVideoNote = "record_video_note"
|
ChatRecordVideoNote = "record_video_note"
|
||||||
ChatUploadVideoNote = "upload_video_note"
|
ChatUploadVideoNote = "upload_video_note"
|
||||||
|
@ -1395,8 +1396,10 @@ func (config ChatInviteLinkConfig) params() (Params, error) {
|
||||||
// RevokeChatInviteLinkConfig.
|
// RevokeChatInviteLinkConfig.
|
||||||
type CreateChatInviteLinkConfig struct {
|
type CreateChatInviteLinkConfig struct {
|
||||||
ChatConfig
|
ChatConfig
|
||||||
ExpireDate int
|
Name string
|
||||||
MemberLimit int
|
ExpireDate int
|
||||||
|
MemberLimit int
|
||||||
|
CreatesJoinRequest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (CreateChatInviteLinkConfig) method() string {
|
func (CreateChatInviteLinkConfig) method() string {
|
||||||
|
@ -1406,9 +1409,11 @@ func (CreateChatInviteLinkConfig) method() string {
|
||||||
func (config CreateChatInviteLinkConfig) params() (Params, error) {
|
func (config CreateChatInviteLinkConfig) params() (Params, error) {
|
||||||
params := make(Params)
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddNonEmpty("name", config.Name)
|
||||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
params.AddNonZero("expire_date", config.ExpireDate)
|
params.AddNonZero("expire_date", config.ExpireDate)
|
||||||
params.AddNonZero("member_limit", config.MemberLimit)
|
params.AddNonZero("member_limit", config.MemberLimit)
|
||||||
|
params.AddBool("creates_join_request", config.CreatesJoinRequest)
|
||||||
|
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
@ -1418,9 +1423,11 @@ func (config CreateChatInviteLinkConfig) params() (Params, error) {
|
||||||
// must have the appropriate admin rights.
|
// must have the appropriate admin rights.
|
||||||
type EditChatInviteLinkConfig struct {
|
type EditChatInviteLinkConfig struct {
|
||||||
ChatConfig
|
ChatConfig
|
||||||
InviteLink string
|
InviteLink string
|
||||||
ExpireDate int
|
Name string
|
||||||
MemberLimit int
|
ExpireDate int
|
||||||
|
MemberLimit int
|
||||||
|
CreatesJoinRequest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EditChatInviteLinkConfig) method() string {
|
func (EditChatInviteLinkConfig) method() string {
|
||||||
|
@ -1431,9 +1438,11 @@ func (config EditChatInviteLinkConfig) params() (Params, error) {
|
||||||
params := make(Params)
|
params := make(Params)
|
||||||
|
|
||||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonEmpty("name", config.Name)
|
||||||
params["invite_link"] = config.InviteLink
|
params["invite_link"] = config.InviteLink
|
||||||
params.AddNonZero("expire_date", config.ExpireDate)
|
params.AddNonZero("expire_date", config.ExpireDate)
|
||||||
params.AddNonZero("member_limit", config.MemberLimit)
|
params.AddNonZero("member_limit", config.MemberLimit)
|
||||||
|
params.AddBool("creates_join_request", config.CreatesJoinRequest)
|
||||||
|
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
@ -1460,6 +1469,44 @@ func (config RevokeChatInviteLinkConfig) params() (Params, error) {
|
||||||
return params, nil
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// LeaveChatConfig allows you to leave a chat.
|
// LeaveChatConfig allows you to leave a chat.
|
||||||
type LeaveChatConfig struct {
|
type LeaveChatConfig struct {
|
||||||
ChatID int64
|
ChatID int64
|
||||||
|
|
38
types.go
38
types.go
|
@ -108,6 +108,12 @@ type Update struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ChatMember *ChatMemberUpdated `json:"chat_member"`
|
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.
|
// UpdatesChannel is the channel for getting updates.
|
||||||
|
@ -1421,10 +1427,19 @@ type ChatInviteLink struct {
|
||||||
InviteLink string `json:"invite_link"`
|
InviteLink string `json:"invite_link"`
|
||||||
// Creator of the link.
|
// Creator of the link.
|
||||||
Creator User `json:"creator"`
|
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 is true, if the link is primary.
|
||||||
IsPrimary bool `json:"is_primary"`
|
IsPrimary bool `json:"is_primary"`
|
||||||
// IsRevoked is true, if the link is revoked.
|
// IsRevoked is true, if the link is revoked.
|
||||||
IsRevoked bool `json:"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
|
// ExpireDate is the point in time (Unix timestamp) when the link will
|
||||||
// expire or has been expired.
|
// expire or has been expired.
|
||||||
//
|
//
|
||||||
|
@ -1435,6 +1450,11 @@ type ChatInviteLink struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
MemberLimit int `json:"member_limit"`
|
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.
|
// ChatMember contains information about one member of a chat.
|
||||||
|
@ -1588,6 +1608,24 @@ type ChatMemberUpdated struct {
|
||||||
InviteLink *ChatInviteLink `json:"invite_link"`
|
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"`
|
||||||
|
}
|
||||||
|
|
||||||
// ChatPermissions describes actions that a non-administrator user is
|
// ChatPermissions describes actions that a non-administrator user is
|
||||||
// allowed to take in a chat. All fields are optional.
|
// allowed to take in a chat. All fields are optional.
|
||||||
type ChatPermissions struct {
|
type ChatPermissions struct {
|
||||||
|
|
Loading…
Reference in New Issue