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