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