all repos — telegram-bot-api @ 25c494b33521571360e1e71e78159e8510c64c51

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"`
  17	ErrorCode   int                 `json:"error_code"`
  18	Description string              `json:"description"`
  19	Parameters  *ResponseParameters `json:"parameters"`
  20}
  21
  22// ResponseParameters are various errors that can be returned in APIResponse.
  23type ResponseParameters struct {
  24	MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
  25	RetryAfter      int   `json:"retry_after"`        // 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"`
  32	EditedMessage      *Message            `json:"edited_message"`
  33	ChannelPost        *Message            `json:"channel_post"`
  34	EditedChannelPost  *Message            `json:"edited_channel_post"`
  35	InlineQuery        *InlineQuery        `json:"inline_query"`
  36	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
  37	CallbackQuery      *CallbackQuery      `json:"callback_query"`
  38	ShippingQuery      *ShippingQuery      `json:"shipping_query"`
  39	PreCheckoutQuery   *PreCheckoutQuery   `json:"pre_checkout_query"`
  40}
  41
  42// UpdatesChannel is the channel for getting updates.
  43type UpdatesChannel <-chan Update
  44
  45// Clear discards all unprocessed incoming updates.
  46func (ch UpdatesChannel) Clear() {
  47	for len(ch) != 0 {
  48		<-ch
  49	}
  50}
  51
  52// User is a user on Telegram.
  53type User struct {
  54	ID           int    `json:"id"`
  55	FirstName    string `json:"first_name"`
  56	LastName     string `json:"last_name"`     // optional
  57	UserName     string `json:"username"`      // optional
  58	LanguageCode string `json:"language_code"` // optional
  59	IsBot        bool   `json:"is_bot"`        // optional
  60}
  61
  62// String displays a simple text version of a user.
  63//
  64// It is normally a user's username, but falls back to a first/last
  65// name as available.
  66func (u *User) String() string {
  67	if u == nil {
  68		return ""
  69	}
  70	if u.UserName != "" {
  71		return u.UserName
  72	}
  73
  74	name := u.FirstName
  75	if u.LastName != "" {
  76		name += " " + u.LastName
  77	}
  78
  79	return name
  80}
  81
  82// GroupChat is a group chat.
  83type GroupChat struct {
  84	ID    int    `json:"id"`
  85	Title string `json:"title"`
  86}
  87
  88// ChatPhoto represents a chat photo.
  89type ChatPhoto struct {
  90	SmallFileID string `json:"small_file_id"`
  91	BigFileID   string `json:"big_file_id"`
  92}
  93
  94// Chat contains information about the place a message was sent.
  95type Chat struct {
  96	ID                  int64      `json:"id"`
  97	Type                string     `json:"type"`
  98	Title               string     `json:"title"`                          // optional
  99	UserName            string     `json:"username"`                       // optional
 100	FirstName           string     `json:"first_name"`                     // optional
 101	LastName            string     `json:"last_name"`                      // optional
 102	AllMembersAreAdmins bool       `json:"all_members_are_administrators"` // optional
 103	Photo               *ChatPhoto `json:"photo"`
 104	Description         string     `json:"description,omitempty"` // optional
 105	InviteLink          string     `json:"invite_link,omitempty"` // optional
 106	PinnedMessage       *Message   `json:"pinned_message"`        // optional
 107}
 108
 109// IsPrivate returns if the Chat is a private conversation.
 110func (c Chat) IsPrivate() bool {
 111	return c.Type == "private"
 112}
 113
 114// IsGroup returns if the Chat is a group.
 115func (c Chat) IsGroup() bool {
 116	return c.Type == "group"
 117}
 118
 119// IsSuperGroup returns if the Chat is a supergroup.
 120func (c Chat) IsSuperGroup() bool {
 121	return c.Type == "supergroup"
 122}
 123
 124// IsChannel returns if the Chat is a channel.
 125func (c Chat) IsChannel() bool {
 126	return c.Type == "channel"
 127}
 128
 129// ChatConfig returns a ChatConfig struct for chat related methods.
 130func (c Chat) ChatConfig() ChatConfig {
 131	return ChatConfig{ChatID: c.ID}
 132}
 133
 134// Message is returned by almost every request, and contains data about
 135// almost anything.
 136type Message struct {
 137	// MessageID is a unique message identifier inside this chat
 138	MessageID int `json:"message_id"`
 139	// From is a sender, empty for messages sent to channels;
 140	// optional
 141	From *User `json:"from"`
 142	// Date of the message was sent in Unix time
 143	Date int `json:"date"`
 144	// Chat is the conversation the message belongs to
 145	Chat *Chat `json:"chat"`
 146	// ForwardFrom for forwarded messages, sender of the original message;
 147	// optional
 148	ForwardFrom *User `json:"forward_from"`
 149	// ForwardFromChat for messages forwarded from channels,
 150	// information about the original channel;
 151	// optional
 152	ForwardFromChat *Chat `json:"forward_from_chat"`
 153	// ForwardFromMessageID for messages forwarded from channels,
 154	// identifier of the original message in the channel;
 155	// optional
 156	ForwardFromMessageID int `json:"forward_from_message_id"`
 157	// ForwardDate for forwarded messages, date the original message was sent in Unix time;
 158	// optional
 159	ForwardDate int `json:"forward_date"`
 160	// ReplyToMessage for replies, the original message.
 161	// Note that the Message object in this field will not contain further ReplyToMessage fields
 162	// even if it itself is a reply;
 163	// optional
 164	ReplyToMessage *Message `json:"reply_to_message"`
 165	// ViaBot through which the message was sent;
 166	// optional
 167	ViaBot *User `json:"via_bot"`
 168	// EditDate of the message was last edited in Unix time;
 169	// optional
 170	EditDate int `json:"edit_date"`
 171	// MediaGroupID is the unique identifier of a media message group this message belongs to;
 172	// optional
 173	MediaGroupID string `json:"media_group_id"`
 174	// AuthorSignature is the signature of the post author for messages in channels;
 175	// optional
 176	AuthorSignature string `json:"author_signature"`
 177	// Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
 178	// optional
 179	Text string `json:"text"`
 180	// Entities is for text messages, special entities like usernames,
 181	// URLs, bot commands, etc. that appear in the text;
 182	// optional
 183	Entities *[]MessageEntity `json:"entities"`
 184	// CaptionEntities;
 185	// optional
 186	CaptionEntities *[]MessageEntity `json:"caption_entities"`
 187	// Audio message is an audio file, information about the file;
 188	// optional
 189	Audio *Audio `json:"audio"`
 190	// Document message is a general file, information about the file;
 191	// optional
 192	Document *Document `json:"document"`
 193	// Animation message is an animation, information about the animation.
 194	// For backward compatibility, when this field is set, the document field will also be set;
 195	// optional
 196	Animation *ChatAnimation `json:"animation"`
 197	// Game message is a game, information about the game;
 198	// optional
 199	Game *Game `json:"game"`
 200	// Photo message is a photo, available sizes of the photo;
 201	// optional
 202	Photo *[]PhotoSize `json:"photo"`
 203	// Sticker message is a sticker, information about the sticker;
 204	// optional
 205	Sticker *Sticker `json:"sticker"`
 206	// Video message is a video, information about the video;
 207	// optional
 208	Video *Video `json:"video"`
 209	// VideoNote message is a video note, information about the video message;
 210	// optional
 211	VideoNote *VideoNote `json:"video_note"`
 212	// Voice message is a voice message, information about the file;
 213	// optional
 214	Voice *Voice `json:"voice"`
 215	// Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
 216	// optional
 217	Caption string `json:"caption"`
 218	// Contact message is a shared contact, information about the contact;
 219	// optional
 220	Contact *Contact `json:"contact"`
 221	// Location message is a shared location, information about the location;
 222	// optional
 223	Location *Location `json:"location"`
 224	// Venue message is a venue, information about the venue.
 225	// For backward compatibility, when this field is set, the location field will also be set;
 226	// optional
 227	Venue *Venue `json:"venue"`
 228	// NewChatMembers that were added to the group or supergroup
 229	// and information about them (the bot itself may be one of these members);
 230	// optional
 231	NewChatMembers *[]User `json:"new_chat_members"`
 232	// LeftChatMember is a member was removed from the group,
 233	// information about them (this member may be the bot itself);
 234	// optional
 235	LeftChatMember *User `json:"left_chat_member"`
 236	// NewChatTitle is a chat title was changed to this value;
 237	// optional
 238	NewChatTitle string `json:"new_chat_title"`
 239	// NewChatPhoto is a chat photo was change to this value;
 240	// optional
 241	NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
 242	// DeleteChatPhoto is a service message: the chat photo was deleted;
 243	// optional
 244	DeleteChatPhoto bool `json:"delete_chat_photo"`
 245	// GroupChatCreated is a service message: the group has been created;
 246	// optional
 247	GroupChatCreated bool `json:"group_chat_created"`
 248	// SuperGroupChatCreated is a service message: the supergroup has been created.
 249	// This field can't be received in a message coming through updates,
 250	// because bot can't be a member of a supergroup when it is created.
 251	// It can only be found in ReplyToMessage if someone replies to a very first message
 252	// in a directly created supergroup;
 253	// optional
 254	SuperGroupChatCreated bool `json:"supergroup_chat_created"`
 255	// ChannelChatCreated is a service message: the channel has been created.
 256	// This field can't be received in a message coming through updates,
 257	// because bot can't be a member of a channel when it is created.
 258	// It can only be found in ReplyToMessage
 259	// if someone replies to a very first message in a channel;
 260	// optional
 261	ChannelChatCreated bool `json:"channel_chat_created"`
 262	// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
 263	// This number may be greater than 32 bits and some programming languages
 264	// may have difficulty/silent defects in interpreting it.
 265	// But it is smaller than 52 bits, so a signed 64 bit integer
 266	// or double-precision float type are safe for storing this identifier;
 267	// optional
 268	MigrateToChatID int64 `json:"migrate_to_chat_id"`
 269	// MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
 270	// This number may be greater than 32 bits and some programming languages
 271	// may have difficulty/silent defects in interpreting it.
 272	// But it is smaller than 52 bits, so a signed 64 bit integer
 273	// or double-precision float type are safe for storing this identifier;
 274	// optional
 275	MigrateFromChatID int64 `json:"migrate_from_chat_id"`
 276	// PinnedMessage is a specified message was pinned.
 277	// Note that the Message object in this field will not contain further ReplyToMessage
 278	// fields even if it is itself a reply;
 279	// optional
 280	PinnedMessage *Message `json:"pinned_message"`
 281	// Invoice message is an invoice for a payment;
 282	// optional
 283	Invoice *Invoice `json:"invoice"`
 284	// SuccessfulPayment message is a service message about a successful payment,
 285	// information about the payment;
 286	// optional
 287	SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
 288	// PassportData is a Telegram Passport data;
 289	// optional
 290	PassportData *PassportData `json:"passport_data,omitempty"`
 291}
 292
 293// Time converts the message timestamp into a Time.
 294func (m *Message) Time() time.Time {
 295	return time.Unix(int64(m.Date), 0)
 296}
 297
 298// IsCommand returns true if message starts with a "bot_command" entity.
 299func (m *Message) IsCommand() bool {
 300	if m.Entities == nil || len(*m.Entities) == 0 {
 301		return false
 302	}
 303
 304	entity := (*m.Entities)[0]
 305	return entity.Offset == 0 && entity.IsCommand()
 306}
 307
 308// Command checks if the message was a command and if it was, returns the
 309// command. If the Message was not a command, it returns an empty string.
 310//
 311// If the command contains the at name syntax, it is removed. Use
 312// CommandWithAt() if you do not want that.
 313func (m *Message) Command() string {
 314	command := m.CommandWithAt()
 315
 316	if i := strings.Index(command, "@"); i != -1 {
 317		command = command[:i]
 318	}
 319
 320	return command
 321}
 322
 323// CommandWithAt checks if the message was a command and if it was, returns the
 324// command. If the Message was not a command, it returns an empty string.
 325//
 326// If the command contains the at name syntax, it is not removed. Use Command()
 327// if you want that.
 328func (m *Message) CommandWithAt() string {
 329	if !m.IsCommand() {
 330		return ""
 331	}
 332
 333	// IsCommand() checks that the message begins with a bot_command entity
 334	entity := (*m.Entities)[0]
 335	return m.Text[1:entity.Length]
 336}
 337
 338// CommandArguments checks if the message was a command and if it was,
 339// returns all text after the command name. If the Message was not a
 340// command, it returns an empty string.
 341//
 342// Note: The first character after the command name is omitted:
 343// - "/foo bar baz" yields "bar baz", not " bar baz"
 344// - "/foo-bar baz" yields "bar baz", too
 345// Even though the latter is not a command conforming to the spec, the API
 346// marks "/foo" as command entity.
 347func (m *Message) CommandArguments() string {
 348	if !m.IsCommand() {
 349		return ""
 350	}
 351
 352	// IsCommand() checks that the message begins with a bot_command entity
 353	entity := (*m.Entities)[0]
 354	if len(m.Text) == entity.Length {
 355		return "" // The command makes up the whole message
 356	}
 357
 358	return m.Text[entity.Length+1:]
 359}
 360
 361// MessageEntity contains information about data in a Message.
 362type MessageEntity struct {
 363	Type   string `json:"type"`
 364	Offset int    `json:"offset"`
 365	Length int    `json:"length"`
 366	URL    string `json:"url"`  // optional
 367	User   *User  `json:"user"` // optional
 368}
 369
 370// ParseURL attempts to parse a URL contained within a MessageEntity.
 371func (e MessageEntity) ParseURL() (*url.URL, error) {
 372	if e.URL == "" {
 373		return nil, errors.New(ErrBadURL)
 374	}
 375
 376	return url.Parse(e.URL)
 377}
 378
 379// IsMention returns true if the type of the message entity is "mention" (@username).
 380func (e MessageEntity) IsMention() bool {
 381	return e.Type == "mention"
 382}
 383
 384// IsHashtag returns true if the type of the message entity is "hashtag".
 385func (e MessageEntity) IsHashtag() bool {
 386	return e.Type == "hashtag"
 387}
 388
 389// IsCommand returns true if the type of the message entity is "bot_command".
 390func (e MessageEntity) IsCommand() bool {
 391	return e.Type == "bot_command"
 392}
 393
 394// IsUrl returns true if the type of the message entity is "url".
 395func (e MessageEntity) IsUrl() bool {
 396	return e.Type == "url"
 397}
 398
 399// IsEmail returns true if the type of the message entity is "email".
 400func (e MessageEntity) IsEmail() bool {
 401	return e.Type == "email"
 402}
 403
 404// IsBold returns true if the type of the message entity is "bold" (bold text).
 405func (e MessageEntity) IsBold() bool {
 406	return e.Type == "bold"
 407}
 408
 409// IsItalic returns true if the type of the message entity is "italic" (italic text).
 410func (e MessageEntity) IsItalic() bool {
 411	return e.Type == "italic"
 412}
 413
 414// IsCode returns true if the type of the message entity is "code" (monowidth string).
 415func (e MessageEntity) IsCode() bool {
 416	return e.Type == "code"
 417}
 418
 419// IsPre returns true if the type of the message entity is "pre" (monowidth block).
 420func (e MessageEntity) IsPre() bool {
 421	return e.Type == "pre"
 422}
 423
 424// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
 425func (e MessageEntity) IsTextLink() bool {
 426	return e.Type == "text_link"
 427}
 428
 429// PhotoSize contains information about photos.
 430type PhotoSize struct {
 431	FileID   string `json:"file_id"`
 432	Width    int    `json:"width"`
 433	Height   int    `json:"height"`
 434	FileSize int    `json:"file_size"` // optional
 435}
 436
 437// Audio contains information about audio.
 438type Audio struct {
 439	FileID    string `json:"file_id"`
 440	Duration  int    `json:"duration"`
 441	Performer string `json:"performer"` // optional
 442	Title     string `json:"title"`     // optional
 443	MimeType  string `json:"mime_type"` // optional
 444	FileSize  int    `json:"file_size"` // optional
 445}
 446
 447// Document contains information about a document.
 448type Document struct {
 449	FileID    string     `json:"file_id"`
 450	Thumbnail *PhotoSize `json:"thumb"`     // optional
 451	FileName  string     `json:"file_name"` // optional
 452	MimeType  string     `json:"mime_type"` // optional
 453	FileSize  int        `json:"file_size"` // optional
 454}
 455
 456// Sticker contains information about a sticker.
 457type Sticker struct {
 458	FileUniqueID string     `json:"file_unique_id"`
 459	FileID       string     `json:"file_id"`
 460	Width        int        `json:"width"`
 461	Height       int        `json:"height"`
 462	Thumbnail    *PhotoSize `json:"thumb"`       // optional
 463	Emoji        string     `json:"emoji"`       // optional
 464	FileSize     int        `json:"file_size"`   // optional
 465	SetName      string     `json:"set_name"`    // optional
 466	IsAnimated   bool       `json:"is_animated"` // optional
 467}
 468
 469// StickerSet contains information about an sticker set.
 470type StickerSet struct {
 471	Name          string    `json:"name"`
 472	Title         string    `json:"title"`
 473	IsAnimated    bool      `json:"is_animated"`
 474	ContainsMasks bool      `json:"contains_masks"`
 475	Stickers      []Sticker `json:"stickers"`
 476}
 477
 478// ChatAnimation contains information about an animation.
 479type ChatAnimation struct {
 480	FileID    string     `json:"file_id"`
 481	Width     int        `json:"width"`
 482	Height    int        `json:"height"`
 483	Duration  int        `json:"duration"`
 484	Thumbnail *PhotoSize `json:"thumb"`     // optional
 485	FileName  string     `json:"file_name"` // optional
 486	MimeType  string     `json:"mime_type"` // optional
 487	FileSize  int        `json:"file_size"` // optional
 488}
 489
 490// Video contains information about a video.
 491type Video struct {
 492	FileID    string     `json:"file_id"`
 493	Width     int        `json:"width"`
 494	Height    int        `json:"height"`
 495	Duration  int        `json:"duration"`
 496	Thumbnail *PhotoSize `json:"thumb"`     // optional
 497	MimeType  string     `json:"mime_type"` // optional
 498	FileSize  int        `json:"file_size"` // optional
 499}
 500
 501// VideoNote contains information about a video.
 502type VideoNote struct {
 503	FileID    string     `json:"file_id"`
 504	Length    int        `json:"length"`
 505	Duration  int        `json:"duration"`
 506	Thumbnail *PhotoSize `json:"thumb"`     // optional
 507	FileSize  int        `json:"file_size"` // optional
 508}
 509
 510// Voice contains information about a voice.
 511type Voice struct {
 512	FileID   string `json:"file_id"`
 513	Duration int    `json:"duration"`
 514	MimeType string `json:"mime_type"` // optional
 515	FileSize int    `json:"file_size"` // optional
 516}
 517
 518// Contact contains information about a contact.
 519//
 520// Note that LastName and UserID may be empty.
 521type Contact struct {
 522	PhoneNumber string `json:"phone_number"`
 523	FirstName   string `json:"first_name"`
 524	LastName    string `json:"last_name"` // optional
 525	UserID      int    `json:"user_id"`   // optional
 526}
 527
 528// Location contains information about a place.
 529type Location struct {
 530	Longitude float64 `json:"longitude"`
 531	Latitude  float64 `json:"latitude"`
 532}
 533
 534// Venue contains information about a venue, including its Location.
 535type Venue struct {
 536	Location     Location `json:"location"`
 537	Title        string   `json:"title"`
 538	Address      string   `json:"address"`
 539	FoursquareID string   `json:"foursquare_id"` // optional
 540}
 541
 542// UserProfilePhotos contains a set of user profile photos.
 543type UserProfilePhotos struct {
 544	TotalCount int           `json:"total_count"`
 545	Photos     [][]PhotoSize `json:"photos"`
 546}
 547
 548// File contains information about a file to download from Telegram.
 549type File struct {
 550	FileID   string `json:"file_id"`
 551	FileSize int    `json:"file_size"` // optional
 552	FilePath string `json:"file_path"` // optional
 553}
 554
 555// Link returns a full path to the download URL for a File.
 556//
 557// It requires the Bot Token to create the link.
 558func (f *File) Link(token string) string {
 559	return fmt.Sprintf(FileEndpoint, token, f.FilePath)
 560}
 561
 562// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
 563type ReplyKeyboardMarkup struct {
 564	Keyboard        [][]KeyboardButton `json:"keyboard"`
 565	ResizeKeyboard  bool               `json:"resize_keyboard"`   // optional
 566	OneTimeKeyboard bool               `json:"one_time_keyboard"` // optional
 567	Selective       bool               `json:"selective"`         // optional
 568}
 569
 570// KeyboardButton is a button within a custom keyboard.
 571type KeyboardButton struct {
 572	Text            string `json:"text"`
 573	RequestContact  bool   `json:"request_contact"`
 574	RequestLocation bool   `json:"request_location"`
 575}
 576
 577// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
 578type ReplyKeyboardHide struct {
 579	HideKeyboard bool `json:"hide_keyboard"`
 580	Selective    bool `json:"selective"` // optional
 581}
 582
 583// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
 584type ReplyKeyboardRemove struct {
 585	RemoveKeyboard bool `json:"remove_keyboard"`
 586	Selective      bool `json:"selective"`
 587}
 588
 589// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
 590type InlineKeyboardMarkup struct {
 591	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
 592}
 593
 594// InlineKeyboardButton is a button within a custom keyboard for
 595// inline query responses.
 596//
 597// Note that some values are references as even an empty string
 598// will change behavior.
 599//
 600// CallbackGame, if set, MUST be first button in first row.
 601type InlineKeyboardButton struct {
 602	Text                         string        `json:"text"`
 603	URL                          *string       `json:"url,omitempty"`                              // optional
 604	CallbackData                 *string       `json:"callback_data,omitempty"`                    // optional
 605	SwitchInlineQuery            *string       `json:"switch_inline_query,omitempty"`              // optional
 606	SwitchInlineQueryCurrentChat *string       `json:"switch_inline_query_current_chat,omitempty"` // optional
 607	CallbackGame                 *CallbackGame `json:"callback_game,omitempty"`                    // optional
 608	Pay                          bool          `json:"pay,omitempty"`                              // optional
 609}
 610
 611// CallbackQuery is data sent when a keyboard button with callback data
 612// is clicked.
 613type CallbackQuery struct {
 614	ID              string   `json:"id"`
 615	From            *User    `json:"from"`
 616	Message         *Message `json:"message"`           // optional
 617	InlineMessageID string   `json:"inline_message_id"` // optional
 618	ChatInstance    string   `json:"chat_instance"`
 619	Data            string   `json:"data"`            // optional
 620	GameShortName   string   `json:"game_short_name"` // optional
 621}
 622
 623// ForceReply allows the Bot to have users directly reply to it without
 624// additional interaction.
 625type ForceReply struct {
 626	ForceReply bool `json:"force_reply"`
 627	Selective  bool `json:"selective"` // optional
 628}
 629
 630// ChatMember is information about a member in a chat.
 631type ChatMember struct {
 632	User                  *User  `json:"user"`
 633	Status                string `json:"status"`
 634	CustomTitle           string `json:"custom_title,omitempty"`              // optional
 635	UntilDate             int64  `json:"until_date,omitempty"`                // optional
 636	CanBeEdited           bool   `json:"can_be_edited,omitempty"`             // optional
 637	CanChangeInfo         bool   `json:"can_change_info,omitempty"`           // optional
 638	CanPostMessages       bool   `json:"can_post_messages,omitempty"`         // optional
 639	CanEditMessages       bool   `json:"can_edit_messages,omitempty"`         // optional
 640	CanDeleteMessages     bool   `json:"can_delete_messages,omitempty"`       // optional
 641	CanInviteUsers        bool   `json:"can_invite_users,omitempty"`          // optional
 642	CanRestrictMembers    bool   `json:"can_restrict_members,omitempty"`      // optional
 643	CanPinMessages        bool   `json:"can_pin_messages,omitempty"`          // optional
 644	CanPromoteMembers     bool   `json:"can_promote_members,omitempty"`       // optional
 645	CanSendMessages       bool   `json:"can_send_messages,omitempty"`         // optional
 646	CanSendMediaMessages  bool   `json:"can_send_media_messages,omitempty"`   // optional
 647	CanSendOtherMessages  bool   `json:"can_send_other_messages,omitempty"`   // optional
 648	CanAddWebPagePreviews bool   `json:"can_add_web_page_previews,omitempty"` // optional
 649}
 650
 651// IsCreator returns if the ChatMember was the creator of the chat.
 652func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
 653
 654// IsAdministrator returns if the ChatMember is a chat administrator.
 655func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
 656
 657// IsMember returns if the ChatMember is a current member of the chat.
 658func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
 659
 660// HasLeft returns if the ChatMember left the chat.
 661func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
 662
 663// WasKicked returns if the ChatMember was kicked from the chat.
 664func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
 665
 666// Game is a game within Telegram.
 667type Game struct {
 668	Title        string          `json:"title"`
 669	Description  string          `json:"description"`
 670	Photo        []PhotoSize     `json:"photo"`
 671	Text         string          `json:"text"`
 672	TextEntities []MessageEntity `json:"text_entities"`
 673	Animation    Animation       `json:"animation"`
 674}
 675
 676// Animation is a GIF animation demonstrating the game.
 677type Animation struct {
 678	FileID   string    `json:"file_id"`
 679	Thumb    PhotoSize `json:"thumb"`
 680	FileName string    `json:"file_name"`
 681	MimeType string    `json:"mime_type"`
 682	FileSize int       `json:"file_size"`
 683}
 684
 685// GameHighScore is a user's score and position on the leaderboard.
 686type GameHighScore struct {
 687	Position int  `json:"position"`
 688	User     User `json:"user"`
 689	Score    int  `json:"score"`
 690}
 691
 692// CallbackGame is for starting a game in an inline keyboard button.
 693type CallbackGame struct{}
 694
 695// WebhookInfo is information about a currently set webhook.
 696type WebhookInfo struct {
 697	URL                  string `json:"url"`
 698	HasCustomCertificate bool   `json:"has_custom_certificate"`
 699	PendingUpdateCount   int    `json:"pending_update_count"`
 700	LastErrorDate        int    `json:"last_error_date"`    // optional
 701	LastErrorMessage     string `json:"last_error_message"` // optional
 702	MaxConnections       int    `json:"max_connections"`    // optional
 703}
 704
 705// IsSet returns true if a webhook is currently set.
 706func (info WebhookInfo) IsSet() bool {
 707	return info.URL != ""
 708}
 709
 710// InputMediaPhoto contains a photo for displaying as part of a media group.
 711type InputMediaPhoto struct {
 712	Type      string `json:"type"`
 713	Media     string `json:"media"`
 714	Caption   string `json:"caption"`
 715	ParseMode string `json:"parse_mode"`
 716}
 717
 718// InputMediaVideo contains a video for displaying as part of a media group.
 719type InputMediaVideo struct {
 720	Type  string `json:"type"`
 721	Media string `json:"media"`
 722	// thumb intentionally missing as it is not currently compatible
 723	Caption           string `json:"caption"`
 724	ParseMode         string `json:"parse_mode"`
 725	Width             int    `json:"width"`
 726	Height            int    `json:"height"`
 727	Duration          int    `json:"duration"`
 728	SupportsStreaming bool   `json:"supports_streaming"`
 729}
 730
 731// InlineQuery is a Query from Telegram for an inline request.
 732type InlineQuery struct {
 733	// ID unique identifier for this query
 734	ID string `json:"id"`
 735	// From sender
 736	From *User `json:"from"`
 737	// Location sender location, only for bots that request user location.
 738	//
 739	// optional
 740	Location *Location `json:"location"`
 741	// Query text of the query (up to 256 characters).
 742	Query string `json:"query"`
 743	// Offset of the results to be returned, can be controlled by the bot.
 744	Offset string `json:"offset"`
 745}
 746
 747// InlineQueryResultArticle is an inline query response article.
 748type InlineQueryResultArticle struct {
 749	// Type of the result, must be article.
 750	//
 751	// required
 752	Type string `json:"type"`
 753	// ID unique identifier for this result, 1-64 Bytes.
 754	//
 755	// required
 756	ID string `json:"id"`
 757	// Title of the result
 758	//
 759	// required
 760	Title string `json:"title"`
 761	// InputMessageContent content of the message to be sent.
 762	//
 763	// required
 764	InputMessageContent interface{} `json:"input_message_content,omitempty"`
 765	// ReplyMarkup Inline keyboard attached to the message.
 766	//
 767	// optional
 768	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 769	// URL of the result.
 770	//
 771	// optional
 772	URL string `json:"url"`
 773	// HideURL pass True, if you don't want the URL to be shown in the message.
 774	//
 775	// optional
 776	HideURL bool `json:"hide_url"`
 777	// Description short description of the result.
 778	//
 779	// optional
 780	Description string `json:"description"`
 781	// ThumbURL url of the thumbnail for the result
 782	//
 783	// optional
 784	ThumbURL string `json:"thumb_url"`
 785	// ThumbWidth thumbnail width
 786	//
 787	// optional
 788	ThumbWidth int `json:"thumb_width"`
 789	// ThumbHeight thumbnail height
 790	//
 791	// optional
 792	ThumbHeight int `json:"thumb_height"`
 793}
 794
 795// InlineQueryResultPhoto is an inline query response photo.
 796type InlineQueryResultPhoto struct {
 797	// Type of the result, must be article.
 798	//
 799	// required
 800	Type string `json:"type"`
 801	// ID unique identifier for this result, 1-64 Bytes.
 802	//
 803	// required
 804	ID string `json:"id"`
 805	// URL a valid URL of the photo. Photo must be in jpeg format.
 806	// Photo size must not exceed 5MB.
 807	URL string `json:"photo_url"`
 808	// MimeType
 809	MimeType string `json:"mime_type"`
 810	// Width of the photo
 811	//
 812	// optional
 813	Width int `json:"photo_width"`
 814	// Height of the photo
 815	//
 816	// optional
 817	Height int `json:"photo_height"`
 818	// ThumbURL url of the thumbnail for the photo.
 819	//
 820	// optional
 821	ThumbURL string `json:"thumb_url"`
 822	// Title for the result
 823	//
 824	// optional
 825	Title string `json:"title"`
 826	// Description short description of the result
 827	//
 828	// optional
 829	Description string `json:"description"`
 830	// Caption of the photo to be sent, 0-1024 characters after entities parsing.
 831	//
 832	// optional
 833	Caption string `json:"caption"`
 834	// ParseMode mode for parsing entities in the photo caption.
 835	// See formatting options for more details
 836	// (https://core.telegram.org/bots/api#formatting-options).
 837	//
 838	// optional
 839	ParseMode string `json:"parse_mode"`
 840	// ReplyMarkup inline keyboard attached to the message.
 841	//
 842	// optional
 843	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 844	// InputMessageContent content of the message to be sent instead of the photo.
 845	//
 846	// optional
 847	InputMessageContent interface{} `json:"input_message_content,omitempty"`
 848}
 849
 850// InlineQueryResultCachedPhoto is an inline query response with cached photo.
 851type InlineQueryResultCachedPhoto struct {
 852	// Type of the result, must be photo.
 853	//
 854	// required
 855	Type string `json:"type"`
 856	// ID unique identifier for this result, 1-64 bytes.
 857	//
 858	// required
 859	ID string `json:"id"`
 860	// PhotoID a valid file identifier of the photo.
 861	//
 862	// required
 863	PhotoID string `json:"photo_file_id"`
 864	// Title for the result.
 865	//
 866	// optional
 867	Title string `json:"title"`
 868	// Description short description of the result.
 869	//
 870	// optional
 871	Description string `json:"description"`
 872	// Caption of the photo to be sent, 0-1024 characters after entities parsing.
 873	//
 874	// optional
 875	Caption string `json:"caption"`
 876	// ParseMode mode for parsing entities in the photo caption.
 877	// See formatting options for more details
 878	// (https://core.telegram.org/bots/api#formatting-options).
 879	//
 880	// optional
 881	ParseMode string `json:"parse_mode"`
 882	// ReplyMarkup inline keyboard attached to the message.
 883	//
 884	// optional
 885	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 886	// InputMessageContent content of the message to be sent instead of the photo.
 887	//
 888	// optional
 889	InputMessageContent interface{} `json:"input_message_content,omitempty"`
 890}
 891
 892// InlineQueryResultGIF is an inline query response GIF.
 893type InlineQueryResultGIF struct {
 894	// Type of the result, must be gif.
 895	//
 896	// required
 897	Type string `json:"type"`
 898	// ID unique identifier for this result, 1-64 bytes.
 899	//
 900	// required
 901	ID string `json:"id"`
 902	// URL a valid URL for the GIF file. File size must not exceed 1MB.
 903	//
 904	// required
 905	URL string `json:"gif_url"`
 906	// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
 907	//
 908	// required
 909	ThumbURL string `json:"thumb_url"`
 910	// Width of the GIF
 911	//
 912	// optional
 913	Width int `json:"gif_width,omitempty"`
 914	// Height of the GIF
 915	//
 916	// optional
 917	Height int `json:"gif_height,omitempty"`
 918	// Duration of the GIF
 919	//
 920	// optional
 921	Duration int `json:"gif_duration,omitempty"`
 922	// Title for the result
 923	//
 924	// optional
 925	Title string `json:"title,omitempty"`
 926	// Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
 927	//
 928	// optional
 929	Caption string `json:"caption,omitempty"`
 930	// ReplyMarkup inline keyboard attached to the message
 931	//
 932	// optional
 933	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 934	// InputMessageContent content of the message to be sent instead of the GIF animation.
 935	//
 936	// optional
 937	InputMessageContent interface{} `json:"input_message_content,omitempty"`
 938}
 939
 940// InlineQueryResultCachedGIF is an inline query response with cached gif.
 941type InlineQueryResultCachedGIF struct {
 942	// Type of the result, must be gif.
 943	//
 944	// required
 945	Type string `json:"type"`
 946	// ID unique identifier for this result, 1-64 bytes.
 947	//
 948	// required
 949	ID string `json:"id"`
 950	// GifID a valid file identifier for the GIF file.
 951	//
 952	// required
 953	GifID string `json:"gif_file_id"`
 954	// Title for the result
 955	//
 956	// optional
 957	Title string `json:"title"`
 958	// Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
 959	//
 960	// optional
 961	Caption string `json:"caption"`
 962	// ParseMode mode for parsing entities in the caption.
 963	// See formatting options for more details
 964	// (https://core.telegram.org/bots/api#formatting-options).
 965	//
 966	// optional
 967	ParseMode string `json:"parse_mode"`
 968	// ReplyMarkup inline keyboard attached to the message.
 969	//
 970	// optional
 971	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
 972	// InputMessageContent content of the message to be sent instead of the GIF animation.
 973	//
 974	// optional
 975	InputMessageContent interface{} `json:"input_message_content,omitempty"`
 976}
 977
 978// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
 979type InlineQueryResultMPEG4GIF struct {
 980	// Type of the result, must be mpeg4_gif
 981	//
 982	// required
 983	Type string `json:"type"`
 984	// ID unique identifier for this result, 1-64 bytes
 985	//
 986	// required
 987	ID string `json:"id"`
 988	// URL a valid URL for the MP4 file. File size must not exceed 1MB
 989	//
 990	// required
 991	URL string `json:"mpeg4_url"`
 992	// Width video width
 993	//
 994	// optional
 995	Width int `json:"mpeg4_width"`
 996	// Height vVideo height
 997	//
 998	// optional
 999	Height int `json:"mpeg4_height"`
1000	// Duration video duration
1001	//
1002	// optional
1003	Duration int `json:"mpeg4_duration"`
1004	// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
1005	ThumbURL string `json:"thumb_url"`
1006	// Title for the result
1007	//
1008	// optional
1009	Title string `json:"title"`
1010	// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
1011	//
1012	// optional
1013	Caption string `json:"caption"`
1014	// ReplyMarkup inline keyboard attached to the message
1015	//
1016	// optional
1017	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1018	// InputMessageContent content of the message to be sent instead of the video animation
1019	//
1020	// optional
1021	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1022}
1023
1024// InlineQueryResultCachedMpeg4Gif is an inline query response with cached
1025// H.264/MPEG-4 AVC video without sound gif.
1026type InlineQueryResultCachedMpeg4Gif struct {
1027	// Type of the result, must be mpeg4_gif
1028	//
1029	// required
1030	Type string `json:"type"`
1031	// ID unique identifier for this result, 1-64 bytes
1032	//
1033	// required
1034	ID string `json:"id"`
1035	// MGifID a valid file identifier for the MP4 file
1036	//
1037	// required
1038	MGifID string `json:"mpeg4_file_id"`
1039	// Title for the result
1040	//
1041	// optional
1042	Title string `json:"title"`
1043	// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
1044	//
1045	// optional
1046	Caption string `json:"caption"`
1047	// ParseMode mode for parsing entities in the caption.
1048	// See formatting options for more details
1049	// (https://core.telegram.org/bots/api#formatting-options).
1050	//
1051	// optional
1052	ParseMode string `json:"parse_mode"`
1053	// ReplyMarkup inline keyboard attached to the message.
1054	//
1055	// optional
1056	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1057	// InputMessageContent content of the message to be sent instead of the video animation.
1058	//
1059	// optional
1060	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1061}
1062
1063// InlineQueryResultVideo is an inline query response video.
1064type InlineQueryResultVideo struct {
1065	// Type of the result, must be video
1066	//
1067	// required
1068	Type string `json:"type"`
1069	// ID unique identifier for this result, 1-64 bytes
1070	//
1071	// required
1072	ID string `json:"id"`
1073	// URL a valid url for the embedded video player or video file
1074	//
1075	// required
1076	URL string `json:"video_url"`
1077	// MimeType of the content of video url, “text/html” or “video/mp4”
1078	//
1079	// required
1080	MimeType string `json:"mime_type"`
1081	//
1082	// ThumbURL url of the thumbnail (jpeg only) for the video
1083	// optional
1084	ThumbURL string `json:"thumb_url"`
1085	// Title for the result
1086	//
1087	// required
1088	Title string `json:"title"`
1089	// Caption of the video to be sent, 0-1024 characters after entities parsing
1090	//
1091	// optional
1092	Caption string `json:"caption"`
1093	// Width video width
1094	//
1095	// optional
1096	Width int `json:"video_width"`
1097	// Height video height
1098	//
1099	// optional
1100	Height int `json:"video_height"`
1101	// Duration video duration in seconds
1102	//
1103	// optional
1104	Duration int `json:"video_duration"`
1105	// Description short description of the result
1106	//
1107	// optional
1108	Description string `json:"description"`
1109	// ReplyMarkup inline keyboard attached to the message
1110	//
1111	// optional
1112	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1113	// InputMessageContent content of the message to be sent instead of the video.
1114	// This field is required if InlineQueryResultVideo is used to send
1115	// an HTML-page as a result (e.g., a YouTube video).
1116	//
1117	// optional
1118	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1119}
1120
1121// InlineQueryResultCachedVideo is an inline query response with cached video.
1122type InlineQueryResultCachedVideo struct {
1123	// Type of the result, must be video
1124	//
1125	// required
1126	Type string `json:"type"`
1127	// ID unique identifier for this result, 1-64 bytes
1128	//
1129	// required
1130	ID string `json:"id"`
1131	// VideoID a valid file identifier for the video file
1132	//
1133	// required
1134	VideoID string `json:"video_file_id"`
1135	// Title for the result
1136	//
1137	// required
1138	Title string `json:"title"`
1139	// Description short description of the result
1140	//
1141	// optional
1142	Description string `json:"description"`
1143	// Caption of the video to be sent, 0-1024 characters after entities parsing
1144	//
1145	// optional
1146	Caption string `json:"caption"`
1147	// ParseMode mode for parsing entities in the video caption.
1148	// See formatting options for more details
1149	// (https://core.telegram.org/bots/api#formatting-options).
1150	//
1151	// optional
1152	ParseMode string `json:"parse_mode"`
1153	// ReplyMarkup inline keyboard attached to the message
1154	//
1155	// optional
1156	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1157	// InputMessageContent content of the message to be sent instead of the video
1158	//
1159	// optional
1160	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1161}
1162
1163// InlineQueryResultCachedSticker is an inline query response with cached sticker.
1164type InlineQueryResultCachedSticker struct {
1165	// Type of the result, must be sticker
1166	//
1167	// required
1168	Type string `json:"type"`
1169	// ID unique identifier for this result, 1-64 bytes
1170	//
1171	// required
1172	ID string `json:"id"`
1173	// StickerID a valid file identifier of the sticker
1174	//
1175	// required
1176	StickerID string `json:"sticker_file_id"`
1177	// Title is a title
1178	Title string `json:"title"`
1179	// ParseMode mode for parsing entities in the video caption.
1180	// See formatting options for more details
1181	// (https://core.telegram.org/bots/api#formatting-options).
1182	//
1183	// optional
1184	ParseMode string `json:"parse_mode"`
1185	// ReplyMarkup inline keyboard attached to the message
1186	//
1187	// optional
1188	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1189	// InputMessageContent content of the message to be sent instead of the sticker
1190	//
1191	// optional
1192	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1193}
1194
1195// InlineQueryResultAudio is an inline query response audio.
1196type InlineQueryResultAudio struct {
1197	// Type of the result, must be audio
1198	//
1199	// required
1200	Type string `json:"type"`
1201	// ID unique identifier for this result, 1-64 bytes
1202	//
1203	// required
1204	ID string `json:"id"`
1205	// URL a valid url for the audio file
1206	//
1207	// required
1208	URL string `json:"audio_url"`
1209	// Title is a title
1210	//
1211	// required
1212	Title string `json:"title"`
1213	// Caption 0-1024 characters after entities parsing
1214	//
1215	// optional
1216	Caption string `json:"caption"`
1217	// Performer is a performer
1218	//
1219	// optional
1220	Performer string `json:"performer"`
1221	// Duration audio duration in seconds
1222	//
1223	// optional
1224	Duration int `json:"audio_duration"`
1225	// ReplyMarkup inline keyboard attached to the message
1226	//
1227	// optional
1228	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1229	// InputMessageContent content of the message to be sent instead of the audio
1230	//
1231	// optional
1232	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1233}
1234
1235// InlineQueryResultCachedAudio is an inline query response with cached audio.
1236type InlineQueryResultCachedAudio struct {
1237	// Type of the result, must be audio
1238	//
1239	// required
1240	Type string `json:"type"`
1241	// ID unique identifier for this result, 1-64 bytes
1242	//
1243	// required
1244	ID string `json:"id"`
1245	// AudioID a valid file identifier for the audio file
1246	//
1247	// required
1248	AudioID string `json:"audio_file_id"`
1249	// Caption 0-1024 characters after entities parsing
1250	//
1251	// optional
1252	Caption string `json:"caption"`
1253	// ParseMode mode for parsing entities in the video caption.
1254	// See formatting options for more details
1255	// (https://core.telegram.org/bots/api#formatting-options).
1256	//
1257	// optional
1258	ParseMode string `json:"parse_mode"`
1259	// ReplyMarkup inline keyboard attached to the message
1260	//
1261	// optional
1262	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1263	// InputMessageContent content of the message to be sent instead of the audio
1264	//
1265	// optional
1266	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1267}
1268
1269// InlineQueryResultVoice is an inline query response voice.
1270type InlineQueryResultVoice struct {
1271	// Type of the result, must be voice
1272	//
1273	// required
1274	Type string `json:"type"`
1275	// ID unique identifier for this result, 1-64 bytes
1276	//
1277	// required
1278	ID string `json:"id"`
1279	// URL a valid URL for the voice recording
1280	//
1281	// required
1282	URL string `json:"voice_url"`
1283	// Title recording title
1284	//
1285	// required
1286	Title string `json:"title"`
1287	// Caption 0-1024 characters after entities parsing
1288	//
1289	// optional
1290	Caption string `json:"caption"`
1291	// Duration recording duration in seconds
1292	//
1293	// optional
1294	Duration int `json:"voice_duration"`
1295	// ReplyMarkup inline keyboard attached to the message
1296	//
1297	// optional
1298	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1299	// InputMessageContent content of the message to be sent instead of the voice recording
1300	//
1301	// optional
1302	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1303}
1304
1305// InlineQueryResultCachedVoice is an inline query response with cached voice.
1306type InlineQueryResultCachedVoice struct {
1307	// Type of the result, must be voice
1308	//
1309	// required
1310	Type string `json:"type"`
1311	// ID unique identifier for this result, 1-64 bytes
1312	//
1313	// required
1314	ID string `json:"id"`
1315	// VoiceID a valid file identifier for the voice message
1316	//
1317	// required
1318	VoiceID string `json:"voice_file_id"`
1319	// Title voice message title
1320	//
1321	// required
1322	Title string `json:"title"`
1323	// Caption 0-1024 characters after entities parsing
1324	//
1325	// optional
1326	Caption string `json:"caption"`
1327	// ParseMode mode for parsing entities in the video caption.
1328	// See formatting options for more details
1329	// (https://core.telegram.org/bots/api#formatting-options).
1330	//
1331	// optional
1332	ParseMode string `json:"parse_mode"`
1333	// ReplyMarkup inline keyboard attached to the message
1334	//
1335	// optional
1336	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1337	// InputMessageContent content of the message to be sent instead of the voice message
1338	//
1339	// optional
1340	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1341}
1342
1343// InlineQueryResultDocument is an inline query response document.
1344type InlineQueryResultDocument struct {
1345	// Type of the result, must be document
1346	//
1347	// required
1348	Type string `json:"type"`
1349	// ID unique identifier for this result, 1-64 bytes
1350	//
1351	// required
1352	ID string `json:"id"`
1353	// Title for the result
1354	//
1355	// required
1356	Title string `json:"title"`
1357	// Caption of the document to be sent, 0-1024 characters after entities parsing
1358	//
1359	// optional
1360	Caption string `json:"caption"`
1361	// URL a valid url for the file
1362	//
1363	// required
1364	URL string `json:"document_url"`
1365	// MimeType of the content of the file, either “application/pdf” or “application/zip”
1366	//
1367	// required
1368	MimeType string `json:"mime_type"`
1369	// Description short description of the result
1370	//
1371	// optional
1372	Description string `json:"description"`
1373	// ReplyMarkup nline keyboard attached to the message
1374	//
1375	// optional
1376	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1377	// InputMessageContent content of the message to be sent instead of the file
1378	//
1379	// optional
1380	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1381	// ThumbURL url of the thumbnail (jpeg only) for the file
1382	//
1383	// optional
1384	ThumbURL string `json:"thumb_url"`
1385	// ThumbWidth thumbnail width
1386	//
1387	// optional
1388	ThumbWidth int `json:"thumb_width"`
1389	// ThumbHeight thumbnail height
1390	//
1391	// optional
1392	ThumbHeight int `json:"thumb_height"`
1393}
1394
1395// InlineQueryResultCachedDocument is an inline query response with cached document.
1396type InlineQueryResultCachedDocument struct {
1397	// Type of the result, must be document
1398	//
1399	// required
1400	Type string `json:"type"`
1401	// ID unique identifier for this result, 1-64 bytes
1402	//
1403	// required
1404	ID string `json:"id"`
1405	// DocumentID a valid file identifier for the file
1406	//
1407	// required
1408	DocumentID string `json:"document_file_id"`
1409	// Title for the result
1410	//
1411	// optional
1412	Title string `json:"title"` // required
1413	// Caption of the document to be sent, 0-1024 characters after entities parsing
1414	//
1415	// optional
1416	Caption string `json:"caption"`
1417	// Description short description of the result
1418	//
1419	// optional
1420	Description string `json:"description"`
1421	// ParseMode mode for parsing entities in the video caption.
1422	//	// See formatting options for more details
1423	//	// (https://core.telegram.org/bots/api#formatting-options).
1424	//
1425	// optional
1426	ParseMode string `json:"parse_mode"`
1427	// ReplyMarkup inline keyboard attached to the message
1428	//
1429	// optional
1430	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1431	// InputMessageContent content of the message to be sent instead of the file
1432	//
1433	// optional
1434	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1435}
1436
1437// InlineQueryResultLocation is an inline query response location.
1438type InlineQueryResultLocation struct {
1439	// Type of the result, must be location
1440	//
1441	// required
1442	Type string `json:"type"`
1443	// ID unique identifier for this result, 1-64 Bytes
1444	//
1445	// required
1446	ID string `json:"id"`
1447	// Latitude  of the location in degrees
1448	//
1449	// required
1450	Latitude float64 `json:"latitude"`
1451	// Longitude of the location in degrees
1452	//
1453	// required
1454	Longitude float64 `json:"longitude"`
1455	// Title of the location
1456	//
1457	// required
1458	Title string `json:"title"`
1459	// ReplyMarkup inline keyboard attached to the message
1460	//
1461	// optional
1462	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1463	// InputMessageContent content of the message to be sent instead of the location
1464	//
1465	// optional
1466	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1467	// ThumbURL url of the thumbnail for the result
1468	//
1469	// optional
1470	ThumbURL string `json:"thumb_url"`
1471	// ThumbWidth thumbnail width
1472	//
1473	// optional
1474	ThumbWidth int `json:"thumb_width"`
1475	// ThumbHeight thumbnail height
1476	//
1477	// optional
1478	ThumbHeight int `json:"thumb_height"`
1479}
1480
1481// InlineQueryResultVenue is an inline query response venue.
1482type InlineQueryResultVenue struct {
1483	// Type of the result, must be venue
1484	//
1485	// required
1486	Type string `json:"type"`
1487	// ID unique identifier for this result, 1-64 Bytes
1488	//
1489	// required
1490	ID string `json:"id"`
1491	// Latitude of the venue location in degrees
1492	//
1493	// required
1494	Latitude float64 `json:"latitude"`
1495	// Longitude of the venue location in degrees
1496	//
1497	// required
1498	Longitude float64 `json:"longitude"`
1499	// Title of the venue
1500	//
1501	// required
1502	Title string `json:"title"`
1503	// Address of the venue
1504	//
1505	// required
1506	Address string `json:"address"`
1507	// FoursquareID foursquare identifier of the venue if known
1508	//
1509	// optional
1510	FoursquareID string `json:"foursquare_id"`
1511	// FoursquareType foursquare type of the venue, if known.
1512	// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
1513	//
1514	// optional
1515	FoursquareType string `json:"foursquare_type"`
1516	// ReplyMarkup inline keyboard attached to the message
1517	//
1518	// optional
1519	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1520	// InputMessageContent content of the message to be sent instead of the venue
1521	//
1522	// optional
1523	InputMessageContent interface{} `json:"input_message_content,omitempty"`
1524	// ThumbURL url of the thumbnail for the result
1525	//
1526	// optional
1527	ThumbURL string `json:"thumb_url"`
1528	// ThumbWidth thumbnail width
1529	//
1530	// optional
1531	ThumbWidth int `json:"thumb_width"`
1532	// ThumbHeight thumbnail height
1533	//
1534	// optional
1535	ThumbHeight int `json:"thumb_height"`
1536}
1537
1538// InlineQueryResultGame is an inline query response game.
1539type InlineQueryResultGame struct {
1540	// Type of the result, must be game
1541	//
1542	// required
1543	Type string `json:"type"`
1544	// ID unique identifier for this result, 1-64 bytes
1545	//
1546	// required
1547	ID string `json:"id"`
1548	// GameShortName short name of the game
1549	//
1550	// required
1551	GameShortName string `json:"game_short_name"`
1552	// ReplyMarkup inline keyboard attached to the message
1553	//
1554	// optional
1555	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1556}
1557
1558// ChosenInlineResult is an inline query result chosen by a User
1559type ChosenInlineResult struct {
1560	// ResultID the unique identifier for the result that was chosen
1561	ResultID string `json:"result_id"`
1562	// From the user that chose the result
1563	From *User `json:"from"`
1564	// Location sender location, only for bots that require user location
1565	//
1566	// optional
1567	Location *Location `json:"location"`
1568	// InlineMessageID identifier of the sent inline message.
1569	// Available only if there is an inline keyboard attached to the message.
1570	// Will be also received in callback queries and can be used to edit the message.
1571	//
1572	// optional
1573	InlineMessageID string `json:"inline_message_id"`
1574	// Query the query that was used to obtain the result
1575	Query string `json:"query"`
1576}
1577
1578// InputTextMessageContent contains text for displaying
1579// as an inline query result.
1580type InputTextMessageContent struct {
1581	// Text of the message to be sent, 1-4096 characters
1582	Text string `json:"message_text"`
1583	// ParseMode mode for parsing entities in the message text.
1584	// See formatting options for more details
1585	// (https://core.telegram.org/bots/api#formatting-options).
1586	//
1587	// optional
1588	ParseMode string `json:"parse_mode"`
1589	// DisableWebPagePreview disables link previews for links in the sent message
1590	//
1591	// optional
1592	DisableWebPagePreview bool `json:"disable_web_page_preview"`
1593}
1594
1595// InputLocationMessageContent contains a location for displaying
1596// as an inline query result.
1597type InputLocationMessageContent struct {
1598	// Latitude of the location in degrees
1599	Latitude float64 `json:"latitude"`
1600	// Longitude of the location in degrees
1601	Longitude float64 `json:"longitude"`
1602}
1603
1604// InputVenueMessageContent contains a venue for displaying
1605// as an inline query result.
1606type InputVenueMessageContent struct {
1607	// Latitude of the venue in degrees
1608	Latitude float64 `json:"latitude"`
1609	// Longitude of the venue in degrees
1610	Longitude float64 `json:"longitude"`
1611	// Title name of the venue
1612	Title string `json:"title"`
1613	// Address of the venue
1614	Address string `json:"address"`
1615	// FoursquareID foursquare identifier of the venue, if known
1616	//
1617	// optional
1618	FoursquareID string `json:"foursquare_id"`
1619}
1620
1621// InputContactMessageContent contains a contact for displaying
1622// as an inline query result.
1623type InputContactMessageContent struct {
1624	// 	PhoneNumber contact's phone number
1625	PhoneNumber string `json:"phone_number"`
1626	// FirstName contact's first name
1627	FirstName string `json:"first_name"`
1628	// LastName contact's last name
1629	//
1630	// optional
1631	LastName string `json:"last_name"`
1632}
1633
1634// Invoice contains basic information about an invoice.
1635type Invoice struct {
1636	Title          string `json:"title"`
1637	Description    string `json:"description"`
1638	StartParameter string `json:"start_parameter"`
1639	Currency       string `json:"currency"`
1640	TotalAmount    int    `json:"total_amount"`
1641}
1642
1643// LabeledPrice represents a portion of the price for goods or services.
1644type LabeledPrice struct {
1645	Label  string `json:"label"`
1646	Amount int    `json:"amount"`
1647}
1648
1649// ShippingAddress represents a shipping address.
1650type ShippingAddress struct {
1651	CountryCode string `json:"country_code"`
1652	State       string `json:"state"`
1653	City        string `json:"city"`
1654	StreetLine1 string `json:"street_line1"`
1655	StreetLine2 string `json:"street_line2"`
1656	PostCode    string `json:"post_code"`
1657}
1658
1659// OrderInfo represents information about an order.
1660type OrderInfo struct {
1661	Name            string           `json:"name,omitempty"`
1662	PhoneNumber     string           `json:"phone_number,omitempty"`
1663	Email           string           `json:"email,omitempty"`
1664	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
1665}
1666
1667// ShippingOption represents one shipping option.
1668type ShippingOption struct {
1669	ID     string          `json:"id"`
1670	Title  string          `json:"title"`
1671	Prices *[]LabeledPrice `json:"prices"`
1672}
1673
1674// SuccessfulPayment contains basic information about a successful payment.
1675type SuccessfulPayment struct {
1676	Currency                string     `json:"currency"`
1677	TotalAmount             int        `json:"total_amount"`
1678	InvoicePayload          string     `json:"invoice_payload"`
1679	ShippingOptionID        string     `json:"shipping_option_id,omitempty"`
1680	OrderInfo               *OrderInfo `json:"order_info,omitempty"`
1681	TelegramPaymentChargeID string     `json:"telegram_payment_charge_id"`
1682	ProviderPaymentChargeID string     `json:"provider_payment_charge_id"`
1683}
1684
1685// ShippingQuery contains information about an incoming shipping query.
1686type ShippingQuery struct {
1687	ID              string           `json:"id"`
1688	From            *User            `json:"from"`
1689	InvoicePayload  string           `json:"invoice_payload"`
1690	ShippingAddress *ShippingAddress `json:"shipping_address"`
1691}
1692
1693// PreCheckoutQuery contains information about an incoming pre-checkout query.
1694type PreCheckoutQuery struct {
1695	ID               string     `json:"id"`
1696	From             *User      `json:"from"`
1697	Currency         string     `json:"currency"`
1698	TotalAmount      int        `json:"total_amount"`
1699	InvoicePayload   string     `json:"invoice_payload"`
1700	ShippingOptionID string     `json:"shipping_option_id,omitempty"`
1701	OrderInfo        *OrderInfo `json:"order_info,omitempty"`
1702}
1703
1704// Error is an error containing extra information returned by the Telegram API.
1705type Error struct {
1706	Code    int
1707	Message string
1708	ResponseParameters
1709}
1710
1711func (e Error) Error() string {
1712	return e.Message
1713}
1714
1715// BotCommand represents a bot command.
1716type BotCommand struct {
1717	Command     string `json:"command"`
1718	Description string `json:"description"`
1719}