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 '/'.
177func (m *Message) IsCommand() bool {
178 return m.Text != "" && m.Text[0] == '/'
179}
180
181// Command checks if the message was a command and if it was, returns the
182// command. If the Message was not a command, it returns an empty string.
183//
184// If the command contains the at bot syntax, it removes the bot name.
185func (m *Message) Command() string {
186 if !m.IsCommand() {
187 return ""
188 }
189
190 command := strings.SplitN(m.Text, " ", 2)[0][1:]
191
192 if i := strings.Index(command, "@"); i != -1 {
193 command = command[:i]
194 }
195
196 return command
197}
198
199// CommandArguments checks if the message was a command and if it was,
200// returns all text after the command name. If the Message was not a
201// command, it returns an empty string.
202func (m *Message) CommandArguments() string {
203 if !m.IsCommand() {
204 return ""
205 }
206
207 split := strings.SplitN(m.Text, " ", 2)
208 if len(split) != 2 {
209 return ""
210 }
211
212 return split[1]
213}
214
215// MessageEntity contains information about data in a Message.
216type MessageEntity struct {
217 Type string `json:"type"`
218 Offset int `json:"offset"`
219 Length int `json:"length"`
220 URL string `json:"url"` // optional
221 User *User `json:"user"` // optional
222}
223
224// ParseURL attempts to parse a URL contained within a MessageEntity.
225func (entity MessageEntity) ParseURL() (*url.URL, error) {
226 if entity.URL == "" {
227 return nil, errors.New(ErrBadURL)
228 }
229
230 return url.Parse(entity.URL)
231}
232
233// PhotoSize contains information about photos.
234type PhotoSize struct {
235 FileID string `json:"file_id"`
236 Width int `json:"width"`
237 Height int `json:"height"`
238 FileSize int `json:"file_size"` // optional
239}
240
241// Audio contains information about audio.
242type Audio struct {
243 FileID string `json:"file_id"`
244 Duration int `json:"duration"`
245 Performer string `json:"performer"` // optional
246 Title string `json:"title"` // optional
247 MimeType string `json:"mime_type"` // optional
248 FileSize int `json:"file_size"` // optional
249}
250
251// Document contains information about a document.
252type Document struct {
253 FileID string `json:"file_id"`
254 Thumbnail *PhotoSize `json:"thumb"` // optional
255 FileName string `json:"file_name"` // optional
256 MimeType string `json:"mime_type"` // optional
257 FileSize int `json:"file_size"` // optional
258}
259
260// Sticker contains information about a sticker.
261type Sticker struct {
262 FileID string `json:"file_id"`
263 Width int `json:"width"`
264 Height int `json:"height"`
265 Thumbnail *PhotoSize `json:"thumb"` // optional
266 Emoji string `json:"emoji"` // optional
267 FileSize int `json:"file_size"` // optional
268}
269
270// Video contains information about a video.
271type Video struct {
272 FileID string `json:"file_id"`
273 Width int `json:"width"`
274 Height int `json:"height"`
275 Duration int `json:"duration"`
276 Thumbnail *PhotoSize `json:"thumb"` // optional
277 MimeType string `json:"mime_type"` // optional
278 FileSize int `json:"file_size"` // optional
279}
280
281// VideoNote contains information about a video.
282type VideoNote struct {
283 FileID string `json:"file_id"`
284 Length int `json:"length"`
285 Duration int `json:"duration"`
286 Thumbnail *PhotoSize `json:"thumb"` // optional
287 FileSize int `json:"file_size"` // optional
288}
289
290// Voice contains information about a voice.
291type Voice struct {
292 FileID string `json:"file_id"`
293 Duration int `json:"duration"`
294 MimeType string `json:"mime_type"` // optional
295 FileSize int `json:"file_size"` // optional
296}
297
298// Contact contains information about a contact.
299//
300// Note that LastName and UserID may be empty.
301type Contact struct {
302 PhoneNumber string `json:"phone_number"`
303 FirstName string `json:"first_name"`
304 LastName string `json:"last_name"` // optional
305 UserID int `json:"user_id"` // optional
306}
307
308// Location contains information about a place.
309type Location struct {
310 Longitude float64 `json:"longitude"`
311 Latitude float64 `json:"latitude"`
312}
313
314// Venue contains information about a venue, including its Location.
315type Venue struct {
316 Location Location `json:"location"`
317 Title string `json:"title"`
318 Address string `json:"address"`
319 FoursquareID string `json:"foursquare_id"` // optional
320}
321
322// UserProfilePhotos contains a set of user profile photos.
323type UserProfilePhotos struct {
324 TotalCount int `json:"total_count"`
325 Photos [][]PhotoSize `json:"photos"`
326}
327
328// File contains information about a file to download from Telegram.
329type File struct {
330 FileID string `json:"file_id"`
331 FileSize int `json:"file_size"` // optional
332 FilePath string `json:"file_path"` // optional
333}
334
335// Link returns a full path to the download URL for a File.
336//
337// It requires the Bot Token to create the link.
338func (f *File) Link(token string) string {
339 return fmt.Sprintf(FileEndpoint, token, f.FilePath)
340}
341
342// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
343type ReplyKeyboardMarkup struct {
344 Keyboard [][]KeyboardButton `json:"keyboard"`
345 ResizeKeyboard bool `json:"resize_keyboard"` // optional
346 OneTimeKeyboard bool `json:"one_time_keyboard"` // optional
347 Selective bool `json:"selective"` // optional
348}
349
350// KeyboardButton is a button within a custom keyboard.
351type KeyboardButton struct {
352 Text string `json:"text"`
353 RequestContact bool `json:"request_contact"`
354 RequestLocation bool `json:"request_location"`
355}
356
357// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
358type ReplyKeyboardHide struct {
359 HideKeyboard bool `json:"hide_keyboard"`
360 Selective bool `json:"selective"` // optional
361}
362
363// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
364type ReplyKeyboardRemove struct {
365 RemoveKeyboard bool `json:"remove_keyboard"`
366 Selective bool `json:"selective"`
367}
368
369// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
370type InlineKeyboardMarkup struct {
371 InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
372}
373
374// InlineKeyboardButton is a button within a custom keyboard for
375// inline query responses.
376//
377// Note that some values are references as even an empty string
378// will change behavior.
379//
380// CallbackGame, if set, MUST be first button in first row.
381type InlineKeyboardButton struct {
382 Text string `json:"text"`
383 URL *string `json:"url,omitempty"` // optional
384 CallbackData *string `json:"callback_data,omitempty"` // optional
385 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // optional
386 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // optional
387 CallbackGame *CallbackGame `json:"callback_game,omitempty"` // optional
388 Pay bool `json:"pay"`
389}
390
391// CallbackQuery is data sent when a keyboard button with callback data
392// is clicked.
393type CallbackQuery struct {
394 ID string `json:"id"`
395 From *User `json:"from"`
396 Message *Message `json:"message"` // optional
397 InlineMessageID string `json:"inline_message_id"` // optional
398 ChatInstance string `json:"chat_instance"`
399 Data string `json:"data"` // optional
400 GameShortName string `json:"game_short_name"` // optional
401}
402
403// ForceReply allows the Bot to have users directly reply to it without
404// additional interaction.
405type ForceReply struct {
406 ForceReply bool `json:"force_reply"`
407 Selective bool `json:"selective"` // optional
408}
409
410// ChatMember is information about a member in a chat.
411type ChatMember struct {
412 User *User `json:"user"`
413 Status string `json:"status"`
414 UntilDate int64 `json:"until_date,omitempty"` // optional
415 CanBeEdited bool `json:"can_be_edited,omitempty"` // optional
416 CanChangeInfo bool `json:"can_change_info,omitempty"` // optional
417 CanPostMessages bool `json:"can_post_messages,omitempty"` // optional
418 CanEditMessages bool `json:"can_edit_messages,omitempty"` // optional
419 CanDeleteMessages bool `json:"can_delete_messages,omitempty"` // optional
420 CanInviteUsers bool `json:"can_invite_users,omitempty"` // optional
421 CanRestrictMembers bool `json:"can_restrict_members,omitempty"` // optional
422 CanPinMessages bool `json:"can_pin_messages,omitempty"` // optional
423 CanPromoteMembers bool `json:"can_promote_members,omitempty"` // optional
424 CanSendMessages bool `json:"can_send_messages,omitempty"` // optional
425 CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"` // optional
426 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"` // optional
427 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"` // optional
428}
429
430// IsCreator returns if the ChatMember was the creator of the chat.
431func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
432
433// IsAdministrator returns if the ChatMember is a chat administrator.
434func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
435
436// IsMember returns if the ChatMember is a current member of the chat.
437func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
438
439// HasLeft returns if the ChatMember left the chat.
440func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
441
442// WasKicked returns if the ChatMember was kicked from the chat.
443func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
444
445// Game is a game within Telegram.
446type Game struct {
447 Title string `json:"title"`
448 Description string `json:"description"`
449 Photo []PhotoSize `json:"photo"`
450 Text string `json:"text"`
451 TextEntities []MessageEntity `json:"text_entities"`
452 Animation Animation `json:"animation"`
453}
454
455// Animation is a GIF animation demonstrating the game.
456type Animation struct {
457 FileID string `json:"file_id"`
458 Thumb PhotoSize `json:"thumb"`
459 FileName string `json:"file_name"`
460 MimeType string `json:"mime_type"`
461 FileSize int `json:"file_size"`
462}
463
464// GameHighScore is a user's score and position on the leaderboard.
465type GameHighScore struct {
466 Position int `json:"position"`
467 User User `json:"user"`
468 Score int `json:"score"`
469}
470
471// CallbackGame is for starting a game in an inline keyboard button.
472type CallbackGame struct{}
473
474// WebhookInfo is information about a currently set webhook.
475type WebhookInfo struct {
476 URL string `json:"url"`
477 HasCustomCertificate bool `json:"has_custom_certificate"`
478 PendingUpdateCount int `json:"pending_update_count"`
479 LastErrorDate int `json:"last_error_date"` // optional
480 LastErrorMessage string `json:"last_error_message"` // optional
481}
482
483// IsSet returns true if a webhook is currently set.
484func (info WebhookInfo) IsSet() bool {
485 return info.URL != ""
486}
487
488// InlineQuery is a Query from Telegram for an inline request.
489type InlineQuery struct {
490 ID string `json:"id"`
491 From *User `json:"from"`
492 Location *Location `json:"location"` // optional
493 Query string `json:"query"`
494 Offset string `json:"offset"`
495}
496
497// InlineQueryResultArticle is an inline query response article.
498type InlineQueryResultArticle struct {
499 Type string `json:"type"` // required
500 ID string `json:"id"` // required
501 Title string `json:"title"` // required
502 InputMessageContent interface{} `json:"input_message_content,omitempty"` // required
503 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
504 URL string `json:"url"`
505 HideURL bool `json:"hide_url"`
506 Description string `json:"description"`
507 ThumbURL string `json:"thumb_url"`
508 ThumbWidth int `json:"thumb_width"`
509 ThumbHeight int `json:"thumb_height"`
510}
511
512// InlineQueryResultPhoto is an inline query response photo.
513type InlineQueryResultPhoto struct {
514 Type string `json:"type"` // required
515 ID string `json:"id"` // required
516 URL string `json:"photo_url"` // required
517 MimeType string `json:"mime_type"`
518 Width int `json:"photo_width"`
519 Height int `json:"photo_height"`
520 ThumbURL string `json:"thumb_url"`
521 Title string `json:"title"`
522 Description string `json:"description"`
523 Caption string `json:"caption"`
524 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
525 InputMessageContent interface{} `json:"input_message_content,omitempty"`
526}
527
528// InlineQueryResultGIF is an inline query response GIF.
529type InlineQueryResultGIF struct {
530 Type string `json:"type"` // required
531 ID string `json:"id"` // required
532 URL string `json:"gif_url"` // required
533 Width int `json:"gif_width"`
534 Height int `json:"gif_height"`
535 Duration int `json:"gif_duration"`
536 ThumbURL string `json:"thumb_url"`
537 Title string `json:"title"`
538 Caption string `json:"caption"`
539 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
540 InputMessageContent interface{} `json:"input_message_content,omitempty"`
541}
542
543// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
544type InlineQueryResultMPEG4GIF struct {
545 Type string `json:"type"` // required
546 ID string `json:"id"` // required
547 URL string `json:"mpeg4_url"` // required
548 Width int `json:"mpeg4_width"`
549 Height int `json:"mpeg4_height"`
550 Duration int `json:"mpeg4_duration"`
551 ThumbURL string `json:"thumb_url"`
552 Title string `json:"title"`
553 Caption string `json:"caption"`
554 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
555 InputMessageContent interface{} `json:"input_message_content,omitempty"`
556}
557
558// InlineQueryResultVideo is an inline query response video.
559type InlineQueryResultVideo struct {
560 Type string `json:"type"` // required
561 ID string `json:"id"` // required
562 URL string `json:"video_url"` // required
563 MimeType string `json:"mime_type"` // required
564 ThumbURL string `json:"thumb_url"`
565 Title string `json:"title"`
566 Caption string `json:"caption"`
567 Width int `json:"video_width"`
568 Height int `json:"video_height"`
569 Duration int `json:"video_duration"`
570 Description string `json:"description"`
571 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
572 InputMessageContent interface{} `json:"input_message_content,omitempty"`
573}
574
575// InlineQueryResultAudio is an inline query response audio.
576type InlineQueryResultAudio struct {
577 Type string `json:"type"` // required
578 ID string `json:"id"` // required
579 URL string `json:"audio_url"` // required
580 Title string `json:"title"` // required
581 Caption string `json:"caption"`
582 Performer string `json:"performer"`
583 Duration int `json:"audio_duration"`
584 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
585 InputMessageContent interface{} `json:"input_message_content,omitempty"`
586}
587
588// InlineQueryResultVoice is an inline query response voice.
589type InlineQueryResultVoice struct {
590 Type string `json:"type"` // required
591 ID string `json:"id"` // required
592 URL string `json:"voice_url"` // required
593 Title string `json:"title"` // required
594 Caption string `json:"caption"`
595 Duration int `json:"voice_duration"`
596 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
597 InputMessageContent interface{} `json:"input_message_content,omitempty"`
598}
599
600// InlineQueryResultDocument is an inline query response document.
601type InlineQueryResultDocument struct {
602 Type string `json:"type"` // required
603 ID string `json:"id"` // required
604 Title string `json:"title"` // required
605 Caption string `json:"caption"`
606 URL string `json:"document_url"` // required
607 MimeType string `json:"mime_type"` // required
608 Description string `json:"description"`
609 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
610 InputMessageContent interface{} `json:"input_message_content,omitempty"`
611 ThumbURL string `json:"thumb_url"`
612 ThumbWidth int `json:"thumb_width"`
613 ThumbHeight int `json:"thumb_height"`
614}
615
616// InlineQueryResultLocation is an inline query response location.
617type InlineQueryResultLocation struct {
618 Type string `json:"type"` // required
619 ID string `json:"id"` // required
620 Latitude float64 `json:"latitude"` // required
621 Longitude float64 `json:"longitude"` // required
622 Title string `json:"title"` // required
623 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
624 InputMessageContent interface{} `json:"input_message_content,omitempty"`
625 ThumbURL string `json:"thumb_url"`
626 ThumbWidth int `json:"thumb_width"`
627 ThumbHeight int `json:"thumb_height"`
628}
629
630// InlineQueryResultGame is an inline query response game.
631type InlineQueryResultGame struct {
632 Type string `json:"type"`
633 ID string `json:"id"`
634 GameShortName string `json:"game_short_name"`
635 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
636}
637
638// ChosenInlineResult is an inline query result chosen by a User
639type ChosenInlineResult struct {
640 ResultID string `json:"result_id"`
641 From *User `json:"from"`
642 Location *Location `json:"location"`
643 InlineMessageID string `json:"inline_message_id"`
644 Query string `json:"query"`
645}
646
647// InputTextMessageContent contains text for displaying
648// as an inline query result.
649type InputTextMessageContent struct {
650 Text string `json:"message_text"`
651 ParseMode string `json:"parse_mode"`
652 DisableWebPagePreview bool `json:"disable_web_page_preview"`
653}
654
655// InputLocationMessageContent contains a location for displaying
656// as an inline query result.
657type InputLocationMessageContent struct {
658 Latitude float64 `json:"latitude"`
659 Longitude float64 `json:"longitude"`
660}
661
662// InputVenueMessageContent contains a venue for displaying
663// as an inline query result.
664type InputVenueMessageContent struct {
665 Latitude float64 `json:"latitude"`
666 Longitude float64 `json:"longitude"`
667 Title string `json:"title"`
668 Address string `json:"address"`
669 FoursquareID string `json:"foursquare_id"`
670}
671
672// InputContactMessageContent contains a contact for displaying
673// as an inline query result.
674type InputContactMessageContent struct {
675 PhoneNumber string `json:"phone_number"`
676 FirstName string `json:"first_name"`
677 LastName string `json:"last_name"`
678}
679
680// Invoice contains basic information about an invoice.
681type Invoice struct {
682 Title string `json:"title"`
683 Description string `json:"description"`
684 StartParameter string `json:"start_parameter"`
685 Currency string `json:"currency"`
686 TotalAmount int `json:"total_amount"`
687}
688
689// LabeledPrice represents a portion of the price for goods or services.
690type LabeledPrice struct {
691 Label string `json:"label"`
692 Amount int `json:"amount"`
693}
694
695// ShippingAddress represents a shipping address.
696type ShippingAddress struct {
697 CountryCode string `json:"country_code"`
698 State string `json:"state"`
699 City string `json:"city"`
700 StreetLine1 string `json:"street_line1"`
701 StreetLine2 string `json:"street_line2"`
702 PostCode string `json:"post_code"`
703}
704
705// OrderInfo represents information about an order.
706type OrderInfo struct {
707 Name string `json:"name,omitempty"`
708 PhoneNumber string `json:"phone_number,omitempty"`
709 Email string `json:"email,omitempty"`
710 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
711}
712
713// ShippingOption represents one shipping option.
714type ShippingOption struct {
715 ID string `json:"id"`
716 Title string `json:"title"`
717 Prices *[]LabeledPrice `json:"prices"`
718}
719
720// SuccessfulPayment contains basic information about a successful payment.
721type SuccessfulPayment struct {
722 Currency string `json:"currency"`
723 TotalAmount int `json:"total_amount"`
724 InvoicePayload string `json:"invoice_payload"`
725 ShippingOptionID string `json:"shipping_option_id,omitempty"`
726 OrderInfo *OrderInfo `json:"order_info,omitempty"`
727 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
728 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
729}
730
731// ShippingQuery contains information about an incoming shipping query.
732type ShippingQuery struct {
733 ID string `json:"id"`
734 From *User `json:"from"`
735 InvoicePayload string `json:"invoice_payload"`
736 ShippingAddress *ShippingAddress `json:"shipping_address"`
737}
738
739// PreCheckoutQuery contains information about an incoming pre-checkout query.
740type PreCheckoutQuery struct {
741 ID string `json:"id"`
742 From *User `json:"from"`
743 Currency string `json:"currency"`
744 TotalAmount int `json:"total_amount"`
745 InvoicePayload string `json:"invoice_payload"`
746 ShippingOptionID string `json:"shipping_option_id,omitempty"`
747 OrderInfo *OrderInfo `json:"order_info,omitempty"`
748}