Implement Bot API 6.3 changes.
parent
4126fa6112
commit
797f683a71
163
configs.go
163
configs.go
|
@ -265,6 +265,7 @@ func (CloseConfig) params() (Params, error) {
|
|||
// BaseChat is base type for all chat config types.
|
||||
type BaseChat struct {
|
||||
ChatID int64 // required
|
||||
MessageThreadID int
|
||||
ChannelUsername string
|
||||
ProtectContent bool
|
||||
ReplyToMessageID int
|
||||
|
@ -277,6 +278,7 @@ func (chat *BaseChat) params() (Params, error) {
|
|||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
|
||||
params.AddNonZero("message_thread_id", chat.MessageThreadID)
|
||||
params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
|
||||
params.AddBool("disable_notification", chat.DisableNotification)
|
||||
params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
|
||||
|
@ -1383,6 +1385,7 @@ type PromoteChatMemberConfig struct {
|
|||
CanRestrictMembers bool
|
||||
CanPinMessages bool
|
||||
CanPromoteMembers bool
|
||||
CanManageTopics bool
|
||||
}
|
||||
|
||||
func (config PromoteChatMemberConfig) method() string {
|
||||
|
@ -1406,6 +1409,7 @@ func (config PromoteChatMemberConfig) params() (Params, error) {
|
|||
params.AddBool("can_restrict_members", config.CanRestrictMembers)
|
||||
params.AddBool("can_pin_messages", config.CanPinMessages)
|
||||
params.AddBool("can_promote_members", config.CanPromoteMembers)
|
||||
params.AddBool("can_manage_topics", config.CanManageTopics)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
@ -2220,16 +2224,158 @@ func (config DeleteChatStickerSetConfig) params() (Params, error) {
|
|||
return params, nil
|
||||
}
|
||||
|
||||
// GetForumTopicIconStickersConfig allows you to get custom emoji stickers,
|
||||
// which can be used as a forum topic icon by any user.
|
||||
type GetForumTopicIconStickersConfig struct{}
|
||||
|
||||
func (config GetForumTopicIconStickersConfig) method() string {
|
||||
return "getForumTopicIconStickers"
|
||||
}
|
||||
|
||||
func (config GetForumTopicIconStickersConfig) params() (Params, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// CreateForumTopicConfig allows you to create a topic
|
||||
// in a forum supergroup chat.
|
||||
type CreateForumTopicConfig struct {
|
||||
ChatID int64
|
||||
Name string
|
||||
IconColor int
|
||||
IconCustomEmojiID string
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config CreateForumTopicConfig) method() string {
|
||||
return "createForumTopic"
|
||||
}
|
||||
|
||||
func (config CreateForumTopicConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonEmpty("name", config.Name)
|
||||
params.AddNonZero("icon_color", config.IconColor)
|
||||
params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// EditForumTopicConfig allows you to edit
|
||||
// name and icon of a topic in a forum supergroup chat.
|
||||
type EditForumTopicConfig struct {
|
||||
ChatID int64
|
||||
MessageThreadID int
|
||||
Name string
|
||||
IconCustomEmojiID string
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config EditForumTopicConfig) method() string {
|
||||
return "editForumTopic"
|
||||
}
|
||||
|
||||
func (config EditForumTopicConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||
params.AddNonEmpty("icon_color", config.Name)
|
||||
params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// CloseForumTopicConfig allows you to close
|
||||
// an open topic in a forum supergroup chat.
|
||||
type CloseForumTopicConfig struct {
|
||||
ChatID int64
|
||||
MessageThreadID int
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config CloseForumTopicConfig) method() string {
|
||||
return "closeForumTopic"
|
||||
}
|
||||
|
||||
func (config CloseForumTopicConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReopenForumTopicConfig allows you to reopen
|
||||
// an closed topic in a forum supergroup chat.
|
||||
type ReopenForumTopicConfig struct {
|
||||
ChatID int64
|
||||
MessageThreadID int
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config ReopenForumTopicConfig) method() string {
|
||||
return "reopenForumTopic"
|
||||
}
|
||||
|
||||
func (config ReopenForumTopicConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// DeleteForumTopicConfig allows you to delete a forum topic
|
||||
// along with all its messages in a forum supergroup chat.
|
||||
type DeleteForumTopicConfig struct {
|
||||
ChatID int64
|
||||
MessageThreadID int
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config DeleteForumTopicConfig) method() string {
|
||||
return "deleteForumTopic"
|
||||
}
|
||||
|
||||
func (config DeleteForumTopicConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UnpinAllForumTopicMessagesConfig allows you to clear the list
|
||||
// of pinned messages in a forum topic.
|
||||
type UnpinAllForumTopicMessagesConfig struct {
|
||||
ChatID int64
|
||||
MessageThreadID int
|
||||
SuperGroupUsername string
|
||||
}
|
||||
|
||||
func (config UnpinAllForumTopicMessagesConfig) method() string {
|
||||
return "unpinAllForumTopicMessages"
|
||||
}
|
||||
|
||||
func (config UnpinAllForumTopicMessagesConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// MediaGroupConfig allows you to send a group of media.
|
||||
//
|
||||
// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
|
||||
type MediaGroupConfig struct {
|
||||
ChatID int64
|
||||
ChannelUsername string
|
||||
|
||||
BaseChat
|
||||
Media []interface{}
|
||||
DisableNotification bool
|
||||
ReplyToMessageID int
|
||||
}
|
||||
|
||||
func (config MediaGroupConfig) method() string {
|
||||
|
@ -2237,13 +2383,16 @@ func (config MediaGroupConfig) method() string {
|
|||
}
|
||||
|
||||
func (config MediaGroupConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
params, err := config.BaseChat.params()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
|
||||
params.AddBool("disable_notification", config.DisableNotification)
|
||||
params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
|
||||
|
||||
err := params.AddInterface("media", prepareInputMediaForParams(config.Media))
|
||||
err = params.AddInterface("media", prepareInputMediaForParams(config.Media))
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
|
|
@ -178,7 +178,9 @@ func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
|
|||
// two to ten InputMediaPhoto or InputMediaVideo.
|
||||
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
|
||||
return MediaGroupConfig{
|
||||
ChatID: chatID,
|
||||
BaseChat: BaseChat{
|
||||
ChatID: chatID,
|
||||
},
|
||||
Media: files,
|
||||
}
|
||||
}
|
||||
|
|
88
types.go
88
types.go
|
@ -261,8 +261,22 @@ type Chat struct {
|
|||
//
|
||||
// optional
|
||||
LastName string `json:"last_name,omitempty"`
|
||||
// IsForum is true if the supergroup chat is a forum (has topics enabled)
|
||||
//
|
||||
// optional
|
||||
IsForum bool `json:"is_forum,omitempty"`
|
||||
// Photo is a chat photo
|
||||
Photo *ChatPhoto `json:"photo"`
|
||||
// If non-empty, the list of all active chat usernames;
|
||||
// for private chats, supergroups and channels. Returned only in getChat.
|
||||
//
|
||||
// optional
|
||||
ActiveUsernames []string `json:"active_usernames,omitempty"`
|
||||
// Custom emoji identifier of emoji status of the other party
|
||||
// in a private chat. Returned only in getChat.
|
||||
//
|
||||
// optional
|
||||
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
|
||||
// Bio is the bio of the other party in a private chat. Returned only in
|
||||
// getChat
|
||||
//
|
||||
|
@ -361,6 +375,11 @@ func (c Chat) ChatConfig() ChatConfig {
|
|||
type Message struct {
|
||||
// MessageID is a unique message identifier inside this chat
|
||||
MessageID int `json:"message_id"`
|
||||
// Unique identifier of a message thread to which the message belongs;
|
||||
// for supergroups only
|
||||
//
|
||||
// optional
|
||||
MessageThreadID int `json:"message_thread_id,omitempty"`
|
||||
// From is a sender, empty for messages sent to channels;
|
||||
//
|
||||
// optional
|
||||
|
@ -404,6 +423,10 @@ type Message struct {
|
|||
//
|
||||
// optional
|
||||
ForwardDate int `json:"forward_date,omitempty"`
|
||||
// IsTopicMessage true if the message is sent to a forum topic
|
||||
//
|
||||
// optional
|
||||
IsTopicMessage bool `json:"is_topic_message,omitempty"`
|
||||
// IsAutomaticForward is true if the message is a channel post that was
|
||||
// automatically forwarded to the connected discussion group.
|
||||
//
|
||||
|
@ -608,6 +631,18 @@ type Message struct {
|
|||
//
|
||||
// optional
|
||||
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
|
||||
// ForumTopicCreated is a service message: forum topic created
|
||||
//
|
||||
// optional
|
||||
ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"`
|
||||
// ForumTopicClosed is a service message: forum topic closed
|
||||
//
|
||||
// optional
|
||||
ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"`
|
||||
// ForumTopicReopened is a service message: forum topic reopened
|
||||
//
|
||||
// optional
|
||||
ForumTopicReopened *ForumTopicReopened `json:"forum_topic_reopened,omitempty"`
|
||||
// VideoChatScheduled is a service message: video chat scheduled.
|
||||
//
|
||||
// optional
|
||||
|
@ -1181,6 +1216,30 @@ type MessageAutoDeleteTimerChanged struct {
|
|||
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
|
||||
}
|
||||
|
||||
// ForumTopicCreated represents a service message about a new forum topic
|
||||
// created in the chat.
|
||||
type ForumTopicCreated struct {
|
||||
// Name is the name of topic
|
||||
Name string `json:"name"`
|
||||
// IconColor is the color of the topic icon in RGB format
|
||||
IconColor int `json:"icon_color"`
|
||||
// IconCustomEmojiID is the unique identifier of the custom emoji
|
||||
// shown as the topic icon
|
||||
//
|
||||
// optional
|
||||
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
||||
}
|
||||
|
||||
// ForumTopicClosed represents a service message about a forum topic
|
||||
// closed in the chat. Currently holds no information.
|
||||
type ForumTopicClosed struct {
|
||||
}
|
||||
|
||||
// ForumTopicReopened represents a service message about a forum topic
|
||||
// reopened in the chat. Currently holds no information.
|
||||
type ForumTopicReopened struct {
|
||||
}
|
||||
|
||||
// VideoChatScheduled represents a service message about a voice chat scheduled
|
||||
// in the chat.
|
||||
type VideoChatScheduled struct {
|
||||
|
@ -1591,6 +1650,7 @@ type ChatAdministratorRights struct {
|
|||
CanPostMessages bool `json:"can_post_messages"`
|
||||
CanEditMessages bool `json:"can_edit_messages"`
|
||||
CanPinMessages bool `json:"can_pin_messages"`
|
||||
CanManageTopics bool `json:"can_manage_topics"`
|
||||
}
|
||||
|
||||
// ChatMember contains information about one member of a chat.
|
||||
|
@ -1682,7 +1742,13 @@ type ChatMember struct {
|
|||
// True, if the user is allowed to pin messages; groups and supergroups only
|
||||
//
|
||||
// optional
|
||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||
// CanManageTopics administrators and restricted only.
|
||||
// True, if the user is allowed to create, rename,
|
||||
// close, and reopen forum topics; supergroups only
|
||||
//
|
||||
// optional
|
||||
CanManageTopics bool `json:"can_manage_topics,omitempty"`
|
||||
// IsMember is true, if the user is a member of the chat at the moment of
|
||||
// the request
|
||||
IsMember bool `json:"is_member"`
|
||||
|
@ -1806,6 +1872,11 @@ type ChatPermissions struct {
|
|||
//
|
||||
// optional
|
||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||
// CanManageTopics is true, if the user is allowed to create forum topics.
|
||||
// If omitted defaults to the value of can_pin_messages
|
||||
//
|
||||
// optional
|
||||
CanManageTopics bool `json:"can_manage_topics,omitempty"`
|
||||
}
|
||||
|
||||
// ChatLocation represents a location to which a chat is connected.
|
||||
|
@ -1818,6 +1889,21 @@ type ChatLocation struct {
|
|||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
// ForumTopic represents a forum topic.
|
||||
type ForumTopic struct {
|
||||
// MessageThreadID is the unique identifier of the forum topic
|
||||
MessageThreadID int `json:"message_thread_id"`
|
||||
// Name is the name of the topic
|
||||
Name string `json:"name"`
|
||||
// IconColor is the color of the topic icon in RGB format
|
||||
IconColor int `json:"icon_color"`
|
||||
// IconCustomEmojiID is the unique identifier of the custom emoji
|
||||
// shown as the topic icon
|
||||
//
|
||||
// optional
|
||||
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
||||
}
|
||||
|
||||
// BotCommand represents a bot command.
|
||||
type BotCommand struct {
|
||||
// Command text of the command, 1-32 characters.
|
||||
|
|
Loading…
Reference in New Issue