all repos — telegram-bot-api @ ac5306ce0c6d68946d7d5a029c0338e758b5fc96

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