all repos — telegram-bot-api @ ac87082c555ae9cd9cc2b0b07cf904744cf5841d

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.UserName != "" {
 68		return u.UserName
 69	}
 70
 71	name := u.FirstName
 72	if u.LastName != "" {
 73		name += " " + u.LastName
 74	}
 75
 76	return name
 77}
 78
 79// GroupChat is a group chat.
 80type GroupChat struct {
 81	ID    int    `json:"id"`
 82	Title string `json:"title"`
 83}
 84
 85// ChatPhoto represents a chat photo.
 86type ChatPhoto struct {
 87	SmallFileID string `json:"small_file_id"`
 88	BigFileID   string `json:"big_file_id"`
 89}
 90
 91// Chat contains information about the place a message was sent.
 92type Chat struct {
 93	ID                  int64      `json:"id"`
 94	Type                string     `json:"type"`
 95	Title               string     `json:"title"`                          // optional
 96	UserName            string     `json:"username"`                       // optional
 97	FirstName           string     `json:"first_name"`                     // optional
 98	LastName            string     `json:"last_name"`                      // optional
 99	AllMembersAreAdmins bool       `json:"all_members_are_administrators"` // optional
100	Photo               *ChatPhoto `json:"photo"`
101	Description         string     `json:"description,omitempty"` // optional
102	InviteLink          string     `json:"invite_link,omitempty"` // optional
103}
104
105// IsPrivate returns if the Chat is a private conversation.
106func (c Chat) IsPrivate() bool {
107	return c.Type == "private"
108}
109
110// IsGroup returns if the Chat is a group.
111func (c Chat) IsGroup() bool {
112	return c.Type == "group"
113}
114
115// IsSuperGroup returns if the Chat is a supergroup.
116func (c Chat) IsSuperGroup() bool {
117	return c.Type == "supergroup"
118}
119
120// IsChannel returns if the Chat is a channel.
121func (c Chat) IsChannel() bool {
122	return c.Type == "channel"
123}
124
125// ChatConfig returns a ChatConfig struct for chat related methods.
126func (c Chat) ChatConfig() ChatConfig {
127	return ChatConfig{ChatID: c.ID}
128}
129
130// Message is returned by almost every request, and contains data about
131// almost anything.
132type Message struct {
133	MessageID             int                `json:"message_id"`
134	From                  *User              `json:"from"` // optional
135	Date                  int                `json:"date"`
136	Chat                  *Chat              `json:"chat"`
137	ForwardFrom           *User              `json:"forward_from"`            // optional
138	ForwardFromChat       *Chat              `json:"forward_from_chat"`       // optional
139	ForwardFromMessageID  int                `json:"forward_from_message_id"` // optional
140	ForwardDate           int                `json:"forward_date"`            // optional
141	ReplyToMessage        *Message           `json:"reply_to_message"`        // optional
142	EditDate              int                `json:"edit_date"`               // optional
143	Text                  string             `json:"text"`                    // optional
144	Entities              *[]MessageEntity   `json:"entities"`                // optional
145	Audio                 *Audio             `json:"audio"`                   // optional
146	Document              *Document          `json:"document"`                // optional
147	Game                  *Game              `json:"game"`                    // optional
148	Photo                 *[]PhotoSize       `json:"photo"`                   // optional
149	Sticker               *Sticker           `json:"sticker"`                 // optional
150	Video                 *Video             `json:"video"`                   // optional
151	VideoNote             *VideoNote         `json:"video_note"`              // optional
152	Voice                 *Voice             `json:"voice"`                   // optional
153	Caption               string             `json:"caption"`                 // optional
154	Contact               *Contact           `json:"contact"`                 // optional
155	Location              *Location          `json:"location"`                // optional
156	Venue                 *Venue             `json:"venue"`                   // optional
157	NewChatMembers        *[]User            `json:"new_chat_members"`        // optional
158	LeftChatMember        *User              `json:"left_chat_member"`        // optional
159	NewChatTitle          string             `json:"new_chat_title"`          // optional
160	NewChatPhoto          *[]PhotoSize       `json:"new_chat_photo"`          // optional
161	DeleteChatPhoto       bool               `json:"delete_chat_photo"`       // optional
162	GroupChatCreated      bool               `json:"group_chat_created"`      // optional
163	SuperGroupChatCreated bool               `json:"supergroup_chat_created"` // optional
164	ChannelChatCreated    bool               `json:"channel_chat_created"`    // optional
165	MigrateToChatID       int64              `json:"migrate_to_chat_id"`      // optional
166	MigrateFromChatID     int64              `json:"migrate_from_chat_id"`    // optional
167	PinnedMessage         *Message           `json:"pinned_message"`          // optional
168	Invoice               *Invoice           `json:"invoice"`                 // optional
169	SuccessfulPayment     *SuccessfulPayment `json:"successful_payment"`      // optional
170}
171
172// Time converts the message timestamp into a Time.
173func (m *Message) Time() time.Time {
174	return time.Unix(int64(m.Date), 0)
175}
176
177// IsCommand returns true if message starts with a "bot_command" entity.
178func (m *Message) IsCommand() bool {
179	if m.Entities == nil || len(*m.Entities) == 0 {
180		return false
181	}
182
183	entity := (*m.Entities)[0]
184	return entity.Offset == 0 && entity.Type == "bot_command"
185}
186
187// Command checks if the message was a command and if it was, returns the
188// command. If the Message was not a command, it returns an empty string.
189//
190// If the command contains the at name syntax, it is removed. Use
191// CommandWithAt() if you do not want that.
192func (m *Message) Command() string {
193	command := m.CommandWithAt()
194
195	if i := strings.Index(command, "@"); i != -1 {
196		command = command[:i]
197	}
198
199	return command
200}
201
202// CommandWithAt checks if the message was a command and if it was, returns the
203// command. If the Message was not a command, it returns an empty string.
204//
205// If the command contains the at name syntax, it is not removed. Use Command()
206// if you want that.
207func (m *Message) CommandWithAt() string {
208	if !m.IsCommand() {
209		return ""
210	}
211
212	// IsCommand() checks that the message begins with a bot_command entity
213	entity := (*m.Entities)[0]
214	return m.Text[1:entity.Length]
215}
216
217// CommandArguments checks if the message was a command and if it was,
218// returns all text after the command name. If the Message was not a
219// command, it returns an empty string.
220//
221// Note: The first character after the command name is omitted:
222// - "/foo bar baz" yields "bar baz", not " bar baz"
223// - "/foo-bar baz" yields "bar baz", too
224// Even though the latter is not a command conforming to the spec, the API
225// marks "/foo" as command entity.
226func (m *Message) CommandArguments() string {
227	if !m.IsCommand() {
228		return ""
229	}
230
231	// IsCommand() checks that the message begins with a bot_command entity
232	entity := (*m.Entities)[0]
233
234	if len(m.Text) == entity.Length {
235		return "" // The command makes up the whole message
236	}
237
238	return m.Text[entity.Length+1:]
239}
240
241// MessageEntity contains information about data in a Message.
242type MessageEntity struct {
243	Type   string `json:"type"`
244	Offset int    `json:"offset"`
245	Length int    `json:"length"`
246	URL    string `json:"url"`  // optional
247	User   *User  `json:"user"` // optional
248}
249
250// ParseURL attempts to parse a URL contained within a MessageEntity.
251func (entity MessageEntity) ParseURL() (*url.URL, error) {
252	if entity.URL == "" {
253		return nil, errors.New(ErrBadURL)
254	}
255
256	return url.Parse(entity.URL)
257}
258
259// PhotoSize contains information about photos.
260type PhotoSize struct {
261	FileID   string `json:"file_id"`
262	Width    int    `json:"width"`
263	Height   int    `json:"height"`
264	FileSize int    `json:"file_size"` // optional
265}
266
267// Audio contains information about audio.
268type Audio struct {
269	FileID    string `json:"file_id"`
270	Duration  int    `json:"duration"`
271	Performer string `json:"performer"` // optional
272	Title     string `json:"title"`     // optional
273	MimeType  string `json:"mime_type"` // optional
274	FileSize  int    `json:"file_size"` // optional
275}
276
277// Document contains information about a document.
278type Document struct {
279	FileID    string     `json:"file_id"`
280	Thumbnail *PhotoSize `json:"thumb"`     // optional
281	FileName  string     `json:"file_name"` // optional
282	MimeType  string     `json:"mime_type"` // optional
283	FileSize  int        `json:"file_size"` // optional
284}
285
286// Sticker contains information about a sticker.
287type Sticker struct {
288	FileID       string       `json:"file_id"`
289	Width        int          `json:"width"`
290	Height       int          `json:"height"`
291	Thumbnail    *PhotoSize   `json:"thumb"`         // optional
292	Emoji        string       `json:"emoji"`         // optional
293	SetName      string       `json:"set_name"`      // optional
294	MaskPosition MaskPosition `json:"mask_position"` //optional
295	FileSize     int          `json:"file_size"`     // optional
296}
297
298// MaskPosition is the position of a mask.
299type MaskPosition struct {
300	Point  string  `json:"point"`
301	XShift float32 `json:"x_shift"`
302	YShift float32 `json:"y_shift"`
303	Scale  float32 `json:"scale"`
304}
305
306// Video contains information about a video.
307type Video struct {
308	FileID    string     `json:"file_id"`
309	Width     int        `json:"width"`
310	Height    int        `json:"height"`
311	Duration  int        `json:"duration"`
312	Thumbnail *PhotoSize `json:"thumb"`     // optional
313	MimeType  string     `json:"mime_type"` // optional
314	FileSize  int        `json:"file_size"` // optional
315}
316
317// VideoNote contains information about a video.
318type VideoNote struct {
319	FileID    string     `json:"file_id"`
320	Length    int        `json:"length"`
321	Duration  int        `json:"duration"`
322	Thumbnail *PhotoSize `json:"thumb"`     // optional
323	FileSize  int        `json:"file_size"` // optional
324}
325
326// Voice contains information about a voice.
327type Voice struct {
328	FileID   string `json:"file_id"`
329	Duration int    `json:"duration"`
330	MimeType string `json:"mime_type"` // optional
331	FileSize int    `json:"file_size"` // optional
332}
333
334// Contact contains information about a contact.
335//
336// Note that LastName and UserID may be empty.
337type Contact struct {
338	PhoneNumber string `json:"phone_number"`
339	FirstName   string `json:"first_name"`
340	LastName    string `json:"last_name"` // optional
341	UserID      int    `json:"user_id"`   // optional
342}
343
344// Location contains information about a place.
345type Location struct {
346	Longitude float64 `json:"longitude"`
347	Latitude  float64 `json:"latitude"`
348}
349
350// Venue contains information about a venue, including its Location.
351type Venue struct {
352	Location     Location `json:"location"`
353	Title        string   `json:"title"`
354	Address      string   `json:"address"`
355	FoursquareID string   `json:"foursquare_id"` // optional
356}
357
358// UserProfilePhotos contains a set of user profile photos.
359type UserProfilePhotos struct {
360	TotalCount int           `json:"total_count"`
361	Photos     [][]PhotoSize `json:"photos"`
362}
363
364// File contains information about a file to download from Telegram.
365type File struct {
366	FileID   string `json:"file_id"`
367	FileSize int    `json:"file_size"` // optional
368	FilePath string `json:"file_path"` // optional
369}
370
371// Link returns a full path to the download URL for a File.
372//
373// It requires the Bot Token to create the link.
374func (f *File) Link(token string) string {
375	return fmt.Sprintf(FileEndpoint, token, f.FilePath)
376}
377
378// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
379type ReplyKeyboardMarkup struct {
380	Keyboard        [][]KeyboardButton `json:"keyboard"`
381	ResizeKeyboard  bool               `json:"resize_keyboard"`   // optional
382	OneTimeKeyboard bool               `json:"one_time_keyboard"` // optional
383	Selective       bool               `json:"selective"`         // optional
384}
385
386// KeyboardButton is a button within a custom keyboard.
387type KeyboardButton struct {
388	Text            string `json:"text"`
389	RequestContact  bool   `json:"request_contact"`
390	RequestLocation bool   `json:"request_location"`
391}
392
393// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
394type ReplyKeyboardHide struct {
395	HideKeyboard bool `json:"hide_keyboard"`
396	Selective    bool `json:"selective"` // optional
397}
398
399// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
400type ReplyKeyboardRemove struct {
401	RemoveKeyboard bool `json:"remove_keyboard"`
402	Selective      bool `json:"selective"`
403}
404
405// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
406type InlineKeyboardMarkup struct {
407	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
408}
409
410// InlineKeyboardButton is a button within a custom keyboard for
411// inline query responses.
412//
413// Note that some values are references as even an empty string
414// will change behavior.
415//
416// CallbackGame, if set, MUST be first button in first row.
417type InlineKeyboardButton struct {
418	Text                         string        `json:"text"`
419	URL                          *string       `json:"url,omitempty"`                              // optional
420	CallbackData                 *string       `json:"callback_data,omitempty"`                    // optional
421	SwitchInlineQuery            *string       `json:"switch_inline_query,omitempty"`              // optional
422	SwitchInlineQueryCurrentChat *string       `json:"switch_inline_query_current_chat,omitempty"` // optional
423	CallbackGame                 *CallbackGame `json:"callback_game,omitempty"`                    // optional
424	Pay                          bool          `json:"pay,omitempty"`                              // optional
425}
426
427// CallbackQuery is data sent when a keyboard button with callback data
428// is clicked.
429type CallbackQuery struct {
430	ID              string   `json:"id"`
431	From            *User    `json:"from"`
432	Message         *Message `json:"message"`           // optional
433	InlineMessageID string   `json:"inline_message_id"` // optional
434	ChatInstance    string   `json:"chat_instance"`
435	Data            string   `json:"data"`            // optional
436	GameShortName   string   `json:"game_short_name"` // optional
437}
438
439// ForceReply allows the Bot to have users directly reply to it without
440// additional interaction.
441type ForceReply struct {
442	ForceReply bool `json:"force_reply"`
443	Selective  bool `json:"selective"` // optional
444}
445
446// ChatMember is information about a member in a chat.
447type ChatMember struct {
448	User                  *User  `json:"user"`
449	Status                string `json:"status"`
450	UntilDate             int64  `json:"until_date,omitempty"`                // optional
451	CanBeEdited           bool   `json:"can_be_edited,omitempty"`             // optional
452	CanChangeInfo         bool   `json:"can_change_info,omitempty"`           // optional
453	CanPostMessages       bool   `json:"can_post_messages,omitempty"`         // optional
454	CanEditMessages       bool   `json:"can_edit_messages,omitempty"`         // optional
455	CanDeleteMessages     bool   `json:"can_delete_messages,omitempty"`       // optional
456	CanInviteUsers        bool   `json:"can_invite_users,omitempty"`          // optional
457	CanRestrictMembers    bool   `json:"can_restrict_members,omitempty"`      // optional
458	CanPinMessages        bool   `json:"can_pin_messages,omitempty"`          // optional
459	CanPromoteMembers     bool   `json:"can_promote_members,omitempty"`       // optional
460	CanSendMessages       bool   `json:"can_send_messages,omitempty"`         // optional
461	CanSendMediaMessages  bool   `json:"can_send_media_messages,omitempty"`   // optional
462	CanSendOtherMessages  bool   `json:"can_send_other_messages,omitempty"`   // optional
463	CanAddWebPagePreviews bool   `json:"can_add_web_page_previews,omitempty"` // optional
464}
465
466// IsCreator returns if the ChatMember was the creator of the chat.
467func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
468
469// IsAdministrator returns if the ChatMember is a chat administrator.
470func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
471
472// IsMember returns if the ChatMember is a current member of the chat.
473func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
474
475// HasLeft returns if the ChatMember left the chat.
476func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
477
478// WasKicked returns if the ChatMember was kicked from the chat.
479func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
480
481// Game is a game within Telegram.
482type Game struct {
483	Title        string          `json:"title"`
484	Description  string          `json:"description"`
485	Photo        []PhotoSize     `json:"photo"`
486	Text         string          `json:"text"`
487	TextEntities []MessageEntity `json:"text_entities"`
488	Animation    Animation       `json:"animation"`
489}
490
491// Animation is a GIF animation demonstrating the game.
492type Animation struct {
493	FileID   string    `json:"file_id"`
494	Thumb    PhotoSize `json:"thumb"`
495	FileName string    `json:"file_name"`
496	MimeType string    `json:"mime_type"`
497	FileSize int       `json:"file_size"`
498}
499
500// GameHighScore is a user's score and position on the leaderboard.
501type GameHighScore struct {
502	Position int  `json:"position"`
503	User     User `json:"user"`
504	Score    int  `json:"score"`
505}
506
507// CallbackGame is for starting a game in an inline keyboard button.
508type CallbackGame struct{}
509
510// WebhookInfo is information about a currently set webhook.
511type WebhookInfo struct {
512	URL                  string `json:"url"`
513	HasCustomCertificate bool   `json:"has_custom_certificate"`
514	PendingUpdateCount   int    `json:"pending_update_count"`
515	LastErrorDate        int    `json:"last_error_date"`    // optional
516	LastErrorMessage     string `json:"last_error_message"` // optional
517}
518
519// IsSet returns true if a webhook is currently set.
520func (info WebhookInfo) IsSet() bool {
521	return info.URL != ""
522}
523
524// InlineQuery is a Query from Telegram for an inline request.
525type InlineQuery struct {
526	ID       string    `json:"id"`
527	From     *User     `json:"from"`
528	Location *Location `json:"location"` // optional
529	Query    string    `json:"query"`
530	Offset   string    `json:"offset"`
531}
532
533// InlineQueryResultArticle is an inline query response article.
534type InlineQueryResultArticle struct {
535	Type                string                `json:"type"`                            // required
536	ID                  string                `json:"id"`                              // required
537	Title               string                `json:"title"`                           // required
538	InputMessageContent interface{}           `json:"input_message_content,omitempty"` // required
539	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
540	URL                 string                `json:"url"`
541	HideURL             bool                  `json:"hide_url"`
542	Description         string                `json:"description"`
543	ThumbURL            string                `json:"thumb_url"`
544	ThumbWidth          int                   `json:"thumb_width"`
545	ThumbHeight         int                   `json:"thumb_height"`
546}
547
548// InlineQueryResultPhoto is an inline query response photo.
549type InlineQueryResultPhoto struct {
550	Type                string                `json:"type"`      // required
551	ID                  string                `json:"id"`        // required
552	URL                 string                `json:"photo_url"` // required
553	MimeType            string                `json:"mime_type"`
554	Width               int                   `json:"photo_width"`
555	Height              int                   `json:"photo_height"`
556	ThumbURL            string                `json:"thumb_url"`
557	Title               string                `json:"title"`
558	Description         string                `json:"description"`
559	Caption             string                `json:"caption"`
560	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
561	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
562}
563
564// InlineQueryResultGIF is an inline query response GIF.
565type InlineQueryResultGIF struct {
566	Type                string                `json:"type"`    // required
567	ID                  string                `json:"id"`      // required
568	URL                 string                `json:"gif_url"` // required
569	Width               int                   `json:"gif_width"`
570	Height              int                   `json:"gif_height"`
571	Duration            int                   `json:"gif_duration"`
572	ThumbURL            string                `json:"thumb_url"`
573	Title               string                `json:"title"`
574	Caption             string                `json:"caption"`
575	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
576	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
577}
578
579// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
580type InlineQueryResultMPEG4GIF struct {
581	Type                string                `json:"type"`      // required
582	ID                  string                `json:"id"`        // required
583	URL                 string                `json:"mpeg4_url"` // required
584	Width               int                   `json:"mpeg4_width"`
585	Height              int                   `json:"mpeg4_height"`
586	Duration            int                   `json:"mpeg4_duration"`
587	ThumbURL            string                `json:"thumb_url"`
588	Title               string                `json:"title"`
589	Caption             string                `json:"caption"`
590	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
591	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
592}
593
594// InlineQueryResultVideo is an inline query response video.
595type InlineQueryResultVideo struct {
596	Type                string                `json:"type"`      // required
597	ID                  string                `json:"id"`        // required
598	URL                 string                `json:"video_url"` // required
599	MimeType            string                `json:"mime_type"` // required
600	ThumbURL            string                `json:"thumb_url"`
601	Title               string                `json:"title"`
602	Caption             string                `json:"caption"`
603	Width               int                   `json:"video_width"`
604	Height              int                   `json:"video_height"`
605	Duration            int                   `json:"video_duration"`
606	Description         string                `json:"description"`
607	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
608	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
609}
610
611// InlineQueryResultAudio is an inline query response audio.
612type InlineQueryResultAudio struct {
613	Type                string                `json:"type"`      // required
614	ID                  string                `json:"id"`        // required
615	URL                 string                `json:"audio_url"` // required
616	Title               string                `json:"title"`     // required
617	Caption             string                `json:"caption"`
618	Performer           string                `json:"performer"`
619	Duration            int                   `json:"audio_duration"`
620	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
621	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
622}
623
624// InlineQueryResultVoice is an inline query response voice.
625type InlineQueryResultVoice struct {
626	Type                string                `json:"type"`      // required
627	ID                  string                `json:"id"`        // required
628	URL                 string                `json:"voice_url"` // required
629	Title               string                `json:"title"`     // required
630	Caption             string                `json:"caption"`
631	Duration            int                   `json:"voice_duration"`
632	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
633	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
634}
635
636// InlineQueryResultDocument is an inline query response document.
637type InlineQueryResultDocument struct {
638	Type                string                `json:"type"`  // required
639	ID                  string                `json:"id"`    // required
640	Title               string                `json:"title"` // required
641	Caption             string                `json:"caption"`
642	URL                 string                `json:"document_url"` // required
643	MimeType            string                `json:"mime_type"`    // required
644	Description         string                `json:"description"`
645	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
646	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
647	ThumbURL            string                `json:"thumb_url"`
648	ThumbWidth          int                   `json:"thumb_width"`
649	ThumbHeight         int                   `json:"thumb_height"`
650}
651
652// InlineQueryResultLocation is an inline query response location.
653type InlineQueryResultLocation struct {
654	Type                string                `json:"type"`      // required
655	ID                  string                `json:"id"`        // required
656	Latitude            float64               `json:"latitude"`  // required
657	Longitude           float64               `json:"longitude"` // required
658	Title               string                `json:"title"`     // required
659	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
660	InputMessageContent interface{}           `json:"input_message_content,omitempty"`
661	ThumbURL            string                `json:"thumb_url"`
662	ThumbWidth          int                   `json:"thumb_width"`
663	ThumbHeight         int                   `json:"thumb_height"`
664}
665
666// InlineQueryResultGame is an inline query response game.
667type InlineQueryResultGame struct {
668	Type          string                `json:"type"`
669	ID            string                `json:"id"`
670	GameShortName string                `json:"game_short_name"`
671	ReplyMarkup   *InlineKeyboardMarkup `json:"reply_markup"`
672}
673
674// ChosenInlineResult is an inline query result chosen by a User
675type ChosenInlineResult struct {
676	ResultID        string    `json:"result_id"`
677	From            *User     `json:"from"`
678	Location        *Location `json:"location"`
679	InlineMessageID string    `json:"inline_message_id"`
680	Query           string    `json:"query"`
681}
682
683// InputTextMessageContent contains text for displaying
684// as an inline query result.
685type InputTextMessageContent struct {
686	Text                  string `json:"message_text"`
687	ParseMode             string `json:"parse_mode"`
688	DisableWebPagePreview bool   `json:"disable_web_page_preview"`
689}
690
691// InputLocationMessageContent contains a location for displaying
692// as an inline query result.
693type InputLocationMessageContent struct {
694	Latitude  float64 `json:"latitude"`
695	Longitude float64 `json:"longitude"`
696}
697
698// InputVenueMessageContent contains a venue for displaying
699// as an inline query result.
700type InputVenueMessageContent struct {
701	Latitude     float64 `json:"latitude"`
702	Longitude    float64 `json:"longitude"`
703	Title        string  `json:"title"`
704	Address      string  `json:"address"`
705	FoursquareID string  `json:"foursquare_id"`
706}
707
708// InputContactMessageContent contains a contact for displaying
709// as an inline query result.
710type InputContactMessageContent struct {
711	PhoneNumber string `json:"phone_number"`
712	FirstName   string `json:"first_name"`
713	LastName    string `json:"last_name"`
714}
715
716// Invoice contains basic information about an invoice.
717type Invoice struct {
718	Title          string `json:"title"`
719	Description    string `json:"description"`
720	StartParameter string `json:"start_parameter"`
721	Currency       string `json:"currency"`
722	TotalAmount    int    `json:"total_amount"`
723}
724
725// LabeledPrice represents a portion of the price for goods or services.
726type LabeledPrice struct {
727	Label  string `json:"label"`
728	Amount int    `json:"amount"`
729}
730
731// ShippingAddress represents a shipping address.
732type ShippingAddress struct {
733	CountryCode string `json:"country_code"`
734	State       string `json:"state"`
735	City        string `json:"city"`
736	StreetLine1 string `json:"street_line1"`
737	StreetLine2 string `json:"street_line2"`
738	PostCode    string `json:"post_code"`
739}
740
741// OrderInfo represents information about an order.
742type OrderInfo struct {
743	Name            string           `json:"name,omitempty"`
744	PhoneNumber     string           `json:"phone_number,omitempty"`
745	Email           string           `json:"email,omitempty"`
746	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
747}
748
749// ShippingOption represents one shipping option.
750type ShippingOption struct {
751	ID     string          `json:"id"`
752	Title  string          `json:"title"`
753	Prices *[]LabeledPrice `json:"prices"`
754}
755
756// SuccessfulPayment contains basic information about a successful payment.
757type SuccessfulPayment struct {
758	Currency                string     `json:"currency"`
759	TotalAmount             int        `json:"total_amount"`
760	InvoicePayload          string     `json:"invoice_payload"`
761	ShippingOptionID        string     `json:"shipping_option_id,omitempty"`
762	OrderInfo               *OrderInfo `json:"order_info,omitempty"`
763	TelegramPaymentChargeID string     `json:"telegram_payment_charge_id"`
764	ProviderPaymentChargeID string     `json:"provider_payment_charge_id"`
765}
766
767// ShippingQuery contains information about an incoming shipping query.
768type ShippingQuery struct {
769	ID              string           `json:"id"`
770	From            *User            `json:"from"`
771	InvoicePayload  string           `json:"invoice_payload"`
772	ShippingAddress *ShippingAddress `json:"shipping_address"`
773}
774
775// PreCheckoutQuery contains information about an incoming pre-checkout query.
776type PreCheckoutQuery struct {
777	ID               string     `json:"id"`
778	From             *User      `json:"from"`
779	Currency         string     `json:"currency"`
780	TotalAmount      int        `json:"total_amount"`
781	InvoicePayload   string     `json:"invoice_payload"`
782	ShippingOptionID string     `json:"shipping_option_id,omitempty"`
783	OrderInfo        *OrderInfo `json:"order_info,omitempty"`
784}
785
786// StickerSet is a collection of stickers.
787type StickerSet struct {
788	Name          string    `json:"name"`
789	Title         string    `json:"title"`
790	ContainsMasks bool      `json:"contains_masks"`
791	Stickers      []Sticker `json:"stickers"`
792}