Updates for Bot API 5.0.

bot-api-6.1
Syfaro 2020-11-05 16:53:37 -05:00
parent 18c023f584
commit ac5306ce0c
4 changed files with 358 additions and 141 deletions

View File

@ -477,7 +477,7 @@ func TestSetWebhookWithCert(t *testing.T) {
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
bot.Request(RemoveWebhookConfig{}) bot.Request(DeleteWebhookConfig{})
wh := NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem") wh := NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem")
_, err := bot.Request(wh) _, err := bot.Request(wh)
@ -491,7 +491,7 @@ func TestSetWebhookWithCert(t *testing.T) {
t.Error(err) t.Error(err)
} }
bot.Request(RemoveWebhookConfig{}) bot.Request(DeleteWebhookConfig{})
} }
func TestSetWebhookWithoutCert(t *testing.T) { func TestSetWebhookWithoutCert(t *testing.T) {
@ -499,7 +499,7 @@ func TestSetWebhookWithoutCert(t *testing.T) {
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
bot.Request(RemoveWebhookConfig{}) bot.Request(DeleteWebhookConfig{})
wh := NewWebhook("https://example.com/tgbotapi-test/" + bot.Token) wh := NewWebhook("https://example.com/tgbotapi-test/" + bot.Token)
_, err := bot.Request(wh) _, err := bot.Request(wh)
@ -519,7 +519,7 @@ func TestSetWebhookWithoutCert(t *testing.T) {
t.Errorf("failed to set webhook: %s", info.LastErrorMessage) t.Errorf("failed to set webhook: %s", info.LastErrorMessage)
} }
bot.Request(RemoveWebhookConfig{}) bot.Request(DeleteWebhookConfig{})
} }
func TestSendWithMediaGroup(t *testing.T) { func TestSendWithMediaGroup(t *testing.T) {

View File

@ -63,13 +63,41 @@ type Fileable interface {
useExistingFile() bool useExistingFile() bool
} }
// LogOutConfig is a request to log out of the cloud Bot API server.
//
// Note that you may not log back in for at least 10 minutes.
type LogOutConfig struct{}
func (LogOutConfig) method() string {
return "logOut"
}
func (LogOutConfig) params() (Params, error) {
return nil, nil
}
// CloseConfig is a request to close the bot instance on a local server.
//
// Note that you may not close an instance for the first 10 minutes after the
// bot has started.
type CloseConfig struct{}
func (CloseConfig) method() string {
return "close"
}
func (CloseConfig) params() (Params, error) {
return nil, nil
}
// BaseChat is base type for all chat config types. // BaseChat is base type for all chat config types.
type BaseChat struct { type BaseChat struct {
ChatID int64 // required ChatID int64 // required
ChannelUsername string ChannelUsername string
ReplyToMessageID int ReplyToMessageID int
ReplyMarkup interface{} ReplyMarkup interface{}
DisableNotification bool DisableNotification bool
AllowSendingWithoutReply bool
} }
func (chat *BaseChat) params() (Params, error) { func (chat *BaseChat) params() (Params, error) {
@ -78,6 +106,7 @@ func (chat *BaseChat) params() (Params, error) {
params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername) params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID) params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
params.AddBool("disable_notification", chat.DisableNotification) params.AddBool("disable_notification", chat.DisableNotification)
params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
err := params.AddInterface("reply_markup", chat.ReplyMarkup) err := params.AddInterface("reply_markup", chat.ReplyMarkup)
@ -140,6 +169,7 @@ type MessageConfig struct {
BaseChat BaseChat
Text string Text string
ParseMode string ParseMode string
Entities []MessageEntity
DisableWebPagePreview bool DisableWebPagePreview bool
} }
@ -152,8 +182,9 @@ func (config MessageConfig) params() (Params, error) {
params.AddNonEmpty("text", config.Text) params.AddNonEmpty("text", config.Text)
params.AddBool("disable_web_page_preview", config.DisableWebPagePreview) params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("entities", config.Entities)
return params, nil return params, err
} }
func (config MessageConfig) method() string { func (config MessageConfig) method() string {
@ -184,19 +215,50 @@ func (config ForwardConfig) method() string {
return "forwardMessage" return "forwardMessage"
} }
// CopyMessageConfig contains information about a copyMessage request.
type CopyMessageConfig struct {
BaseChat
FromChatID int64
FromChannelUsername string
MessageID int
Caption string
ParseMode string
CaptionEntities []MessageEntity
}
func (config CopyMessageConfig) params() (Params, error) {
params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddFirstValid("from_chat_id", config.FromChatID, config.FromChannelUsername)
params.AddNonZero("message_id", config.MessageID)
params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err
}
// PhotoConfig contains information about a SendPhoto request. // PhotoConfig contains information about a SendPhoto request.
type PhotoConfig struct { type PhotoConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string ParseMode string
CaptionEntities []MessageEntity
} }
func (config PhotoConfig) params() (Params, error) { func (config PhotoConfig) params() (Params, error) {
params, err := config.BaseFile.params() params, err := config.BaseFile.params()
if err != nil {
return params, err
}
params.AddNonEmpty(config.name(), config.FileID) params.AddNonEmpty(config.name(), config.FileID)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err return params, err
} }
@ -212,11 +274,12 @@ func (config PhotoConfig) method() string {
// AudioConfig contains information about a SendAudio request. // AudioConfig contains information about a SendAudio request.
type AudioConfig struct { type AudioConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string ParseMode string
Duration int CaptionEntities []MessageEntity
Performer string Duration int
Title string Performer string
Title string
} }
func (config AudioConfig) params() (Params, error) { func (config AudioConfig) params() (Params, error) {
@ -231,8 +294,9 @@ func (config AudioConfig) params() (Params, error) {
params.AddNonEmpty("title", config.Title) params.AddNonEmpty("title", config.Title)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, nil return params, err
} }
func (config AudioConfig) name() string { func (config AudioConfig) name() string {
@ -246,8 +310,10 @@ func (config AudioConfig) method() string {
// DocumentConfig contains information about a SendDocument request. // DocumentConfig contains information about a SendDocument request.
type DocumentConfig struct { type DocumentConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string ParseMode string
CaptionEntities []MessageEntity
DisableContentTypeDetection bool
} }
func (config DocumentConfig) params() (Params, error) { func (config DocumentConfig) params() (Params, error) {
@ -256,6 +322,7 @@ func (config DocumentConfig) params() (Params, error) {
params.AddNonEmpty(config.name(), config.FileID) params.AddNonEmpty(config.name(), config.FileID)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("disable_content_type_detection", config.DisableContentTypeDetection)
return params, err return params, err
} }
@ -295,17 +362,22 @@ type VideoConfig struct {
Duration int Duration int
Caption string Caption string
ParseMode string ParseMode string
CaptionEntities []MessageEntity
SupportsStreaming bool SupportsStreaming bool
} }
func (config VideoConfig) params() (Params, error) { func (config VideoConfig) params() (Params, error) {
params, err := config.BaseChat.params() params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty(config.name(), config.FileID) params.AddNonEmpty(config.name(), config.FileID)
params.AddNonZero("duration", config.Duration) params.AddNonZero("duration", config.Duration)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("supports_streaming", config.SupportsStreaming) params.AddBool("supports_streaming", config.SupportsStreaming)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err return params, err
} }
@ -321,18 +393,23 @@ func (config VideoConfig) method() string {
// AnimationConfig contains information about a SendAnimation request. // AnimationConfig contains information about a SendAnimation request.
type AnimationConfig struct { type AnimationConfig struct {
BaseFile BaseFile
Duration int Duration int
Caption string Caption string
ParseMode string ParseMode string
CaptionEntities []MessageEntity
} }
func (config AnimationConfig) params() (Params, error) { func (config AnimationConfig) params() (Params, error) {
params, err := config.BaseChat.params() params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty(config.name(), config.FileID) params.AddNonEmpty(config.name(), config.FileID)
params.AddNonZero("duration", config.Duration) params.AddNonZero("duration", config.Duration)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err return params, err
} }
@ -373,18 +450,23 @@ func (config VideoNoteConfig) method() string {
// VoiceConfig contains information about a SendVoice request. // VoiceConfig contains information about a SendVoice request.
type VoiceConfig struct { type VoiceConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string ParseMode string
Duration int CaptionEntities []MessageEntity
Duration int
} }
func (config VoiceConfig) params() (Params, error) { func (config VoiceConfig) params() (Params, error) {
params, err := config.BaseChat.params() params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty(config.name(), config.FileID) params.AddNonEmpty(config.name(), config.FileID)
params.AddNonZero("duration", config.Duration) params.AddNonZero("duration", config.Duration)
params.AddNonEmpty("caption", config.Caption) params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err return params, err
} }
@ -400,9 +482,12 @@ func (config VoiceConfig) method() string {
// LocationConfig contains information about a SendLocation request. // LocationConfig contains information about a SendLocation request.
type LocationConfig struct { type LocationConfig struct {
BaseChat BaseChat
Latitude float64 // required Latitude float64 // required
Longitude float64 // required Longitude float64 // required
LivePeriod int // optional HorizontalAccuracy float64 // optional
LivePeriod int // optional
Heading int // optional
ProximityAlertRadius int // optional
} }
func (config LocationConfig) params() (Params, error) { func (config LocationConfig) params() (Params, error) {
@ -410,7 +495,10 @@ func (config LocationConfig) params() (Params, error) {
params.AddNonZeroFloat("latitude", config.Latitude) params.AddNonZeroFloat("latitude", config.Latitude)
params.AddNonZeroFloat("longitude", config.Longitude) params.AddNonZeroFloat("longitude", config.Longitude)
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
params.AddNonZero("live_period", config.LivePeriod) params.AddNonZero("live_period", config.LivePeriod)
params.AddNonZero("heading", config.Heading)
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
return params, err return params, err
} }
@ -422,8 +510,11 @@ func (config LocationConfig) method() string {
// EditMessageLiveLocationConfig allows you to update a live location. // EditMessageLiveLocationConfig allows you to update a live location.
type EditMessageLiveLocationConfig struct { type EditMessageLiveLocationConfig struct {
BaseEdit BaseEdit
Latitude float64 // required Latitude float64 // required
Longitude float64 // required Longitude float64 // required
HorizontalAccuracy float64 // optional
Heading int // optional
ProximityAlertRadius int // optional
} }
func (config EditMessageLiveLocationConfig) params() (Params, error) { func (config EditMessageLiveLocationConfig) params() (Params, error) {
@ -431,6 +522,9 @@ func (config EditMessageLiveLocationConfig) params() (Params, error) {
params.AddNonZeroFloat("latitude", config.Latitude) params.AddNonZeroFloat("latitude", config.Latitude)
params.AddNonZeroFloat("longitude", config.Longitude) params.AddNonZeroFloat("longitude", config.Longitude)
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
params.AddNonZero("heading", config.Heading)
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
return params, err return params, err
} }
@ -455,11 +549,14 @@ func (config StopMessageLiveLocationConfig) method() string {
// VenueConfig contains information about a SendVenue request. // VenueConfig contains information about a SendVenue request.
type VenueConfig struct { type VenueConfig struct {
BaseChat BaseChat
Latitude float64 // required Latitude float64 // required
Longitude float64 // required Longitude float64 // required
Title string // required Title string // required
Address string // required Address string // required
FoursquareID string FoursquareID string
FoursquareType string
GooglePlaceID string
GooglePlaceType string
} }
func (config VenueConfig) params() (Params, error) { func (config VenueConfig) params() (Params, error) {
@ -470,6 +567,9 @@ func (config VenueConfig) params() (Params, error) {
params["title"] = config.Title params["title"] = config.Title
params["address"] = config.Address params["address"] = config.Address
params.AddNonEmpty("foursquare_id", config.FoursquareID) params.AddNonEmpty("foursquare_id", config.FoursquareID)
params.AddNonEmpty("foursquare_type", config.FoursquareType)
params.AddNonEmpty("google_place_id", config.GooglePlaceID)
params.AddNonEmpty("google_place_type", config.GooglePlaceType)
return params, err return params, err
} }
@ -514,6 +614,7 @@ type SendPollConfig struct {
CorrectOptionID int64 CorrectOptionID int64
Explanation string Explanation string
ExplanationParseMode string ExplanationParseMode string
ExplanationEntities []MessageEntity
OpenPeriod int OpenPeriod int
CloseDate int CloseDate int
IsClosed bool IsClosed bool
@ -526,7 +627,9 @@ func (config SendPollConfig) params() (Params, error) {
} }
params["question"] = config.Question params["question"] = config.Question
err = params.AddInterface("options", config.Options) if err = params.AddInterface("options", config.Options); err != nil {
return params, err
}
params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous) params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous)
params.AddNonEmpty("type", config.Type) params.AddNonEmpty("type", config.Type)
params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers) params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
@ -536,6 +639,7 @@ func (config SendPollConfig) params() (Params, error) {
params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode) params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode)
params.AddNonZero("open_period", config.OpenPeriod) params.AddNonZero("open_period", config.OpenPeriod)
params.AddNonZero("close_date", config.CloseDate) params.AddNonZero("close_date", config.CloseDate)
err = params.AddInterface("explanation_entities", config.ExplanationEntities)
return params, err return params, err
} }
@ -646,15 +750,20 @@ type EditMessageTextConfig struct {
BaseEdit BaseEdit
Text string Text string
ParseMode string ParseMode string
Entities []MessageEntity
DisableWebPagePreview bool DisableWebPagePreview bool
} }
func (config EditMessageTextConfig) params() (Params, error) { func (config EditMessageTextConfig) params() (Params, error) {
params, err := config.BaseEdit.params() params, err := config.BaseEdit.params()
if err != nil {
return params, err
}
params["text"] = config.Text params["text"] = config.Text
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("disable_web_page_preview", config.DisableWebPagePreview) params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
err = params.AddInterface("entities", config.Entities)
return params, err return params, err
} }
@ -666,15 +775,20 @@ func (config EditMessageTextConfig) method() string {
// EditMessageCaptionConfig allows you to modify the caption of a message. // EditMessageCaptionConfig allows you to modify the caption of a message.
type EditMessageCaptionConfig struct { type EditMessageCaptionConfig struct {
BaseEdit BaseEdit
Caption string Caption string
ParseMode string ParseMode string
CaptionEntities []MessageEntity
} }
func (config EditMessageCaptionConfig) params() (Params, error) { func (config EditMessageCaptionConfig) params() (Params, error) {
params, err := config.BaseEdit.params() params, err := config.BaseEdit.params()
if err != nil {
return params, err
}
params["caption"] = config.Caption params["caption"] = config.Caption
params.AddNonEmpty("parse_mode", config.ParseMode) params.AddNonEmpty("parse_mode", config.ParseMode)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err return params, err
} }
@ -791,10 +905,12 @@ func (config UpdateConfig) params() (Params, error) {
// WebhookConfig contains information about a SetWebhook request. // WebhookConfig contains information about a SetWebhook request.
type WebhookConfig struct { type WebhookConfig struct {
URL *url.URL URL *url.URL
Certificate interface{} Certificate interface{}
MaxConnections int IPAddress string
AllowedUpdates []string MaxConnections int
AllowedUpdates []string
DropPendingUpdates bool
} }
func (config WebhookConfig) method() string { func (config WebhookConfig) method() string {
@ -808,8 +924,10 @@ func (config WebhookConfig) params() (Params, error) {
params["url"] = config.URL.String() params["url"] = config.URL.String()
} }
params.AddNonEmpty("ip_address", config.IPAddress)
params.AddNonZero("max_connections", config.MaxConnections) params.AddNonZero("max_connections", config.MaxConnections)
params.AddInterface("allowed_updates", config.AllowedUpdates) params.AddInterface("allowed_updates", config.AllowedUpdates)
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
return params, nil return params, nil
} }
@ -826,16 +944,21 @@ func (config WebhookConfig) useExistingFile() bool {
return config.URL != nil return config.URL != nil
} }
// RemoveWebhookConfig is a helper to remove a webhook. // DeleteWebhookConfig is a helper to delete a webhook.
type RemoveWebhookConfig struct { type DeleteWebhookConfig struct {
DropPendingUpdates bool
} }
func (config RemoveWebhookConfig) method() string { func (config DeleteWebhookConfig) method() string {
return "setWebhook" return "deleteWebhook"
} }
func (config RemoveWebhookConfig) params() (Params, error) { func (config DeleteWebhookConfig) params() (Params, error) {
return nil, nil params := make(Params)
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
return params, nil
} }
// FileBytes contains information about a set of bytes to upload // FileBytes contains information about a set of bytes to upload
@ -923,6 +1046,7 @@ type ChatMemberConfig struct {
// UnbanChatMemberConfig allows you to unban a user. // UnbanChatMemberConfig allows you to unban a user.
type UnbanChatMemberConfig struct { type UnbanChatMemberConfig struct {
ChatMemberConfig ChatMemberConfig
OnlyIfBanned bool
} }
func (config UnbanChatMemberConfig) method() string { func (config UnbanChatMemberConfig) method() string {
@ -934,6 +1058,7 @@ func (config UnbanChatMemberConfig) params() (Params, error) {
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername) params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
params.AddNonZero("user_id", config.UserID) params.AddNonZero("user_id", config.UserID)
params.AddBool("only_if_banned", config.OnlyIfBanned)
return params, nil return params, nil
} }
@ -986,6 +1111,7 @@ func (config RestrictChatMemberConfig) params() (Params, error) {
// PromoteChatMemberConfig contains fields to promote members of chat // PromoteChatMemberConfig contains fields to promote members of chat
type PromoteChatMemberConfig struct { type PromoteChatMemberConfig struct {
ChatMemberConfig ChatMemberConfig
IsAnonymous bool
CanChangeInfo bool CanChangeInfo bool
CanPostMessages bool CanPostMessages bool
CanEditMessages bool CanEditMessages bool
@ -1006,6 +1132,7 @@ func (config PromoteChatMemberConfig) params() (Params, error) {
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername) params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
params.AddNonZero("user_id", config.UserID) params.AddNonZero("user_id", config.UserID)
params.AddBool("is_anonymous", config.IsAnonymous)
params.AddBool("can_change_info", config.CanChangeInfo) params.AddBool("can_change_info", config.CanChangeInfo)
params.AddBool("can_post_messages", config.CanPostMessages) params.AddBool("can_post_messages", config.CanPostMessages)
params.AddBool("can_edit_messages", config.CanEditMessages) params.AddBool("can_edit_messages", config.CanEditMessages)
@ -1281,10 +1408,13 @@ func (config PinChatMessageConfig) params() (Params, error) {
return params, nil return params, nil
} }
// UnpinChatMessageConfig contains information of chat to unpin. // UnpinChatMessageConfig contains information of a chat message to unpin.
//
// If MessageID is not specified, it will unpin the most recent pin.
type UnpinChatMessageConfig struct { type UnpinChatMessageConfig struct {
ChatID int64 ChatID int64
ChannelUsername string ChannelUsername string
MessageID int
} }
func (config UnpinChatMessageConfig) method() string { func (config UnpinChatMessageConfig) method() string {
@ -1294,6 +1424,26 @@ func (config UnpinChatMessageConfig) method() string {
func (config UnpinChatMessageConfig) params() (Params, error) { func (config UnpinChatMessageConfig) params() (Params, error) {
params := make(Params) params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
params.AddNonZero("message_id", config.MessageID)
return params, nil
}
// UnpinAllChatMessagesConfig contains information of all messages to unpin in
// a chat.
type UnpinAllChatMessagesConfig struct {
ChatID int64
ChannelUsername string
}
func (config UnpinAllChatMessagesConfig) method() string {
return "unpinAllChatMessages"
}
func (config UnpinAllChatMessagesConfig) params() (Params, error) {
params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername) params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
return params, nil return params, nil
@ -1680,7 +1830,8 @@ func (config MediaGroupConfig) params() (Params, error) {
// DiceConfig allows you to send a random dice roll to Telegram. // DiceConfig allows you to send a random dice roll to Telegram.
// //
// Emoji may be one of the following: 🎲 (1-6), 🎯 (1-6), 🏀 (1-5). // Emoji may be one of the following: 🎲 (1-6), 🎯 (1-6), 🏀 (1-5), ⚽ (1-5),
// 🎰 (1-64).
type DiceConfig struct { type DiceConfig struct {
BaseChat BaseChat

244
types.go
View File

@ -121,6 +121,7 @@ type Chat struct {
LastName string `json:"last_name,omitempty"` // optional LastName string `json:"last_name,omitempty"` // optional
AllMembersAreAdmins bool `json:"all_members_are_administrators,omitempty"` // deprecated, optional AllMembersAreAdmins bool `json:"all_members_are_administrators,omitempty"` // deprecated, optional
Photo *ChatPhoto `json:"photo,omitempty"` // optional Photo *ChatPhoto `json:"photo,omitempty"` // optional
Bio string `json:"bio,omitempty"` // optional
Description string `json:"description,omitempty"` // optional Description string `json:"description,omitempty"` // optional
InviteLink string `json:"invite_link,omitempty"` // optional InviteLink string `json:"invite_link,omitempty"` // optional
PinnedMessage *Message `json:"pinned_message,omitempty"` // optional PinnedMessage *Message `json:"pinned_message,omitempty"` // optional
@ -128,6 +129,8 @@ type Chat struct {
SlowModeDelay int `json:"slow_mode_delay,omitempty"` // optional SlowModeDelay int `json:"slow_mode_delay,omitempty"` // optional
StickerSetName string `json:"sticker_set_name,omitempty"` // optional StickerSetName string `json:"sticker_set_name,omitempty"` // optional
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` // optional CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` // optional
LinkedChatID int `json:"linked_chat_id,omitempty"` // optional
Location *ChatLocation `json:"location"` // optional
} }
// IsPrivate returns if the Chat is a private conversation. // IsPrivate returns if the Chat is a private conversation.
@ -158,55 +161,57 @@ func (c Chat) ChatConfig() ChatConfig {
// Message is returned by almost every request, and contains data about // Message is returned by almost every request, and contains data about
// almost anything. // almost anything.
type Message struct { type Message struct {
MessageID int `json:"message_id"` MessageID int `json:"message_id"`
From *User `json:"from,omitempty"` // optional From *User `json:"from,omitempty"` // optional
Date int `json:"date"` SenderChat *Chat `json:"sender_chat,omitempty"` // optional
Chat *Chat `json:"chat"` Date int `json:"date"`
ForwardFrom *User `json:"forward_from,omitempty"` // optional Chat *Chat `json:"chat"`
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"` // optional ForwardFrom *User `json:"forward_from,omitempty"` // optional
ForwardFromMessageID int `json:"forward_from_message_id,omitempty"` // optional ForwardFromChat *Chat `json:"forward_from_chat,omitempty"` // optional
ForwardSignature string `json:"forward_signature,omitempty"` // optional ForwardFromMessageID int `json:"forward_from_message_id,omitempty"` // optional
ForwardSenderName string `json:"forward_sender_name,omitempty"` // optional ForwardSignature string `json:"forward_signature,omitempty"` // optional
ForwardDate int `json:"forward_date,omitempty"` // optional ForwardSenderName string `json:"forward_sender_name,omitempty"` // optional
ReplyToMessage *Message `json:"reply_to_message,omitempty"` // optional ForwardDate int `json:"forward_date,omitempty"` // optional
ViaBot *User `json:"via_bot"` // optional ReplyToMessage *Message `json:"reply_to_message,omitempty"` // optional
EditDate int `json:"edit_date,omitempty"` // optional ViaBot *User `json:"via_bot"` // optional
MediaGroupID string `json:"media_group_id,omitempty"` // optional EditDate int `json:"edit_date,omitempty"` // optional
AuthorSignature string `json:"author_signature,omitempty"` // optional MediaGroupID string `json:"media_group_id,omitempty"` // optional
Text string `json:"text,omitempty"` // optional AuthorSignature string `json:"author_signature,omitempty"` // optional
Entities []MessageEntity `json:"entities,omitempty"` // optional Text string `json:"text,omitempty"` // optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` // optional Entities []MessageEntity `json:"entities,omitempty"` // optional
Audio *Audio `json:"audio,omitempty"` // optional Audio *Audio `json:"audio,omitempty"` // optional
Document *Document `json:"document,omitempty"` // optional Document *Document `json:"document,omitempty"` // optional
Animation *ChatAnimation `json:"animation,omitempty"` // optional Animation *ChatAnimation `json:"animation,omitempty"` // optional
Game *Game `json:"game,omitempty"` // optional Photo []PhotoSize `json:"photo,omitempty"` // optional
Photo []PhotoSize `json:"photo,omitempty"` // optional Sticker *Sticker `json:"sticker,omitempty"` // optional
Sticker *Sticker `json:"sticker,omitempty"` // optional Video *Video `json:"video,omitempty"` // optional
Video *Video `json:"video,omitempty"` // optional VideoNote *VideoNote `json:"video_note,omitempty"` // optional
VideoNote *VideoNote `json:"video_note,omitempty"` // optional Voice *Voice `json:"voice,omitempty"` // optional
Voice *Voice `json:"voice,omitempty"` // optional Caption string `json:"caption,omitempty"` // optional
Caption string `json:"caption,omitempty"` // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` // optional
Contact *Contact `json:"contact,omitempty"` // optional Contact *Contact `json:"contact,omitempty"` // optional
Location *Location `json:"location,omitempty"` // optional Dice *Dice `json:"dice,omitempty"` // optional
Venue *Venue `json:"venue,omitempty"` // optional Game *Game `json:"game,omitempty"` // optional
Poll *Poll `json:"poll,omitempty"` // optional Poll *Poll `json:"poll,omitempty"` // optional
Dice *Dice `json:"dice,omitempty"` // optional Venue *Venue `json:"venue,omitempty"` // optional
NewChatMembers []User `json:"new_chat_members,omitempty"` // optional Location *Location `json:"location,omitempty"` // optional
LeftChatMember *User `json:"left_chat_member,omitempty"` // optional NewChatMembers []User `json:"new_chat_members,omitempty"` // optional
NewChatTitle string `json:"new_chat_title,omitempty"` // optional LeftChatMember *User `json:"left_chat_member,omitempty"` // optional
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"` // optional NewChatTitle string `json:"new_chat_title,omitempty"` // optional
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` // optional NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"` // optional
GroupChatCreated bool `json:"group_chat_created,omitempty"` // optional DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` // optional
SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"` // optional GroupChatCreated bool `json:"group_chat_created,omitempty"` // optional
ChannelChatCreated bool `json:"channel_chat_created,omitempty"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"` // optional
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional ChannelChatCreated bool `json:"channel_chat_created,omitempty"` // optional
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"` // optional MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional
PinnedMessage *Message `json:"pinned_message,omitempty"` // optional MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"` // optional
Invoice *Invoice `json:"invoice,omitempty"` // optional PinnedMessage *Message `json:"pinned_message,omitempty"` // optional
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"` // optional Invoice *Invoice `json:"invoice,omitempty"` // optional
ConnectedWebsite string `json:"connected_website,omitempty"` // optional SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"` // optional
PassportData *PassportData `json:"passport_data,omitempty"` // optional ConnectedWebsite string `json:"connected_website,omitempty"` // optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // optional PassportData *PassportData `json:"passport_data,omitempty"` // optional
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"` // optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // optional
} }
// Time converts the message timestamp into a Time. // Time converts the message timestamp into a Time.
@ -363,6 +368,7 @@ type Audio struct {
Duration int `json:"duration"` Duration int `json:"duration"`
Performer string `json:"performer,omitempty"` // optional Performer string `json:"performer,omitempty"` // optional
Title string `json:"title,omitempty"` // optional Title string `json:"title,omitempty"` // optional
FileName string `json:"file_name,omitempty"` // optional
MimeType string `json:"mime_type,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional
FileSize int `json:"file_size,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional
} }
@ -427,6 +433,7 @@ type Video struct {
Height int `json:"height"` Height int `json:"height"`
Duration int `json:"duration"` Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional
FileName string `json:"file_name,omitempty"` // optional
MimeType string `json:"mime_type,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional
FileSize int `json:"file_size,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional
} }
@ -463,16 +470,23 @@ type Contact struct {
// Location contains information about a place. // Location contains information about a place.
type Location struct { type Location struct {
Longitude float64 `json:"longitude"` Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"` Latitude float64 `json:"latitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy"` // optional
LivePeriod int `json:"live_period"` // optional
Heading int `json:"heading"` // optional
ProximityAlertRadius int `json:"proximity_alert_radius"` // optional
} }
// Venue contains information about a venue, including its Location. // Venue contains information about a venue, including its Location.
type Venue struct { type Venue struct {
Location Location `json:"location"` Location Location `json:"location"`
Title string `json:"title"` Title string `json:"title"`
Address string `json:"address"` Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"` // optional FoursquareID string `json:"foursquare_id,omitempty"` // optional
FoursquareType string `json:"foursquare_type,omitempty"` // optional
GooglePlaceID string `json:"google_place_id,omitempty"` // optional
GooglePlaceType string `json:"google_place_type,omitempty"` // optional
} }
// PollOption contains information about one answer option in a poll. // PollOption contains information about one answer option in a poll.
@ -510,6 +524,14 @@ type Dice struct {
Value int `json:"value"` Value int `json:"value"`
} }
// ProximityAlertTriggered represents a service message sent when a user in the
// chat triggers a proximity alert sent by another user.
type ProximityAlertTriggered struct {
Traveler User `json:"traveler"`
Watcher User `json:"watcher"`
Distance int `json:"distance"`
}
// UserProfilePhotos contains a set of user profile photos. // UserProfilePhotos contains a set of user profile photos.
type UserProfilePhotos struct { type UserProfilePhotos struct {
TotalCount int `json:"total_count"` TotalCount int `json:"total_count"`
@ -620,6 +642,7 @@ type ChatMember struct {
User *User `json:"user"` User *User `json:"user"`
Status string `json:"status"` Status string `json:"status"`
CustomTitle string `json:"custom_title,omitempty"` // optional CustomTitle string `json:"custom_title,omitempty"` // optional
IsAnonymous bool `json:"is_anonymous"` // optional
UntilDate int64 `json:"until_date,omitempty"` // optional UntilDate int64 `json:"until_date,omitempty"` // optional
CanBeEdited bool `json:"can_be_edited,omitempty"` // optional CanBeEdited bool `json:"can_be_edited,omitempty"` // optional
CanPostMessages bool `json:"can_post_messages,omitempty"` // optional CanPostMessages bool `json:"can_post_messages,omitempty"` // optional
@ -685,12 +708,14 @@ type CallbackGame struct{}
// WebhookInfo is information about a currently set webhook. // WebhookInfo is information about a currently set webhook.
type WebhookInfo struct { type WebhookInfo struct {
URL string `json:"url"` URL string `json:"url"`
HasCustomCertificate bool `json:"has_custom_certificate"` HasCustomCertificate bool `json:"has_custom_certificate"`
PendingUpdateCount int `json:"pending_update_count"` PendingUpdateCount int `json:"pending_update_count"`
LastErrorDate int `json:"last_error_date"` // optional IPAddress string `json:"ip_address"` // optional
LastErrorMessage string `json:"last_error_message"` // optional LastErrorDate int `json:"last_error_date"` // optional
MaxConnections int `json:"max_connections"` // optional LastErrorMessage string `json:"last_error_message"` // optional
MaxConnections int `json:"max_connections"` // optional
AllowedUpdates []string `json:"allowed_updates"` // optional
} }
// IsSet returns true if a webhook is currently set. // IsSet returns true if a webhook is currently set.
@ -734,6 +759,8 @@ type InlineQueryResultPhoto struct {
Title string `json:"title"` Title string `json:"title"`
Description string `json:"description"` Description string `json:"description"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -747,6 +774,7 @@ type InlineQueryResultCachedPhoto struct {
Description string `json:"description"` Description string `json:"description"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -763,6 +791,8 @@ type InlineQueryResultGIF struct {
Duration int `json:"gif_duration,omitempty"` Duration int `json:"gif_duration,omitempty"`
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
Caption string `json:"caption,omitempty"` Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -776,6 +806,7 @@ type InlineQueryResultCachedGIF struct {
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -791,6 +822,8 @@ type InlineQueryResultMPEG4GIF struct {
ThumbMimeType string `json:"thumb_mime_type"` ThumbMimeType string `json:"thumb_mime_type"`
Title string `json:"title"` Title string `json:"title"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -804,6 +837,7 @@ type InlineQueryResultCachedMpeg4Gif struct {
Title string `json:"title"` Title string `json:"title"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -817,6 +851,8 @@ type InlineQueryResultVideo struct {
ThumbURL string `json:"thumb_url"` ThumbURL string `json:"thumb_url"`
Title string `json:"title"` Title string `json:"title"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Width int `json:"video_width"` Width int `json:"video_width"`
Height int `json:"video_height"` Height int `json:"video_height"`
Duration int `json:"video_duration"` Duration int `json:"video_duration"`
@ -834,6 +870,7 @@ type InlineQueryResultCachedVideo struct {
Description string `json:"description"` Description string `json:"description"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -844,7 +881,6 @@ type InlineQueryResultCachedSticker struct {
ID string `json:"id"` // required ID string `json:"id"` // required
StickerID string `json:"sticker_file_id"` // required StickerID string `json:"sticker_file_id"` // required
Title string `json:"title"` // required Title string `json:"title"` // required
ParseMode string `json:"parse_mode"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -856,6 +892,8 @@ type InlineQueryResultAudio struct {
URL string `json:"audio_url"` // required URL string `json:"audio_url"` // required
Title string `json:"title"` // required Title string `json:"title"` // required
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Performer string `json:"performer"` Performer string `json:"performer"`
Duration int `json:"audio_duration"` Duration int `json:"audio_duration"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -869,6 +907,7 @@ type InlineQueryResultCachedAudio struct {
AudioID string `json:"audio_file_id"` // required AudioID string `json:"audio_file_id"` // required
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -880,6 +919,8 @@ type InlineQueryResultVoice struct {
URL string `json:"voice_url"` // required URL string `json:"voice_url"` // required
Title string `json:"title"` // required Title string `json:"title"` // required
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Duration int `json:"voice_duration"` Duration int `json:"voice_duration"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
@ -893,6 +934,7 @@ type InlineQueryResultCachedVoice struct {
Title string `json:"title"` // required Title string `json:"title"` // required
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
@ -903,6 +945,8 @@ type InlineQueryResultDocument struct {
ID string `json:"id"` // required ID string `json:"id"` // required
Title string `json:"title"` // required Title string `json:"title"` // required
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
URL string `json:"document_url"` // required URL string `json:"document_url"` // required
MimeType string `json:"mime_type"` // required MimeType string `json:"mime_type"` // required
Description string `json:"description"` Description string `json:"description"`
@ -922,23 +966,27 @@ type InlineQueryResultCachedDocument struct {
Caption string `json:"caption"` Caption string `json:"caption"`
Description string `json:"description"` Description string `json:"description"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
} }
// InlineQueryResultLocation is an inline query response location. // InlineQueryResultLocation is an inline query response location.
type InlineQueryResultLocation struct { type InlineQueryResultLocation struct {
Type string `json:"type"` // required Type string `json:"type"` // required
ID string `json:"id"` // required ID string `json:"id"` // required
Latitude float64 `json:"latitude"` // required Latitude float64 `json:"latitude"` // required
Longitude float64 `json:"longitude"` // required Longitude float64 `json:"longitude"` // required
LivePeriod int `json:"live_period"` // optional LivePeriod int `json:"live_period"` // optional
Title string `json:"title"` // required Title string `json:"title"` // required
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` Heading int `json:"heading"`
ThumbURL string `json:"thumb_url"` ProximityAlertRadius int `json:"proximity_alert_radius"`
ThumbWidth int `json:"thumb_width"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
ThumbHeight int `json:"thumb_height"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
ThumbURL string `json:"thumb_url"`
ThumbWidth int `json:"thumb_width"`
ThumbHeight int `json:"thumb_height"`
} }
// InlineQueryResultContact is an inline query response contact. // InlineQueryResultContact is an inline query response contact.
@ -964,8 +1012,10 @@ type InlineQueryResultVenue struct {
Longitude float64 `json:"longitude"` // required Longitude float64 `json:"longitude"` // required
Title string `json:"title"` // required Title string `json:"title"` // required
Address string `json:"address"` // required Address string `json:"address"` // required
FoursquareID string `json:"foursquare_id"` FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type"` FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"`
ThumbURL string `json:"thumb_url"` ThumbURL string `json:"thumb_url"`
@ -993,26 +1043,34 @@ type ChosenInlineResult struct {
// InputTextMessageContent contains text for displaying // InputTextMessageContent contains text for displaying
// as an inline query result. // as an inline query result.
type InputTextMessageContent struct { type InputTextMessageContent struct {
Text string `json:"message_text"` Text string `json:"message_text"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
DisableWebPagePreview bool `json:"disable_web_page_preview"` Entities []MessageEntity `json:"entities,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview"`
} }
// InputLocationMessageContent contains a location for displaying // InputLocationMessageContent contains a location for displaying
// as an inline query result. // as an inline query result.
type InputLocationMessageContent struct { type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"` Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"` Longitude float64 `json:"longitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
LivePeriod int `json:"live_period"`
Heading int `json:"heading"`
ProximityAlertRadius int `json:"proximity_alert_radius"`
} }
// InputVenueMessageContent contains a venue for displaying // InputVenueMessageContent contains a venue for displaying
// as an inline query result. // as an inline query result.
type InputVenueMessageContent struct { type InputVenueMessageContent struct {
Latitude float64 `json:"latitude"` Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"` Longitude float64 `json:"longitude"`
Title string `json:"title"` Title string `json:"title"`
Address string `json:"address"` Address string `json:"address"`
FoursquareID string `json:"foursquare_id"` FoursquareID string `json:"foursquare_id"`
FoursquareType string `json:"foursquare_type"`
GooglePlaceID string `json:"google_place_id"`
GooglePlaceType string `json:"google_place_type"`
} }
// InputContactMessageContent contains a contact for displaying // InputContactMessageContent contains a contact for displaying
@ -1104,6 +1162,12 @@ type StickerSet struct {
Thumb *PhotoSize `json:"thumb"` Thumb *PhotoSize `json:"thumb"`
} }
// ChatLocation represents a location to which a chat is connected.
type ChatLocation struct {
Location Location `json:"location"`
Address string `json:"address"`
}
// BotCommand represents Telegram's understanding of a command. // BotCommand represents Telegram's understanding of a command.
type BotCommand struct { type BotCommand struct {
Command string `json:"command"` Command string `json:"command"`
@ -1112,10 +1176,11 @@ type BotCommand struct {
// BaseInputMedia is a base type for the InputMedia types. // BaseInputMedia is a base type for the InputMedia types.
type BaseInputMedia struct { type BaseInputMedia struct {
Type string `json:"type"` Type string `json:"type"`
Media string `json:"media"` Media string `json:"media"`
Caption string `json:"caption"` Caption string `json:"caption"`
ParseMode string `json:"parse_mode"` ParseMode string `json:"parse_mode"`
CaptionEntities []MessageEntity `json:"caption_entities"`
} }
// InputMediaPhoto is a photo to send as part of a media group. // InputMediaPhoto is a photo to send as part of a media group.
@ -1151,6 +1216,7 @@ type InputMediaAudio struct {
// InputMediaDocument is a audio to send as part of a media group. // InputMediaDocument is a audio to send as part of a media group.
type InputMediaDocument struct { type InputMediaDocument struct {
BaseInputMedia BaseInputMedia
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
} }
// Error is an error containing extra information returned by the Telegram API. // Error is an error containing extra information returned by the Telegram API.

View File

@ -311,7 +311,7 @@ var (
_ Chattable = PhotoConfig{} _ Chattable = PhotoConfig{}
_ Chattable = PinChatMessageConfig{} _ Chattable = PinChatMessageConfig{}
_ Chattable = PromoteChatMemberConfig{} _ Chattable = PromoteChatMemberConfig{}
_ Chattable = RemoveWebhookConfig{} _ Chattable = DeleteWebhookConfig{}
_ Chattable = RestrictChatMemberConfig{} _ Chattable = RestrictChatMemberConfig{}
_ Chattable = SendPollConfig{} _ Chattable = SendPollConfig{}
_ Chattable = SetChatDescriptionConfig{} _ Chattable = SetChatDescriptionConfig{}