all repos — telegram-bot-api @ e5991566310f001586af2ff2736a3e4c8436af85

Golang bindings for the Telegram Bot API

types.go (view raw)

   1package tgbotapi
   2
   3import (
   4	"encoding/json"
   5	"errors"
   6	"fmt"
   7	"net/url"
   8	"strings"
   9	"time"
  10)
  11
  12// APIResponse is a response from the Telegram API with the result
  13// stored raw.
  14type APIResponse struct {
  15	Ok          bool                `json:"ok"`
  16	Result      json.RawMessage     `json:"result,omitempty"`
  17	ErrorCode   int                 `json:"error_code,omitempty"`
  18	Description string              `json:"description,omitempty"`
  19	Parameters  *ResponseParameters `json:"parameters,omitempty"`
  20}
  21
  22// ResponseParameters are various errors that can be returned in APIResponse.
  23type ResponseParameters struct {
  24	MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional
  25	RetryAfter      int   `json:"retry_after,omitempty"`        // optional
  26}
  27
  28// Update is an update response, from GetUpdates.
  29type Update struct {
  30	UpdateID           int                 `json:"update_id"`
  31	Message            *Message            `json:"message,omitempty"`
  32	EditedMessage      *Message            `json:"edited_message,omitempty"`
  33	ChannelPost        *Message            `json:"channel_post,omitempty"`
  34	EditedChannelPost  *Message            `json:"edited_channel_post,omitempty"`
  35	InlineQuery        *InlineQuery        `json:"inline_query,omitempty"`
  36	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
  37	CallbackQuery      *CallbackQuery      `json:"callback_query,omitempty"`
  38	ShippingQuery      *ShippingQuery      `json:"shipping_query,omitempty"`
  39	PreCheckoutQuery   *PreCheckoutQuery   `json:"pre_checkout_query,omitempty"`
  40	Poll               *Poll               `json:"poll,omitempty"`
  41	PollAnswer         *PollAnswer         `json:"poll_answer,omitempty"`
  42}
  43
  44// UpdatesChannel is the channel for getting updates.
  45type UpdatesChannel <-chan Update
  46
  47// Clear discards all unprocessed incoming updates.
  48func (ch UpdatesChannel) Clear() {
  49	for len(ch) != 0 {
  50		<-ch
  51	}
  52}
  53
  54// User is a user on Telegram.
  55type User struct {
  56	ID                      int    `json:"id"`
  57	FirstName               string `json:"first_name"`
  58	LastName                string `json:"last_name,omitempty"`                   // optional
  59	UserName                string `json:"username,omitempty"`                    // optional
  60	LanguageCode            string `json:"language_code,omitempty"`               // optional
  61	IsBot                   bool   `json:"is_bot,omitempty"`                      // optional
  62	CanJoinGroups           bool   `json:"can_join_groups,omitempty"`             // optional
  63	CanReadAllGroupMessages bool   `json:"can_read_all_group_messages,omitempty"` // optional
  64	SupportsInlineQueries   bool   `json:"supports_inline_queries,omitempty"`     // optional
  65}
  66
  67// String displays a simple text version of a user.
  68//
  69// It is normally a user's username, but falls back to a first/last
  70// name as available.
  71func (u *User) String() string {
  72	if u == nil {
  73		return ""
  74	}
  75	if u.UserName != "" {
  76		return u.UserName
  77	}
  78
  79	name := u.FirstName
  80	if u.LastName != "" {
  81		name += " " + u.LastName
  82	}
  83
  84	return name
  85}
  86
  87// GroupChat is a group chat.
  88type GroupChat struct {
  89	ID    int    `json:"id"`
  90	Title string `json:"title"`
  91}
  92
  93// ChatPhoto represents a chat photo.
  94type ChatPhoto struct {
  95	SmallFileID       string `json:"small_file_id"`
  96	SmallFileUniqueID string `json:"small_file_unique_id"`
  97	BigFileID         string `json:"big_file_id"`
  98	BigFileUniqueID   string `json:"big_file_unique_id"`
  99}
 100
 101// ChatPermissions describes actions that a non-administrator user is
 102// allowed to take in a chat. All fields are optional.
 103type ChatPermissions struct {
 104	CanSendMessages       bool `json:"can_send_messages"`
 105	CanSendMediaMessages  bool `json:"can_send_media_messages"`
 106	CanSendPolls          bool `json:"can_send_polls"`
 107	CanSendOtherMessages  bool `json:"can_send_other_messages"`
 108	CanAddWebPagePreviews bool `json:"can_add_web_page_previews"`
 109	CanChangeInfo         bool `json:"can_change_info"`
 110	CanInviteUsers        bool `json:"can_invite_users"`
 111	CanPinMessages        bool `json:"can_pin_messages"`
 112}
 113
 114// Chat contains information about the place a message was sent.
 115type Chat struct {
 116	ID                  int64            `json:"id"`
 117	Type                string           `json:"type"`
 118	Title               string           `json:"title,omitempty"`                          // optional
 119	UserName            string           `json:"username,omitempty"`                       // optional
 120	FirstName           string           `json:"first_name,omitempty"`                     // optional
 121	LastName            string           `json:"last_name,omitempty"`                      // optional
 122	AllMembersAreAdmins bool             `json:"all_members_are_administrators,omitempty"` // deprecated, optional
 123	Photo               *ChatPhoto       `json:"photo,omitempty"`                          // optional
 124	Description         string           `json:"description,omitempty"`                    // optional
 125	InviteLink          string           `json:"invite_link,omitempty"`                    // optional
 126	PinnedMessage       *Message         `json:"pinned_message,omitempty"`                 // optional
 127	Permissions         *ChatPermissions `json:"permissions,omitempty"`                    // optional
 128	SlowModeDelay       int              `json:"slow_mode_delay,omitempty"`                // optional
 129	StickerSetName      string           `json:"sticker_set_name,omitempty"`               // optional
 130	CanSetStickerSet    bool             `json:"can_set_sticker_set,omitempty"`            // optional
 131}
 132
 133// IsPrivate returns if the Chat is a private conversation.
 134func (c Chat) IsPrivate() bool {
 135	return c.Type == "private"
 136}
 137
 138// IsGroup returns if the Chat is a group.
 139func (c Chat) IsGroup() bool {
 140	return c.Type == "group"
 141}
 142
 143// IsSuperGroup returns if the Chat is a supergroup.
 144func (c Chat) IsSuperGroup() bool {
 145	return c.Type == "supergroup"
 146}
 147
 148// IsChannel returns if the Chat is a channel.
 149func (c Chat) IsChannel() bool {
 150	return c.Type == "channel"
 151}
 152
 153// ChatConfig returns a ChatConfig struct for chat related methods.
 154func (c Chat) ChatConfig() ChatConfig {
 155	return ChatConfig{ChatID: c.ID}
 156}
 157
 158// Message is returned by almost every request, and contains data about
 159// almost anything.
 160type Message struct {
 161	MessageID             int                   `json:"message_id"`
 162	From                  *User                 `json:"from,omitempty"` // optional
 163	Date                  int                   `json:"date"`
 164	Chat                  *Chat                 `json:"chat"`
 165	ForwardFrom           *User                 `json:"forward_from,omitempty"`            // optional
 166	ForwardFromChat       *Chat                 `json:"forward_from_chat,omitempty"`       // optional
 167	ForwardFromMessageID  int                   `json:"forward_from_message_id,omitempty"` // optional
 168	ForwardSignature      string                `json:"forward_signature,omitempty"`       // optional
 169	ForwardSenderName     string                `json:"forward_sender_name,omitempty"`     // optional
 170	ForwardDate           int                   `json:"forward_date,omitempty"`            // optional
 171	ReplyToMessage        *Message              `json:"reply_to_message,omitempty"`        // optional
 172	EditDate              int                   `json:"edit_date,omitempty"`               // optional
 173	MediaGroupID          string                `json:"media_group_id,omitempty"`          // optional
 174	AuthorSignature       string                `json:"author_signature,omitempty"`        // optional
 175	Text                  string                `json:"text,omitempty"`                    // optional
 176	Entities              []MessageEntity       `json:"entities,omitempty"`                // optional
 177	CaptionEntities       []MessageEntity       `json:"caption_entities,omitempty"`        // optional
 178	Audio                 *Audio                `json:"audio,omitempty"`                   // optional
 179	Document              *Document             `json:"document,omitempty"`                // optional
 180	Animation             *ChatAnimation        `json:"animation,omitempty"`               // optional
 181	Game                  *Game                 `json:"game,omitempty"`                    // optional
 182	Photo                 []PhotoSize           `json:"photo,omitempty"`                   // optional
 183	Sticker               *Sticker              `json:"sticker,omitempty"`                 // optional
 184	Video                 *Video                `json:"video,omitempty"`                   // optional
 185	VideoNote             *VideoNote            `json:"video_note,omitempty"`              // optional
 186	Voice                 *Voice                `json:"voice,omitempty"`                   // optional
 187	Caption               string                `json:"caption,omitempty"`                 // optional
 188	Contact               *Contact              `json:"contact,omitempty"`                 // optional
 189	Location              *Location             `json:"location,omitempty"`                // optional
 190	Venue                 *Venue                `json:"venue,omitempty"`                   // optional
 191	Poll                  *Poll                 `json:"poll,omitempty"`                    // optional
 192	Dice                  *Dice                 `json:"dice,omitempty"`                    // optional
 193	NewChatMembers        []User                `json:"new_chat_members,omitempty"`        // optional
 194	LeftChatMember        *User                 `json:"left_chat_member,omitempty"`        // optional
 195	NewChatTitle          string                `json:"new_chat_title,omitempty"`          // optional
 196	NewChatPhoto          []PhotoSize           `json:"new_chat_photo,omitempty"`          // optional
 197	DeleteChatPhoto       bool                  `json:"delete_chat_photo,omitempty"`       // optional
 198	GroupChatCreated      bool                  `json:"group_chat_created,omitempty"`      // optional
 199	SuperGroupChatCreated bool                  `json:"supergroup_chat_created,omitempty"` // optional
 200	ChannelChatCreated    bool                  `json:"channel_chat_created,omitempty"`    // optional
 201	MigrateToChatID       int64                 `json:"migrate_to_chat_id,omitempty"`      // optional
 202	MigrateFromChatID     int64                 `json:"migrate_from_chat_id,omitempty"`    // optional
 203	PinnedMessage         *Message              `json:"pinned_message,omitempty"`          // optional
 204	Invoice               *Invoice              `json:"invoice,omitempty"`                 // optional
 205	SuccessfulPayment     *SuccessfulPayment    `json:"successful_payment,omitempty"`      // optional
 206	ConnectedWebsite      string                `json:"connected_website,omitempty"`       // optional
 207	PassportData          *PassportData         `json:"passport_data,omitempty"`           // optional
 208	ReplyMarkup           *InlineKeyboardMarkup `json:"reply_markup,omitempty"`            // optional
 209}
 210
 211// Time converts the message timestamp into a Time.
 212func (m *Message) Time() time.Time {
 213	return time.Unix(int64(m.Date), 0)
 214}
 215
 216// IsCommand returns true if message starts with a "bot_command" entity.
 217func (m *Message) IsCommand() bool {
 218	if m.Entities == nil || len(m.Entities) == 0 {
 219		return false
 220	}
 221
 222	entity := m.Entities[0]
 223	return entity.Offset == 0 && entity.IsCommand()
 224}
 225
 226// Command checks if the message was a command and if it was, returns the
 227// command. If the Message was not a command, it returns an empty string.
 228//
 229// If the command contains the at name syntax, it is removed. Use
 230// CommandWithAt() if you do not want that.
 231func (m *Message) Command() string {
 232	command := m.CommandWithAt()
 233
 234	if i := strings.Index(command, "@"); i != -1 {
 235		command = command[:i]
 236	}
 237
 238	return command
 239}
 240
 241// CommandWithAt checks if the message was a command and if it was, returns the
 242// command. If the Message was not a command, it returns an empty string.
 243//
 244// If the command contains the at name syntax, it is not removed. Use Command()
 245// if you want that.
 246func (m *Message) CommandWithAt() string {
 247	if !m.IsCommand() {
 248		return ""
 249	}
 250
 251	// IsCommand() checks that the message begins with a bot_command entity
 252	entity := m.Entities[0]
 253	return m.Text[1:entity.Length]
 254}
 255
 256// CommandArguments checks if the message was a command and if it was,
 257// returns all text after the command name. If the Message was not a
 258// command, it returns an empty string.
 259//
 260// Note: The first character after the command name is omitted:
 261// - "/foo bar baz" yields "bar baz", not " bar baz"
 262// - "/foo-bar baz" yields "bar baz", too
 263// Even though the latter is not a command conforming to the spec, the API
 264// marks "/foo" as command entity.
 265func (m *Message) CommandArguments() string {
 266	if !m.IsCommand() {
 267		return ""
 268	}
 269
 270	// IsCommand() checks that the message begins with a bot_command entity
 271	entity := m.Entities[0]
 272
 273	if len(m.Text) == entity.Length {
 274		return "" // The command makes up the whole message
 275	}
 276
 277	return m.Text[entity.Length+1:]
 278}
 279
 280// MessageEntity contains information about data in a Message.
 281type MessageEntity struct {
 282	Type     string `json:"type"`
 283	Offset   int    `json:"offset"`
 284	Length   int    `json:"length"`
 285	URL      string `json:"url,omitempty"`      // optional
 286	User     *User  `json:"user,omitempty"`     // optional
 287	Language string `json:"language,omitempty"` // optional
 288}
 289
 290// ParseURL attempts to parse a URL contained within a MessageEntity.
 291func (e MessageEntity) ParseURL() (*url.URL, error) {
 292	if e.URL == "" {
 293		return nil, errors.New(ErrBadURL)
 294	}
 295
 296	return url.Parse(e.URL)
 297}
 298
 299// IsMention returns true if the type of the message entity is "mention" (@username).
 300func (e MessageEntity) IsMention() bool {
 301	return e.Type == "mention"
 302}
 303
 304// IsHashtag returns true if the type of the message entity is "hashtag".
 305func (e MessageEntity) IsHashtag() bool {
 306	return e.Type == "hashtag"
 307}
 308
 309// IsCommand returns true if the type of the message entity is "bot_command".
 310func (e MessageEntity) IsCommand() bool {
 311	return e.Type == "bot_command"
 312}
 313
 314// IsURL returns true if the type of the message entity is "url".
 315func (e MessageEntity) IsURL() bool {
 316	return e.Type == "url"
 317}
 318
 319// IsEmail returns true if the type of the message entity is "email".
 320func (e MessageEntity) IsEmail() bool {
 321	return e.Type == "email"
 322}
 323
 324// IsBold returns true if the type of the message entity is "bold" (bold text).
 325func (e MessageEntity) IsBold() bool {
 326	return e.Type == "bold"
 327}
 328
 329// IsItalic returns true if the type of the message entity is "italic" (italic text).
 330func (e MessageEntity) IsItalic() bool {
 331	return e.Type == "italic"
 332}
 333
 334// IsCode returns true if the type of the message entity is "code" (monowidth string).
 335func (e MessageEntity) IsCode() bool {
 336	return e.Type == "code"
 337}
 338
 339// IsPre returns true if the type of the message entity is "pre" (monowidth block).
 340func (e MessageEntity) IsPre() bool {
 341	return e.Type == "pre"
 342}
 343
 344// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
 345func (e MessageEntity) IsTextLink() bool {
 346	return e.Type == "text_link"
 347}
 348
 349// PhotoSize contains information about photos.
 350type PhotoSize struct {
 351	FileID       string `json:"file_id"`
 352	FileUniqueID string `json:"file_unique_id"`
 353	Width        int    `json:"width"`
 354	Height       int    `json:"height"`
 355	FileSize     int    `json:"file_size,omitempty"` // optional
 356}
 357
 358// Audio contains information about audio.
 359type Audio struct {
 360	FileID       string `json:"file_id"`
 361	FileUniqueID string `json:"file_unique_id"`
 362	Duration     int    `json:"duration"`
 363	Performer    string `json:"performer,omitempty"` // optional
 364	Title        string `json:"title,omitempty"`     // optional
 365	MimeType     string `json:"mime_type,omitempty"` // optional
 366	FileSize     int    `json:"file_size,omitempty"` // optional
 367}
 368
 369// Document contains information about a document.
 370type Document struct {
 371	FileID       string     `json:"file_id"`
 372	FileUniqueID string     `json:"file_unique_id"`
 373	Thumbnail    *PhotoSize `json:"thumb,omitempty"`     // optional
 374	FileName     string     `json:"file_name,omitempty"` // optional
 375	MimeType     string     `json:"mime_type,omitempty"` // optional
 376	FileSize     int        `json:"file_size,omitempty"` // optional
 377}
 378
 379// Sticker contains information about a sticker.
 380type Sticker struct {
 381	FileID       string       `json:"file_id"`
 382	FileUniqueID string       `json:"file_unique_id"`
 383	Width        int          `json:"width"`
 384	Height       int          `json:"height"`
 385	IsAnimated   bool         `json:"is_animated"`
 386	Thumbnail    *PhotoSize   `json:"thumb,omitempty"`         // optional
 387	Emoji        string       `json:"emoji,omitempty"`         // optional
 388	SetName      string       `json:"set_name,omitempty"`      // optional
 389	MaskPosition MaskPosition `json:"mask_position,omitempty"` //optional
 390	FileSize     int          `json:"file_size,omitempty"`     // optional
 391}
 392
 393// MaskPosition is the position of a mask.
 394type MaskPosition struct {
 395	Point     string     `json:"point"`
 396	XShift    float32    `json:"x_shift"`
 397	YShift    float32    `json:"y_shift"`
 398	Scale     float32    `json:"scale"`
 399	FileID    string     `json:"file_id"`
 400	Width     int        `json:"width"`
 401	Height    int        `json:"height"`
 402	Thumbnail *PhotoSize `json:"thumb,omitempty"`     // optional
 403	Emoji     string     `json:"emoji,omitempty"`     // optional
 404	FileSize  int        `json:"file_size,omitempty"` // optional
 405	SetName   string     `json:"set_name,omitempty"`  // optional
 406}
 407
 408// ChatAnimation contains information about an animation.
 409type ChatAnimation struct {
 410	FileID       string     `json:"file_id"`
 411	FileUniqueID string     `json:"file_unique_id"`
 412	Width        int        `json:"width"`
 413	Height       int        `json:"height"`
 414	Duration     int        `json:"duration"`
 415	Thumbnail    *PhotoSize `json:"thumb,omitempty"`     // optional
 416	FileName     string     `json:"file_name,omitempty"` // optional
 417	MimeType     string     `json:"mime_type,omitempty"` // optional
 418	FileSize     int        `json:"file_size,omitempty"` // optional
 419}
 420
 421// Video contains information about a video.
 422type Video struct {
 423	FileID       string     `json:"file_id"`
 424	FileUniqueID string     `json:"file_unique_id"`
 425	Width        int        `json:"width"`
 426	Height       int        `json:"height"`
 427	Duration     int        `json:"duration"`
 428	Thumbnail    *PhotoSize `json:"thumb,omitempty"`     // optional
 429	MimeType     string     `json:"mime_type,omitempty"` // optional
 430	FileSize     int        `json:"file_size,omitempty"` // optional
 431}
 432
 433// VideoNote contains information about a video.
 434type VideoNote struct {
 435	FileID       string     `json:"file_id"`
 436	FileUniqueID string     `json:"file_unique_id"`
 437	Length       int        `json:"length"`
 438	Duration     int        `json:"duration"`
 439	Thumbnail    *PhotoSize `json:"thumb,omitempty"`     // optional
 440	FileSize     int        `json:"file_size,omitempty"` // optional
 441}
 442
 443// Voice contains information about a voice.
 444type Voice struct {
 445	FileID       string `json:"file_id"`
 446	FileUniqueID string `json:"file_unique_id"`
 447	Duration     int    `json:"duration"`
 448	MimeType     string `json:"mime_type,omitempty"` // optional
 449	FileSize     int    `json:"file_size,omitempty"` // optional
 450}
 451
 452// Contact contains information about a contact.
 453//
 454// Note that LastName and UserID may be empty.
 455type Contact struct {
 456	PhoneNumber string `json:"phone_number"`
 457	FirstName   string `json:"first_name"`
 458	LastName    string `json:"last_name,omitempty"` // optional
 459	UserID      int    `json:"user_id,omitempty"`   // optional
 460	VCard       string `json:"vcard,omitempty"`     // optional
 461}
 462
 463// Location contains information about a place.
 464type Location struct {
 465	Longitude float64 `json:"longitude"`
 466	Latitude  float64 `json:"latitude"`
 467}
 468
 469// Venue contains information about a venue, including its Location.
 470type Venue struct {
 471	Location     Location `json:"location"`
 472	Title        string   `json:"title"`
 473	Address      string   `json:"address"`
 474	FoursquareID string   `json:"foursquare_id,omitempty"` // optional
 475}
 476
 477// PollOption contains information about one answer option in a poll.
 478type PollOption struct {
 479	Text       string `json:"text"`
 480	VoterCount int    `json:"voter_count"`
 481}
 482
 483// PollAnswer represents an answer of a user in a non-anonymous poll.
 484type PollAnswer struct {
 485	PollID    string `json:"poll_id"`
 486	User      User   `json:"user"`
 487	OptionIDs []int  `json:"option_ids"`
 488}
 489
 490// Poll contains information about a poll.
 491type Poll struct {
 492	ID                    string          `json:"id"`
 493	Question              string          `json:"question"`
 494	Options               []PollOption    `json:"options"`
 495	IsClosed              bool            `json:"is_closed"`
 496	IsAnonymous           bool            `json:"is_anonymous"`
 497	Type                  string          `json:"type"`
 498	AllowsMultipleAnswers bool            `json:"allows_multiple_answers"`
 499	CorrectOptionID       int             `json:"correct_option_id,omitempty"`    // optional
 500	Explanation           string          `json:"explanation,omitempty"`          // optional
 501	ExplanationEntities   []MessageEntity `json:"explanation_entities,omitempty"` // optional
 502	OpenPeriod            int             `json:"open_period,omitempty"`          // optional
 503	CloseDate             int             `json:"close_date,omitempty"`           // optional
 504}
 505
 506// Dice represents a single dice value.
 507type Dice struct {
 508	Emoji string `json:"emoji"`
 509	Value int    `json:"value"`
 510}
 511
 512// UserProfilePhotos contains a set of user profile photos.
 513type UserProfilePhotos struct {
 514	TotalCount int           `json:"total_count"`
 515	Photos     [][]PhotoSize `json:"photos"`
 516}
 517
 518// File contains information about a file to download from Telegram.
 519type File struct {
 520	FileID       string `json:"file_id"`
 521	FileUniqueID string `json:"file_unique_id"`
 522	FileSize     int    `json:"file_size,omitempty"` // optional
 523	FilePath     string `json:"file_path,omitempty"` // optional
 524}
 525
 526// Link returns a full path to the download URL for a File.
 527//
 528// It requires the Bot Token to create the link.
 529func (f *File) Link(token string) string {
 530	return fmt.Sprintf(FileEndpoint, token, f.FilePath)
 531}
 532
 533// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
 534type ReplyKeyboardMarkup struct {
 535	Keyboard        [][]KeyboardButton `json:"keyboard"`
 536	ResizeKeyboard  bool               `json:"resize_keyboard,omitempty"`   // optional
 537	OneTimeKeyboard bool               `json:"one_time_keyboard,omitempty"` // optional
 538	Selective       bool               `json:"selective,omitempty"`         // optional
 539}
 540
 541// KeyboardButton is a button within a custom keyboard.
 542type KeyboardButton struct {
 543	Text            string                  `json:"text"`
 544	RequestContact  bool                    `json:"request_contact"`
 545	RequestLocation bool                    `json:"request_location"`
 546	RequestPoll     *KeyboardButtonPollType `json:"request_poll,omitempty"`
 547}
 548
 549// KeyboardButtonPollType represents type of a poll, which is allowed to
 550// be created and sent when the corresponding button is pressed.
 551type KeyboardButtonPollType struct {
 552	Type string `json:"type"`
 553}
 554
 555// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
 556type ReplyKeyboardHide struct {
 557	HideKeyboard bool `json:"hide_keyboard"`
 558	Selective    bool `json:"selective,omitempty"` // optional
 559}
 560
 561// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
 562type ReplyKeyboardRemove struct {
 563	RemoveKeyboard bool `json:"remove_keyboard"`
 564	Selective      bool `json:"selective"`
 565}
 566
 567// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
 568type InlineKeyboardMarkup struct {
 569	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
 570}
 571
 572// InlineKeyboardButton is a button within a custom keyboard for
 573// inline query responses.
 574//
 575// Note that some values are references as even an empty string
 576// will change behavior.
 577//
 578// CallbackGame, if set, MUST be first button in first row.
 579type InlineKeyboardButton struct {
 580	Text                         string        `json:"text"`
 581	URL                          *string       `json:"url,omitempty"`                              // optional
 582	LoginURL                     *LoginURL     `json:"login_url,omitempty"`                        // optional
 583	CallbackData                 *string       `json:"callback_data,omitempty"`                    // optional
 584	SwitchInlineQuery            *string       `json:"switch_inline_query,omitempty"`              // optional
 585	SwitchInlineQueryCurrentChat *string       `json:"switch_inline_query_current_chat,omitempty"` // optional
 586	CallbackGame                 *CallbackGame `json:"callback_game,omitempty"`                    // optional
 587	Pay                          bool          `json:"pay,omitempty"`                              // optional
 588}
 589
 590// LoginURL is the parameters for the login inline keyboard button type.
 591type LoginURL struct {
 592	URL                string `json:"url"`
 593	ForwardText        string `json:"forward_text"`
 594	BotUsername        string `json:"bot_username"`
 595	RequestWriteAccess bool   `json:"request_write_access"`
 596}
 597
 598// CallbackQuery is data sent when a keyboard button with callback data
 599// is clicked.
 600type CallbackQuery struct {
 601	ID              string   `json:"id"`
 602	From            *User    `json:"from"`
 603	Message         *Message `json:"message,omitempty"`           // optional
 604	InlineMessageID string   `json:"inline_message_id,omitempty"` // optional
 605	ChatInstance    string   `json:"chat_instance"`
 606	Data            string   `json:"data,omitempty"`            // optional
 607	GameShortName   string   `json:"game_short_name,omitempty"` // optional
 608}
 609
 610// ForceReply allows the Bot to have users directly reply to it without
 611// additional interaction.
 612type ForceReply struct {
 613	ForceReply bool `json:"force_reply"`
 614	Selective  bool `json:"selective"` // optional
 615}
 616
 617// ChatMember is information about a member in a chat.
 618type ChatMember struct {
 619	User                  *User  `json:"user"`
 620	Status                string `json:"status"`
 621	CustomTitle           string `json:"custom_title,omitempty"`              // optional
 622	UntilDate             int64  `json:"until_date,omitempty"`                // optional
 623	CanBeEdited           bool   `json:"can_be_edited,omitempty"`             // optional
 624	CanPostMessages       bool   `json:"can_post_messages,omitempty"`         // optional
 625	CanEditMessages       bool   `json:"can_edit_messages,omitempty"`         // optional
 626	CanDeleteMessages     bool   `json:"can_delete_messages,omitempty"`       // optional
 627	CanRestrictMembers    bool   `json:"can_restrict_members,omitempty"`      // optional
 628	CanPromoteMembers     bool   `json:"can_promote_members,omitempty"`       // optional
 629	CanChangeInfo         bool   `json:"can_change_info,omitempty"`           // optional
 630	CanInviteUsers        bool   `json:"can_invite_users,omitempty"`          // optional
 631	CanPinMessages        bool   `json:"can_pin_messages,omitempty"`          // optional
 632	IsChatMember          bool   `json:"is_member,omitempty"`                 // optional
 633	CanSendMessages       bool   `json:"can_send_messages,omitempty"`         // optional
 634	CanSendMediaMessages  bool   `json:"can_send_media_messages,omitempty"`   // optional
 635	CanSendPolls          bool   `json:"can_send_polls,omitempty"`            // optional
 636	CanSendOtherMessages  bool   `json:"can_send_other_messages,omitempty"`   // optional
 637	CanAddWebPagePreviews bool   `json:"can_add_web_page_previews,omitempty"` // optional
 638}
 639
 640// IsCreator returns if the ChatMember was the creator of the chat.
 641func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
 642
 643// IsAdministrator returns if the ChatMember is a chat administrator.
 644func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
 645
 646// IsMember returns if the ChatMember is a current member of the chat.
 647func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
 648
 649// HasLeft returns if the ChatMember left the chat.
 650func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
 651
 652// WasKicked returns if the ChatMember was kicked from the chat.
 653func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
 654
 655// Game is a game within Telegram.
 656type Game struct {
 657	Title        string          `json:"title"`
 658	Description  string          `json:"description"`
 659	Photo        []PhotoSize     `json:"photo"`
 660	Text         string          `json:"text"`
 661	TextEntities []MessageEntity `json:"text_entities"`
 662	Animation    Animation       `json:"animation"`
 663}
 664
 665// Animation is a GIF animation demonstrating the game.
 666type Animation struct {
 667	FileID       string    `json:"file_id"`
 668	FileUniqueID string    `json:"file_unique_id"`
 669	Thumb        PhotoSize `json:"thumb"`
 670	FileName     string    `json:"file_name"`
 671	MimeType     string    `json:"mime_type"`
 672	FileSize     int       `json:"file_size"`
 673}
 674
 675// GameHighScore is a user's score and position on the leaderboard.
 676type GameHighScore struct {
 677	Position int  `json:"position"`
 678	User     User `json:"user"`
 679	Score    int  `json:"score"`
 680}
 681
 682// CallbackGame is for starting a game in an inline keyboard button.
 683type CallbackGame struct{}
 684
 685// WebhookInfo is information about a currently set webhook.
 686type WebhookInfo struct {
 687	URL                  string `json:"url"`
 688	HasCustomCertificate bool   `json:"has_custom_certificate"`
 689	PendingUpdateCount   int    `json:"pending_update_count"`
 690	LastErrorDate        int    `json:"last_error_date"`    // optional
 691	LastErrorMessage     string `json:"last_error_message"` // optional
 692	MaxConnections       int    `json:"max_connections"`    // optional
 693}
 694
 695// IsSet returns true if a webhook is currently set.
 696func (info WebhookInfo) IsSet() bool {
 697	return info.URL != ""
 698}
 699
 700// InlineQuery is a Query from Telegram for an inline request.
 701type InlineQuery struct {
 702	ID       string    `json:"id"`
 703	From     *User     `json:"from"`
 704	Location *Location `json:"location,omitempty"` // optional
 705	Query    string    `json:"query"`
 706	Offset   string    `json:"offset"`
 707}
 708
 709// InlineQueryResultArticle is an inline query response article.
 710type InlineQueryResultArticle struct {
 711	Type                string                `json:"type"`                            // required
 712	ID                  string                `json:"id"`                              // required
 713	Title               string                `json:"title"`                           // required
 714	InputMessageContent interface{}           `json:"input_message_content,omitempty"` // required
 715	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 716	URL                 string                `json:"url"`
 717	HideURL             bool                  `json:"hide_url"`
 718	Description         string                `json:"description"`
 719	ThumbURL            string                `json:"thumb_url"`
 720	ThumbWidth          int                   `json:"thumb_width"`
 721	ThumbHeight         int                   `json:"thumb_height"`
 722}
 723
 724// InlineQueryResultPhoto is an inline query response photo.
 725type InlineQueryResultPhoto struct {
 726	Type                string                `json:"type"`      // required
 727	ID                  string                `json:"id"`        // required
 728	URL                 string                `json:"photo_url"` // required
 729	MimeType            string                `json:"mime_type"`
 730	Width               int                   `json:"photo_width"`
 731	Height              int                   `json:"photo_height"`
 732	ThumbURL            string                `json:"thumb_url"`
 733	Title               string                `json:"title"`
 734	Description         string                `json:"description"`
 735	Caption             string                `json:"caption"`
 736	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 737	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 738}
 739
 740// InlineQueryResultCachedPhoto is an inline query response with cached photo.
 741type InlineQueryResultCachedPhoto struct {
 742	Type                string                `json:"type"`          // required
 743	ID                  string                `json:"id"`            // required
 744	PhotoID             string                `json:"photo_file_id"` // required
 745	Title               string                `json:"title"`
 746	Description         string                `json:"description"`
 747	Caption             string                `json:"caption"`
 748	ParseMode           string                `json:"parse_mode"`
 749	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 750	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 751}
 752
 753// InlineQueryResultGIF is an inline query response GIF.
 754type InlineQueryResultGIF struct {
 755	Type                string                `json:"type"`      // required
 756	ID                  string                `json:"id"`        // required
 757	URL                 string                `json:"gif_url"`   // required
 758	ThumbURL            string                `json:"thumb_url"` // required
 759	Width               int                   `json:"gif_width,omitempty"`
 760	Height              int                   `json:"gif_height,omitempty"`
 761	Duration            int                   `json:"gif_duration,omitempty"`
 762	Title               string                `json:"title,omitempty"`
 763	Caption             string                `json:"caption,omitempty"`
 764	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 765	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 766}
 767
 768// InlineQueryResultCachedGIF is an inline query response with cached gif.
 769type InlineQueryResultCachedGIF struct {
 770	Type                string                `json:"type"`        // required
 771	ID                  string                `json:"id"`          // required
 772	GifID               string                `json:"gif_file_id"` // required
 773	Title               string                `json:"title"`
 774	Caption             string                `json:"caption"`
 775	ParseMode           string                `json:"parse_mode"`
 776	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 777	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 778}
 779
 780// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
 781type InlineQueryResultMPEG4GIF struct {
 782	Type                string                `json:"type"`      // required
 783	ID                  string                `json:"id"`        // required
 784	URL                 string                `json:"mpeg4_url"` // required
 785	Width               int                   `json:"mpeg4_width"`
 786	Height              int                   `json:"mpeg4_height"`
 787	Duration            int                   `json:"mpeg4_duration"`
 788	ThumbURL            string                `json:"thumb_url"`
 789	Title               string                `json:"title"`
 790	Caption             string                `json:"caption"`
 791	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 792	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 793}
 794
 795// InlineQueryResultCachedMpeg4Gif is an inline query response with cached
 796// H.264/MPEG-4 AVC video without sound gif.
 797type InlineQueryResultCachedMpeg4Gif struct {
 798	Type                string                `json:"type"`          // required
 799	ID                  string                `json:"id"`            // required
 800	MGifID              string                `json:"mpeg4_file_id"` // required
 801	Title               string                `json:"title"`
 802	Caption             string                `json:"caption"`
 803	ParseMode           string                `json:"parse_mode"`
 804	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 805	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 806}
 807
 808// InlineQueryResultVideo is an inline query response video.
 809type InlineQueryResultVideo struct {
 810	Type                string                `json:"type"`      // required
 811	ID                  string                `json:"id"`        // required
 812	URL                 string                `json:"video_url"` // required
 813	MimeType            string                `json:"mime_type"` // required
 814	ThumbURL            string                `json:"thumb_url"`
 815	Title               string                `json:"title"`
 816	Caption             string                `json:"caption"`
 817	Width               int                   `json:"video_width"`
 818	Height              int                   `json:"video_height"`
 819	Duration            int                   `json:"video_duration"`
 820	Description         string                `json:"description"`
 821	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 822	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 823}
 824
 825// InlineQueryResultCachedVideo is an inline query response with cached video.
 826type InlineQueryResultCachedVideo struct {
 827	Type                string                `json:"type"`          // required
 828	ID                  string                `json:"id"`            // required
 829	VideoID             string                `json:"video_file_id"` // required
 830	Title               string                `json:"title"`         // required
 831	Description         string                `json:"description"`
 832	Caption             string                `json:"caption"`
 833	ParseMode           string                `json:"parse_mode"`
 834	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 835	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 836}
 837
 838// InlineQueryResultCachedSticker is an inline query response with cached sticker.
 839type InlineQueryResultCachedSticker struct {
 840	Type                string                `json:"type"`            // required
 841	ID                  string                `json:"id"`              // required
 842	StickerID           string                `json:"sticker_file_id"` // required
 843	Title               string                `json:"title"`           // required
 844	ParseMode           string                `json:"parse_mode"`
 845	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 846	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 847}
 848
 849// InlineQueryResultAudio is an inline query response audio.
 850type InlineQueryResultAudio struct {
 851	Type                string                `json:"type"`      // required
 852	ID                  string                `json:"id"`        // required
 853	URL                 string                `json:"audio_url"` // required
 854	Title               string                `json:"title"`     // required
 855	Caption             string                `json:"caption"`
 856	Performer           string                `json:"performer"`
 857	Duration            int                   `json:"audio_duration"`
 858	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 859	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 860}
 861
 862// InlineQueryResultCachedAudio is an inline query response with cached audio.
 863type InlineQueryResultCachedAudio struct {
 864	Type                string                `json:"type"`          // required
 865	ID                  string                `json:"id"`            // required
 866	AudioID             string                `json:"audio_file_id"` // required
 867	Caption             string                `json:"caption"`
 868	ParseMode           string                `json:"parse_mode"`
 869	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 870	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 871}
 872
 873// InlineQueryResultVoice is an inline query response voice.
 874type InlineQueryResultVoice struct {
 875	Type                string                `json:"type"`      // required
 876	ID                  string                `json:"id"`        // required
 877	URL                 string                `json:"voice_url"` // required
 878	Title               string                `json:"title"`     // required
 879	Caption             string                `json:"caption"`
 880	Duration            int                   `json:"voice_duration"`
 881	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 882	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 883}
 884
 885// InlineQueryResultCachedVoice is an inline query response with cached voice.
 886type InlineQueryResultCachedVoice struct {
 887	Type                string                `json:"type"`          // required
 888	ID                  string                `json:"id"`            // required
 889	VoiceID             string                `json:"voice_file_id"` // required
 890	Title               string                `json:"title"`         // required
 891	Caption             string                `json:"caption"`
 892	ParseMode           string                `json:"parse_mode"`
 893	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 894	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 895}
 896
 897// InlineQueryResultDocument is an inline query response document.
 898type InlineQueryResultDocument struct {
 899	Type                string                `json:"type"`  // required
 900	ID                  string                `json:"id"`    // required
 901	Title               string                `json:"title"` // required
 902	Caption             string                `json:"caption"`
 903	URL                 string                `json:"document_url"` // required
 904	MimeType            string                `json:"mime_type"`    // required
 905	Description         string                `json:"description"`
 906	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 907	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 908	ThumbURL            string                `json:"thumb_url"`
 909	ThumbWidth          int                   `json:"thumb_width"`
 910	ThumbHeight         int                   `json:"thumb_height"`
 911}
 912
 913// InlineQueryResultCachedDocument is an inline query response with cached document.
 914type InlineQueryResultCachedDocument struct {
 915	Type                string                `json:"type"`             // required
 916	ID                  string                `json:"id"`               // required
 917	DocumentID          string                `json:"document_file_id"` // required
 918	Title               string                `json:"title"`            // required
 919	Caption             string                `json:"caption"`
 920	Description         string                `json:"description"`
 921	ParseMode           string                `json:"parse_mode"`
 922	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 923	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 924}
 925
 926// InlineQueryResultLocation is an inline query response location.
 927type InlineQueryResultLocation struct {
 928	Type                string                `json:"type"`        // required
 929	ID                  string                `json:"id"`          // required
 930	Latitude            float64               `json:"latitude"`    // required
 931	Longitude           float64               `json:"longitude"`   // required
 932	LivePeriod          int                   `json:"live_period"` // optional
 933	Title               string                `json:"title"`       // required
 934	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 935	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 936	ThumbURL            string                `json:"thumb_url"`
 937	ThumbWidth          int                   `json:"thumb_width"`
 938	ThumbHeight         int                   `json:"thumb_height"`
 939}
 940
 941// InlineQueryResultContact is an inline query response contact.
 942type InlineQueryResultContact struct {
 943	Type                string                `json:"type"`         // required
 944	ID                  string                `json:"id"`           // required
 945	PhoneNumber         string                `json:"phone_number"` // required
 946	FirstName           string                `json:"first_name"`   // required
 947	LastName            string                `json:"last_name"`
 948	VCard               string                `json:"vcard"`
 949	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 950	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 951	ThumbURL            string                `json:"thumb_url"`
 952	ThumbWidth          int                   `json:"thumb_width"`
 953	ThumbHeight         int                   `json:"thumb_height"`
 954}
 955
 956// InlineQueryResultVenue is an inline query response venue.
 957type InlineQueryResultVenue struct {
 958	Type                string                `json:"type"`      // required
 959	ID                  string                `json:"id"`        // required
 960	Latitude            float64               `json:"latitude"`  // required
 961	Longitude           float64               `json:"longitude"` // required
 962	Title               string                `json:"title"`     // required
 963	Address             string                `json:"address"`   // required
 964	FoursquareID        string                `json:"foursquare_id"`
 965	FoursquareType      string                `json:"foursquare_type"`
 966	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 967	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
 968	ThumbURL            string                `json:"thumb_url"`
 969	ThumbWidth          int                   `json:"thumb_width"`
 970	ThumbHeight         int                   `json:"thumb_height"`
 971}
 972
 973// InlineQueryResultGame is an inline query response game.
 974type InlineQueryResultGame struct {
 975	Type          string                `json:"type"`
 976	ID            string                `json:"id"`
 977	GameShortName string                `json:"game_short_name"`
 978	ReplyMarkup   *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 979}
 980
 981// ChosenInlineResult is an inline query result chosen by a User
 982type ChosenInlineResult struct {
 983	ResultID        string    `json:"result_id"`
 984	From            *User     `json:"from"`
 985	Location        *Location `json:"location"`
 986	InlineMessageID string    `json:"inline_message_id"`
 987	Query           string    `json:"query"`
 988}
 989
 990// InputTextMessageContent contains text for displaying
 991// as an inline query result.
 992type InputTextMessageContent struct {
 993	Text                  string `json:"message_text"`
 994	ParseMode             string `json:"parse_mode"`
 995	DisableWebPagePreview bool   `json:"disable_web_page_preview"`
 996}
 997
 998// InputLocationMessageContent contains a location for displaying
 999// as an inline query result.
1000type InputLocationMessageContent struct {
1001	Latitude  float64 `json:"latitude"`
1002	Longitude float64 `json:"longitude"`
1003}
1004
1005// InputVenueMessageContent contains a venue for displaying
1006// as an inline query result.
1007type InputVenueMessageContent struct {
1008	Latitude     float64 `json:"latitude"`
1009	Longitude    float64 `json:"longitude"`
1010	Title        string  `json:"title"`
1011	Address      string  `json:"address"`
1012	FoursquareID string  `json:"foursquare_id"`
1013}
1014
1015// InputContactMessageContent contains a contact for displaying
1016// as an inline query result.
1017type InputContactMessageContent struct {
1018	PhoneNumber string `json:"phone_number"`
1019	FirstName   string `json:"first_name"`
1020	LastName    string `json:"last_name"`
1021	VCard       string `json:"vcard"`
1022}
1023
1024// Invoice contains basic information about an invoice.
1025type Invoice struct {
1026	Title          string `json:"title"`
1027	Description    string `json:"description"`
1028	StartParameter string `json:"start_parameter"`
1029	Currency       string `json:"currency"`
1030	TotalAmount    int    `json:"total_amount"`
1031}
1032
1033// LabeledPrice represents a portion of the price for goods or services.
1034type LabeledPrice struct {
1035	Label  string `json:"label"`
1036	Amount int    `json:"amount"`
1037}
1038
1039// ShippingAddress represents a shipping address.
1040type ShippingAddress struct {
1041	CountryCode string `json:"country_code"`
1042	State       string `json:"state"`
1043	City        string `json:"city"`
1044	StreetLine1 string `json:"street_line1"`
1045	StreetLine2 string `json:"street_line2"`
1046	PostCode    string `json:"post_code"`
1047}
1048
1049// OrderInfo represents information about an order.
1050type OrderInfo struct {
1051	Name            string           `json:"name,omitempty"`
1052	PhoneNumber     string           `json:"phone_number,omitempty"`
1053	Email           string           `json:"email,omitempty"`
1054	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
1055}
1056
1057// ShippingOption represents one shipping option.
1058type ShippingOption struct {
1059	ID     string         `json:"id"`
1060	Title  string         `json:"title"`
1061	Prices []LabeledPrice `json:"prices"`
1062}
1063
1064// SuccessfulPayment contains basic information about a successful payment.
1065type SuccessfulPayment struct {
1066	Currency                string     `json:"currency"`
1067	TotalAmount             int        `json:"total_amount"`
1068	InvoicePayload          string     `json:"invoice_payload"`
1069	ShippingOptionID        string     `json:"shipping_option_id,omitempty"`
1070	OrderInfo               *OrderInfo `json:"order_info,omitempty"`
1071	TelegramPaymentChargeID string     `json:"telegram_payment_charge_id"`
1072	ProviderPaymentChargeID string     `json:"provider_payment_charge_id"`
1073}
1074
1075// ShippingQuery contains information about an incoming shipping query.
1076type ShippingQuery struct {
1077	ID              string           `json:"id"`
1078	From            *User            `json:"from"`
1079	InvoicePayload  string           `json:"invoice_payload"`
1080	ShippingAddress *ShippingAddress `json:"shipping_address"`
1081}
1082
1083// PreCheckoutQuery contains information about an incoming pre-checkout query.
1084type PreCheckoutQuery struct {
1085	ID               string     `json:"id"`
1086	From             *User      `json:"from"`
1087	Currency         string     `json:"currency"`
1088	TotalAmount      int        `json:"total_amount"`
1089	InvoicePayload   string     `json:"invoice_payload"`
1090	ShippingOptionID string     `json:"shipping_option_id,omitempty"`
1091	OrderInfo        *OrderInfo `json:"order_info,omitempty"`
1092}
1093
1094// StickerSet is a collection of stickers.
1095type StickerSet struct {
1096	Name          string     `json:"name"`
1097	Title         string     `json:"title"`
1098	IsAnimated    bool       `json:"is_animated"`
1099	ContainsMasks bool       `json:"contains_masks"`
1100	Stickers      []Sticker  `json:"stickers"`
1101	Thumb         *PhotoSize `json:"thumb"`
1102}
1103
1104// BotCommand represents Telegram's understanding of a command.
1105type BotCommand struct {
1106	Command     string `json:"command"`
1107	Description string `json:"description"`
1108}
1109
1110// BaseInputMedia is a base type for the InputMedia types.
1111type BaseInputMedia struct {
1112	Type      string `json:"type"`
1113	Media     string `json:"media"`
1114	Caption   string `json:"caption"`
1115	ParseMode string `json:"parse_mode"`
1116}
1117
1118// InputMediaPhoto is a photo to send as part of a media group.
1119type InputMediaPhoto struct {
1120	BaseInputMedia
1121}
1122
1123// InputMediaVideo is a video to send as part of a media group.
1124type InputMediaVideo struct {
1125	BaseInputMedia
1126	Width             int  `json:"width"`
1127	Height            int  `json:"height"`
1128	Duration          int  `json:"duration"`
1129	SupportsStreaming bool `json:"supports_streaming"`
1130}
1131
1132// InputMediaAnimation is an animation to send as part of a media group.
1133type InputMediaAnimation struct {
1134	BaseInputMedia
1135	Width    int `json:"width"`
1136	Height   int `json:"height"`
1137	Duration int `json:"duration"`
1138}
1139
1140// InputMediaAudio is a audio to send as part of a media group.
1141type InputMediaAudio struct {
1142	BaseInputMedia
1143	Duration  int    `json:"duration"`
1144	Performer string `json:"performer"`
1145	Title     string `json:"title"`
1146}
1147
1148// InputMediaDocument is a audio to send as part of a media group.
1149type InputMediaDocument struct {
1150	BaseInputMedia
1151}
1152
1153// Error is an error containing extra information returned by the Telegram API.
1154type Error struct {
1155	Code    int
1156	Message string
1157	ResponseParameters
1158}
1159
1160// Error message string.
1161func (e Error) Error() string {
1162	return e.Message
1163}