Bot API 3.5.
Syfaro syfaro@huefox.com
Fri, 29 Dec 2017 13:22:53 -0600
2 files changed,
77 insertions(+),
3 deletions(-)
M
configs.go
→
configs.go
@@ -1231,6 +1231,7 @@ ProviderToken string // required
StartParameter string // required Currency string // required Prices *[]LabeledPrice // required + ProviderData string PhotoURL string PhotoSize int PhotoWidth int@@ -1258,6 +1259,9 @@ if err != nil {
return v, err } v.Add("prices", string(data)) + if config.ProviderData != "" { + v.Add("provider_data", config.ProviderData) + } if config.PhotoURL != "" { v.Add("photo_url", config.PhotoURL) }@@ -1330,6 +1334,7 @@
// PinChatMessageConfig contains information of a message in a chat to pin. type PinChatMessageConfig struct { ChatID int64 + ChannelUsername string MessageID int DisableNotification bool }@@ -1341,7 +1346,11 @@
func (config PinChatMessageConfig) values() (url.Values, error) { v := url.Values{} - v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + if config.ChannelUsername == "" { + v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + } else { + v.Add("chat_id", config.ChannelUsername) + } v.Add("message_id", strconv.Itoa(config.MessageID)) v.Add("disable_notification", strconv.FormatBool(config.DisableNotification))@@ -1350,7 +1359,8 @@ }
// UnpinChatMessageConfig contains information of chat to unpin. type UnpinChatMessageConfig struct { - ChatID int64 + ChatID int64 + ChannelUsername string } func (config UnpinChatMessageConfig) method() string {@@ -1360,7 +1370,11 @@
func (config UnpinChatMessageConfig) values() (url.Values, error) { v := url.Values{} - v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + if config.ChannelUsername == "" { + v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + } else { + v.Add("chat_id", config.ChannelUsername) + } return v, nil }@@ -1763,3 +1777,42 @@ }
return v, nil } + +// MediaGroupConfig allows you to send a group of media. +// +// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo). +type MediaGroupConfig struct { + ChatID int64 + ChannelUsername string + + Media []interface{} + DisableNotification bool + ReplyToMessageID int +} + +func (config MediaGroupConfig) method() string { + return "sendMediaGroup" +} + +func (config MediaGroupConfig) values() (url.Values, error) { + v := url.Values{} + + if config.ChannelUsername == "" { + v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + } else { + v.Add("chat_id", config.ChannelUsername) + } + bytes, err := json.Marshal(config.Media) + if err != nil { + return v, err + } + v.Add("media", string(bytes)) + if config.DisableNotification { + v.Add("disable_notification", strconv.FormatBool(config.DisableNotification)) + } + if config.ReplyToMessageID != 0 { + v.Add("reply_to_message_id", strconv.Itoa(config.ReplyToMessageID)) + } + + return v, nil +}
M
types.go
→
types.go
@@ -798,3 +798,24 @@ Title string `json:"title"`
ContainsMasks bool `json:"contains_masks"` Stickers []Sticker `json:"stickers"` } + +// InputMediaPhoto is a photo to send as part of a media group. +// +// Telegram recommends to use a file_id instead of uploading. +type InputMediaPhoto struct { + Type string `json:"type"` + Media string `json:"media"` + Caption string `json:"caption"` +} + +// InputMediaVideo is a video to send as part of a media group. +// +// Telegram recommends to use a file_id instead of uploading. +type InputMediaVideo struct { + Type string `json:"type"` + Media string `json:"media"` + Caption string `json:"caption,omitempty"` + Width int `json:"width,omitempty"` + Height int `json:"height,omitempty"` + Duration int `json:"duration,omitempty"` +}