all repos — telegram-bot-api @ 4d758f17d47eba8951d7810190e907db56e51801

Golang bindings for the Telegram Bot API

Add some missing fields, generalize configs, remove unneeded methods.
Syfaro syfaro@huefox.com
Mon, 08 Oct 2018 23:05:24 -0500
commit

4d758f17d47eba8951d7810190e907db56e51801

parent

1f859674f7d9f1ab67d3bef4b6ce2c66897f6203

5 files changed, 349 insertions(+), 234 deletions(-)

jump to
M README.mdREADME.md

@@ -63,7 +63,7 @@ }

``` There are more examples on the [wiki](https://github.com/go-telegram-bot-api/telegram-bot-api/wiki) -with detailed information on how to do many differen kinds of things. +with detailed information on how to do many different kinds of things. It's a great place to get started on using keyboards, commands, or other kinds of reply markup.
M bot.gobot.go

@@ -329,11 +329,9 @@ // GetFile returns a File which can download a file from Telegram.

// // Requires FileID. func (bot *BotAPI) GetFile(config FileConfig) (File, error) { - params := make(Params) - - params["file_id"] = config.FileID + params, _ := config.params() - resp, err := bot.MakeRequest("getFile", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return File{}, err }

@@ -437,12 +435,10 @@ return ch

} // GetChat gets information about a chat. -func (bot *BotAPI) GetChat(config ChatConfig) (Chat, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) +func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error) { + params, _ := config.params() - resp, err := bot.MakeRequest("getChat", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return Chat{}, err }

@@ -457,12 +453,10 @@ // GetChatAdministrators gets a list of administrators in the chat.

// // If none have been appointed, only the creator will be returned. // Bots are not shown, even if they are an administrator. -func (bot *BotAPI) GetChatAdministrators(config ChatConfig) ([]ChatMember, error) { - params := make(Params) +func (bot *BotAPI) GetChatAdministrators(config ChatAdministratorsConfig) ([]ChatMember, error) { + params, _ := config.params() - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) - - resp, err := bot.MakeRequest("getChatAdministrators", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return []ChatMember{}, err }

@@ -474,12 +468,10 @@ return members, err

} // GetChatMembersCount gets the number of users in a chat. -func (bot *BotAPI) GetChatMembersCount(config ChatConfig) (int, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) +func (bot *BotAPI) GetChatMembersCount(config ChatMemberCountConfig) (int, error) { + params, _ := config.params() - resp, err := bot.MakeRequest("getChatMembersCount", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return -1, err }

@@ -491,13 +483,10 @@ return count, err

} // GetChatMember gets a specific chat member. -func (bot *BotAPI) GetChatMember(config ChatConfigWithUser) (ChatMember, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) - params.AddNonZero("user_id", config.UserID) +func (bot *BotAPI) GetChatMember(config GetChatMemberConfig) (ChatMember, error) { + params, _ := config.params() - resp, err := bot.MakeRequest("getChatMember", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return ChatMember{}, err }

@@ -508,63 +497,11 @@

return member, err } -// UnbanChatMember unbans a user from a chat. Note that this only will work -// in supergroups and channels, and requires the bot to be an admin. -func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername) - params.AddNonZero("user_id", config.UserID) - - return bot.MakeRequest("unbanChatMember", params) -} - -// RestrictChatMember to restrict a user in a supergroup. The bot must be an -//administrator in the supergroup for this to work and must have the -//appropriate admin rights. Pass True for all boolean parameters to lift -//restrictions from a user. Returns True on success. -func (bot *BotAPI) RestrictChatMember(config RestrictChatMemberConfig) (APIResponse, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername) - params.AddNonZero("user_id", config.UserID) - - params.AddNonNilBool("can_send_messages", config.CanSendMessages) - params.AddNonNilBool("can_send_media_messages", config.CanSendMediaMessages) - params.AddNonNilBool("can_send_other_messages", config.CanSendOtherMessages) - params.AddNonNilBool("can_add_web_page_previews", config.CanAddWebPagePreviews) - params.AddNonZero64("until_date", config.UntilDate) - - return bot.MakeRequest("restrictChatMember", params) -} - -// PromoteChatMember add admin rights to user -func (bot *BotAPI) PromoteChatMember(config PromoteChatMemberConfig) (APIResponse, error) { - params := make(Params) - - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername) - params.AddNonZero("user_id", config.UserID) - - params.AddNonNilBool("can_change_info", config.CanChangeInfo) - params.AddNonNilBool("can_post_messages", config.CanPostMessages) - params.AddNonNilBool("can_edit_messages", config.CanEditMessages) - params.AddNonNilBool("can_delete_messages", config.CanDeleteMessages) - params.AddNonNilBool("can_invite_members", config.CanInviteUsers) - params.AddNonNilBool("can_restrict_members", config.CanRestrictMembers) - params.AddNonNilBool("can_pin_messages", config.CanPinMessages) - params.AddNonNilBool("can_promote_members", config.CanPromoteMembers) - - return bot.MakeRequest("promoteChatMember", params) -} - // GetGameHighScores allows you to get the high scores for a game. func (bot *BotAPI) GetGameHighScores(config GetGameHighScoresConfig) ([]GameHighScore, error) { - v, err := config.params() - if err != nil { - return nil, err - } + params, _ := config.params() - resp, err := bot.MakeRequest(config.method(), v) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return []GameHighScore{}, err }

@@ -576,12 +513,10 @@ return highScores, err

} // GetInviteLink get InviteLink for a chat -func (bot *BotAPI) GetInviteLink(config ChatConfig) (string, error) { - params := make(Params) +func (bot *BotAPI) GetInviteLink(config ChatInviteLinkConfig) (string, error) { + params, _ := config.params() - params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) - - resp, err := bot.MakeRequest("exportChatInviteLink", params) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return "", err }

@@ -594,12 +529,9 @@ }

// GetStickerSet returns a StickerSet. func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error) { - v, err := config.params() - if err != nil { - return StickerSet{}, nil - } + params, _ := config.params() - resp, err := bot.MakeRequest(config.method(), v) + resp, err := bot.MakeRequest(config.method(), params) if err != nil { return StickerSet{}, nil }
M configs.goconfigs.go

@@ -140,16 +140,16 @@ DisableWebPagePreview bool

} func (config MessageConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() if err != nil { - return v, err + return params, err } - v.AddNonEmpty("text", config.Text) - v.AddBool("disable_web_page_preview", config.DisableWebPagePreview) - v.AddNonEmpty("parse_mode", config.ParseMode) + params.AddNonEmpty("text", config.Text) + params.AddBool("disable_web_page_preview", config.DisableWebPagePreview) + params.AddNonEmpty("parse_mode", config.ParseMode) - return v, nil + return params, nil } func (config MessageConfig) method() string {

@@ -165,15 +165,15 @@ MessageID int // required

} func (config ForwardConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() if err != nil { - return v, err + return params, err } - v.AddNonZero64("from_chat_id", config.FromChatID) - v.AddNonZero("message_id", config.MessageID) + params.AddNonZero64("from_chat_id", config.FromChatID) + params.AddNonZero("message_id", config.MessageID) - return v, nil + return params, nil } func (config ForwardConfig) method() string {

@@ -216,19 +216,19 @@ Title string

} func (config AudioConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() if err != nil { - return v, err + return params, err } - v.AddNonEmpty(config.name(), config.FileID) - v.AddNonZero("duration", config.Duration) - v.AddNonEmpty("performer", config.Performer) - v.AddNonEmpty("title", config.Title) - v.AddNonEmpty("caption", config.Caption) - v.AddNonEmpty("parse_mode", config.ParseMode) + params.AddNonEmpty(config.name(), config.FileID) + params.AddNonZero("duration", config.Duration) + params.AddNonEmpty("performer", config.Performer) + params.AddNonEmpty("title", config.Title) + params.AddNonEmpty("caption", config.Caption) + params.AddNonEmpty("parse_mode", config.ParseMode) - return v, nil + return params, nil } func (config AudioConfig) name() string {

@@ -270,11 +270,11 @@ BaseFile

} func (config StickerConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonEmpty(config.name(), config.FileID) + params.AddNonEmpty(config.name(), config.FileID) - return v, err + return params, err } func (config StickerConfig) name() string {

@@ -288,20 +288,22 @@

// VideoConfig contains information about a SendVideo request. type VideoConfig struct { BaseFile - Duration int - Caption string - ParseMode string + Duration int + Caption string + ParseMode string + SupportsStreaming bool } func (config VideoConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonEmpty(config.name(), config.FileID) - v.AddNonZero("duration", config.Duration) - v.AddNonEmpty("caption", config.Caption) - v.AddNonEmpty("parse_mode", config.ParseMode) + params.AddNonEmpty(config.name(), config.FileID) + params.AddNonZero("duration", config.Duration) + params.AddNonEmpty("caption", config.Caption) + params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("supports_streaming", config.SupportsStreaming) - return v, err + return params, err } func (config VideoConfig) name() string {

@@ -321,14 +323,14 @@ ParseMode string

} func (config AnimationConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonEmpty(config.name(), config.FileID) - v.AddNonZero("duration", config.Duration) - v.AddNonEmpty("caption", config.Caption) - v.AddNonEmpty("parse_mode", config.ParseMode) + params.AddNonEmpty(config.name(), config.FileID) + params.AddNonZero("duration", config.Duration) + params.AddNonEmpty("caption", config.Caption) + params.AddNonEmpty("parse_mode", config.ParseMode) - return v, err + return params, err } func (config AnimationConfig) name() string {

@@ -347,13 +349,13 @@ Length int

} func (config VideoNoteConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonEmpty(config.name(), config.FileID) - v.AddNonZero("duration", config.Duration) - v.AddNonZero("length", config.Length) + params.AddNonEmpty(config.name(), config.FileID) + params.AddNonZero("duration", config.Duration) + params.AddNonZero("length", config.Length) - return v, err + return params, err } func (config VideoNoteConfig) name() string {

@@ -373,14 +375,14 @@ Duration int

} func (config VoiceConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonEmpty(config.name(), config.FileID) - v.AddNonZero("duration", config.Duration) - v.AddNonEmpty("caption", config.Caption) - v.AddNonEmpty("parse_mode", config.ParseMode) + params.AddNonEmpty(config.name(), config.FileID) + params.AddNonZero("duration", config.Duration) + params.AddNonEmpty("caption", config.Caption) + params.AddNonEmpty("parse_mode", config.ParseMode) - return v, err + return params, err } func (config VoiceConfig) name() string {

@@ -400,13 +402,13 @@ LivePeriod int // optional

} func (config LocationConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonZeroFloat("latitude", config.Latitude) - v.AddNonZeroFloat("longitude", config.Longitude) - v.AddNonZero("live_period", config.LivePeriod) + params.AddNonZeroFloat("latitude", config.Latitude) + params.AddNonZeroFloat("longitude", config.Longitude) + params.AddNonZero("live_period", config.LivePeriod) - return v, err + return params, err } func (config LocationConfig) method() string {

@@ -421,12 +423,12 @@ Longitude float64 // required

} func (config EditMessageLiveLocationConfig) params() (Params, error) { - v, err := config.BaseEdit.params() + params, err := config.BaseEdit.params() - v.AddNonZeroFloat("latitude", config.Latitude) - v.AddNonZeroFloat("longitude", config.Longitude) + params.AddNonZeroFloat("latitude", config.Latitude) + params.AddNonZeroFloat("longitude", config.Longitude) - return v, err + return params, err } func (config EditMessageLiveLocationConfig) method() string {

@@ -457,15 +459,15 @@ FoursquareID string

} func (config VenueConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v.AddNonZeroFloat("latitude", config.Latitude) - v.AddNonZeroFloat("longitude", config.Longitude) - v["title"] = config.Title - v["address"] = config.Address - v.AddNonEmpty("foursquare_id", config.FoursquareID) + params.AddNonZeroFloat("latitude", config.Latitude) + params.AddNonZeroFloat("longitude", config.Longitude) + params["title"] = config.Title + params["address"] = config.Address + params.AddNonEmpty("foursquare_id", config.FoursquareID) - return v, err + return params, err } func (config VenueConfig) method() string {

@@ -478,16 +480,19 @@ BaseChat

PhoneNumber string FirstName string LastName string + VCard string } func (config ContactConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() + + params["phone_number"] = config.PhoneNumber + params["first_name"] = config.FirstName - v["phone_number"] = config.PhoneNumber - v["first_name"] = config.FirstName - v["last_name"] = config.LastName + params.AddNonEmpty("last_name", config.LastName) + params.AddNonEmpty("vcard", config.VCard) - return v, err + return params, err } func (config ContactConfig) method() string {

@@ -501,11 +506,11 @@ GameShortName string

} func (config GameConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v["game_short_name"] = config.GameShortName + params["game_short_name"] = config.GameShortName - return v, err + return params, err } func (config GameConfig) method() string {

@@ -580,11 +585,11 @@ Action string // required

} func (config ChatActionConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() - v["action"] = config.Action + params["action"] = config.Action - return v, err + return params, err } func (config ChatActionConfig) method() string {

@@ -600,13 +605,13 @@ DisableWebPagePreview bool

} func (config EditMessageTextConfig) params() (Params, error) { - v, err := config.BaseEdit.params() + params, err := config.BaseEdit.params() - v["text"] = config.Text - v.AddNonEmpty("parse_mode", config.ParseMode) - v.AddBool("disable_web_page_preview", config.DisableWebPagePreview) + params["text"] = config.Text + params.AddNonEmpty("parse_mode", config.ParseMode) + params.AddBool("disable_web_page_preview", config.DisableWebPagePreview) - return v, err + return params, err } func (config EditMessageTextConfig) method() string {

@@ -621,18 +626,37 @@ ParseMode string

} func (config EditMessageCaptionConfig) params() (Params, error) { - v, err := config.BaseEdit.params() + params, err := config.BaseEdit.params() - v["caption"] = config.Caption - v.AddNonEmpty("parse_mode", config.ParseMode) + params["caption"] = config.Caption + params.AddNonEmpty("parse_mode", config.ParseMode) - return v, err + return params, err } func (config EditMessageCaptionConfig) method() string { return "editMessageCaption" } +// EditMessageMediaConfig contains information about editing a message's media. +type EditMessageMediaConfig struct { + BaseEdit + + Media interface{} +} + +func (EditMessageMediaConfig) method() string { + return "editMessageMedia" +} + +func (config EditMessageMediaConfig) params() (Params, error) { + params, err := config.BaseEdit.params() + + params.AddInterface("media", config.Media) + + return params, err +} + // EditMessageReplyMarkupConfig allows you to modify the reply markup // of a message. type EditMessageReplyMarkupConfig struct {

@@ -674,6 +698,18 @@ type FileConfig struct {

FileID string } +func (FileConfig) method() string { + return "getFile" +} + +func (config FileConfig) params() (Params, error) { + params := make(Params) + + params["file_id"] = config.FileID + + return params, nil +} + // UpdateConfig contains information about a GetUpdates request. type UpdateConfig struct { Offset int

@@ -700,6 +736,7 @@ type WebhookConfig struct {

URL *url.URL Certificate interface{} MaxConnections int + AllowedUpdates []string } func (config WebhookConfig) method() string {

@@ -714,6 +751,7 @@ params["url"] = config.URL.String()

} params.AddNonZero("max_connections", config.MaxConnections) + params.AddInterface("allowed_updates", config.AllowedUpdates) return params, nil }

@@ -932,6 +970,60 @@ ChatID int64

SuperGroupUsername string } +func (config ChatConfig) params() (Params, error) { + params := make(Params) + + params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + + return params, nil +} + +// ChatInfoConfig contains information about getting chat information. +type ChatInfoConfig struct { + ChatConfig +} + +func (ChatInfoConfig) method() string { + return "getChat" +} + +// ChatMemberCountConfig contains information about getting the number of users in a chat. +type ChatMemberCountConfig struct { + ChatConfig +} + +func (ChatMemberCountConfig) method() string { + return "getChatMembersCount" +} + +// ChatAdministratorsConfig contains information about getting chat administrators. +type ChatAdministratorsConfig struct { + ChatConfig +} + +func (ChatAdministratorsConfig) method() string { + return "getChatAdministrators" +} + +// ChatInviteLinkConfig contains information about getting a chat link. +// +// Note that generating a new link will revoke any previous links. +type ChatInviteLinkConfig struct { + ChatConfig +} + +func (ChatInviteLinkConfig) method() string { + return "exportChatInviteLink" +} + +func (config ChatInviteLinkConfig) params() (Params, error) { + params := make(Params) + + params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + + return params, nil +} + // LeaveChatConfig allows you to leave a chat. type LeaveChatConfig struct { ChatID int64

@@ -950,65 +1042,86 @@

return params, nil } -// ChatConfigWithUser contains information about getting information on -// a specific user within a chat. +// ChatConfigWithUser contains information about a chat and a user. type ChatConfigWithUser struct { ChatID int64 SuperGroupUsername string UserID int } +func (config ChatConfigWithUser) params() (Params, error) { + params := make(Params) + + params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername) + params.AddNonZero("user_id", config.UserID) + + return params, nil +} + +// GetChatMemberConfig is information about getting a specific member in a chat. +type GetChatMemberConfig struct { + ChatConfigWithUser +} + +func (GetChatMemberConfig) method() string { + return "getChatMember" +} + // InvoiceConfig contains information for sendInvoice request. type InvoiceConfig struct { BaseChat - Title string // required - Description string // required - Payload string // required - ProviderToken string // required - StartParameter string // required - Currency string // required - Prices *[]LabeledPrice // required - ProviderData string - PhotoURL string - PhotoSize int - PhotoWidth int - PhotoHeight int - NeedName bool - NeedPhoneNumber bool - NeedEmail bool - NeedShippingAddress bool - IsFlexible bool + Title string // required + Description string // required + Payload string // required + ProviderToken string // required + StartParameter string // required + Currency string // required + Prices *[]LabeledPrice // required + ProviderData string + PhotoURL string + PhotoSize int + PhotoWidth int + PhotoHeight int + NeedName bool + NeedPhoneNumber bool + NeedEmail bool + NeedShippingAddress bool + SendPhoneNumberToProvider bool + SendEmailToProvider bool + IsFlexible bool } func (config InvoiceConfig) params() (Params, error) { - v, err := config.BaseChat.params() + params, err := config.BaseChat.params() if err != nil { - return v, err + return params, err } - v["title"] = config.Title - v["description"] = config.Description - v["payload"] = config.Payload - v["provider_token"] = config.ProviderToken - v["start_parameter"] = config.StartParameter - v["currency"] = config.Currency + params["title"] = config.Title + params["description"] = config.Description + params["payload"] = config.Payload + params["provider_token"] = config.ProviderToken + params["start_parameter"] = config.StartParameter + params["currency"] = config.Currency - if err = v.AddInterface("prices", config.Prices); err != nil { - return v, err + if err = params.AddInterface("prices", config.Prices); err != nil { + return params, err } - v.AddNonEmpty("provider_data", config.ProviderData) - v.AddNonEmpty("photo_url", config.PhotoURL) - v.AddNonZero("photo_size", config.PhotoSize) - v.AddNonZero("photo_width", config.PhotoWidth) - v.AddNonZero("photo_height", config.PhotoHeight) - v.AddBool("need_name", config.NeedName) - v.AddBool("need_phone_number", config.NeedPhoneNumber) - v.AddBool("need_email", config.NeedEmail) - v.AddBool("need_shipping_address", config.NeedShippingAddress) - v.AddBool("is_flexible", config.IsFlexible) + params.AddNonEmpty("provider_data", config.ProviderData) + params.AddNonEmpty("photo_url", config.PhotoURL) + params.AddNonZero("photo_size", config.PhotoSize) + params.AddNonZero("photo_width", config.PhotoWidth) + params.AddNonZero("photo_height", config.PhotoHeight) + params.AddBool("need_name", config.NeedName) + params.AddBool("need_phone_number", config.NeedPhoneNumber) + params.AddBool("need_email", config.NeedEmail) + params.AddBool("need_shipping_address", config.NeedShippingAddress) + params.AddBool("is_flexible", config.IsFlexible) + params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider) + params.AddBool("send_email_to_provider", config.SendEmailToProvider) - return v, nil + return params, nil } func (config InvoiceConfig) method() string {
M helpers.gohelpers.go

@@ -302,16 +302,50 @@

// NewInputMediaPhoto creates a new InputMediaPhoto. func NewInputMediaPhoto(media string) InputMediaPhoto { return InputMediaPhoto{ - Type: "photo", - Media: media, + BaseInputMedia{ + Type: "photo", + Media: media, + }, } } // NewInputMediaVideo creates a new InputMediaVideo. func NewInputMediaVideo(media string) InputMediaVideo { return InputMediaVideo{ - Type: "video", - Media: media, + BaseInputMedia: BaseInputMedia{ + Type: "video", + Media: media, + }, + } +} + +// NewInputMediaAnimation creates a new InputMediaAnimation. +func NewInputMediaAnimation(media string) InputMediaAnimation { + return InputMediaAnimation{ + BaseInputMedia: BaseInputMedia{ + Type: "animation", + Media: media, + }, + } +} + +// NewInputMediaAudio creates a new InputMediaAudio. +func NewInputMediaAudio(media string) InputMediaAudio { + return InputMediaAudio{ + BaseInputMedia: BaseInputMedia{ + Type: "audio", + Media: media, + }, + } +} + +// NewInputMediaDocument creates a new InputMediaDocument. +func NewInputMediaDocument(media string) InputMediaDocument { + return InputMediaDocument{ + BaseInputMedia: BaseInputMedia{ + Type: "document", + Media: media, + }, } }
M types.gotypes.go

@@ -175,6 +175,7 @@ MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional

PinnedMessage *Message `json:"pinned_message"` // optional Invoice *Invoice `json:"invoice"` // optional SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // optional + ConnectedWebsite string `json:"connected_website"` // optional PassportData *PassportData `json:"passport_data,omitempty"` // optional }

@@ -367,6 +368,7 @@ PhoneNumber string `json:"phone_number"`

FirstName string `json:"first_name"` LastName string `json:"last_name"` // optional UserID int `json:"user_id"` // optional + VCard string `json:"vcard"` // optional } // Location contains information about a place.

@@ -685,6 +687,21 @@ Latitude float64 `json:"latitude"` // required

Longitude float64 `json:"longitude"` // required LivePeriod int `json:"live_period"` // optional Title string `json:"title"` // required + ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` + 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. +type InlineQueryResultContact struct { + Type string `json:"type"` // required + ID string `json:"id"` // required + PhoneNumber string `json:"phone_number"` // required + FirstName string `json:"first_name"` // required + LastName string `json:"last_name"` + VCard string `json:"vcard"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"` ThumbURL string `json:"thumb_url"`

@@ -740,6 +757,7 @@ type InputContactMessageContent struct {

PhoneNumber string `json:"phone_number"` FirstName string `json:"first_name"` LastName string `json:"last_name"` + VCard string `json:"vcard"` } // Invoice contains basic information about an invoice.

@@ -820,29 +838,47 @@ 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 { +// BaseInputMedia is a base type for the InputMedia types. +type BaseInputMedia struct { Type string `json:"type"` Media string `json:"media"` Caption string `json:"caption"` ParseMode string `json:"parse_mode"` } +// InputMediaPhoto is a photo to send as part of a media group. +type InputMediaPhoto struct { + BaseInputMedia +} + // 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"` - // thumb intentionally missing as it is not currently compatible - Caption string `json:"caption"` - ParseMode string `json:"parse_mode"` - Width int `json:"width"` - Height int `json:"height"` - Duration int `json:"duration"` - SupportsStreaming bool `json:"supports_streaming"` + BaseInputMedia + Width int `json:"width"` + Height int `json:"height"` + Duration int `json:"duration"` + SupportsStreaming bool `json:"supports_streaming"` +} + +// InputMediaAnimation is an animation to send as part of a media group. +type InputMediaAnimation struct { + BaseInputMedia + Width int `json:"width"` + Height int `json:"height"` + Duration int `json:"duration"` +} + +// InputMediaAudio is a audio to send as part of a media group. +type InputMediaAudio struct { + BaseInputMedia + Duration int `json:"duration"` + Performer string `json:"performer"` + Title string `json:"title"` +} + +// InputMediaDocument is a audio to send as part of a media group. +type InputMediaDocument struct { + BaseInputMedia } // Error is an error containing extra information returned by the Telegram API.