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 NewChatMember *User `json:"new_chat_member"` // 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 ThumbURL string `json:"thumb_url"`
513 Title string `json:"title"`
514 Caption string `json:"caption"`
515 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
516 InputMessageContent interface{} `json:"input_message_content,omitempty"`
517}
518
519// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
520type InlineQueryResultMPEG4GIF struct {
521 Type string `json:"type"` // required
522 ID string `json:"id"` // required
523 URL string `json:"mpeg4_url"` // required
524 Width int `json:"mpeg4_width"`
525 Height int `json:"mpeg4_height"`
526 ThumbURL string `json:"thumb_url"`
527 Title string `json:"title"`
528 Caption string `json:"caption"`
529 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
530 InputMessageContent interface{} `json:"input_message_content,omitempty"`
531}
532
533// InlineQueryResultVideo is an inline query response video.
534type InlineQueryResultVideo struct {
535 Type string `json:"type"` // required
536 ID string `json:"id"` // required
537 URL string `json:"video_url"` // required
538 MimeType string `json:"mime_type"` // required
539 ThumbURL string `json:"thumb_url"`
540 Title string `json:"title"`
541 Caption string `json:"caption"`
542 Width int `json:"video_width"`
543 Height int `json:"video_height"`
544 Duration int `json:"video_duration"`
545 Description string `json:"description"`
546 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
547 InputMessageContent interface{} `json:"input_message_content,omitempty"`
548}
549
550// InlineQueryResultAudio is an inline query response audio.
551type InlineQueryResultAudio struct {
552 Type string `json:"type"` // required
553 ID string `json:"id"` // required
554 URL string `json:"audio_url"` // required
555 Title string `json:"title"` // required
556 Caption string `json:"caption"`
557 Performer string `json:"performer"`
558 Duration int `json:"audio_duration"`
559 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
560 InputMessageContent interface{} `json:"input_message_content,omitempty"`
561}
562
563// InlineQueryResultVoice is an inline query response voice.
564type InlineQueryResultVoice struct {
565 Type string `json:"type"` // required
566 ID string `json:"id"` // required
567 URL string `json:"voice_url"` // required
568 Title string `json:"title"` // required
569 Caption string `json:"caption"`
570 Duration int `json:"voice_duration"`
571 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
572 InputMessageContent interface{} `json:"input_message_content,omitempty"`
573}
574
575// InlineQueryResultDocument is an inline query response document.
576type InlineQueryResultDocument struct {
577 Type string `json:"type"` // required
578 ID string `json:"id"` // required
579 Title string `json:"title"` // required
580 Caption string `json:"caption"`
581 URL string `json:"document_url"` // required
582 MimeType string `json:"mime_type"` // required
583 Description string `json:"description"`
584 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
585 InputMessageContent interface{} `json:"input_message_content,omitempty"`
586 ThumbURL string `json:"thumb_url"`
587 ThumbWidth int `json:"thumb_width"`
588 ThumbHeight int `json:"thumb_height"`
589}
590
591// InlineQueryResultLocation is an inline query response location.
592type InlineQueryResultLocation struct {
593 Type string `json:"type"` // required
594 ID string `json:"id"` // required
595 Latitude float64 `json:"latitude"` // required
596 Longitude float64 `json:"longitude"` // required
597 Title string `json:"title"` // required
598 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
599 InputMessageContent interface{} `json:"input_message_content,omitempty"`
600 ThumbURL string `json:"thumb_url"`
601 ThumbWidth int `json:"thumb_width"`
602 ThumbHeight int `json:"thumb_height"`
603}
604
605// InlineQueryResultGame is an inline query response game.
606type InlineQueryResultGame struct {
607 Type string `json:"type"`
608 ID string `json:"id"`
609 GameShortName string `json:"game_short_name"`
610 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
611}
612
613// ChosenInlineResult is an inline query result chosen by a User
614type ChosenInlineResult struct {
615 ResultID string `json:"result_id"`
616 From *User `json:"from"`
617 Location *Location `json:"location"`
618 InlineMessageID string `json:"inline_message_id"`
619 Query string `json:"query"`
620}
621
622// InputTextMessageContent contains text for displaying
623// as an inline query result.
624type InputTextMessageContent struct {
625 Text string `json:"message_text"`
626 ParseMode string `json:"parse_mode"`
627 DisableWebPagePreview bool `json:"disable_web_page_preview"`
628}
629
630// InputLocationMessageContent contains a location for displaying
631// as an inline query result.
632type InputLocationMessageContent struct {
633 Latitude float64 `json:"latitude"`
634 Longitude float64 `json:"longitude"`
635}
636
637// InputVenueMessageContent contains a venue for displaying
638// as an inline query result.
639type InputVenueMessageContent struct {
640 Latitude float64 `json:"latitude"`
641 Longitude float64 `json:"longitude"`
642 Title string `json:"title"`
643 Address string `json:"address"`
644 FoursquareID string `json:"foursquare_id"`
645}
646
647// InputContactMessageContent contains a contact for displaying
648// as an inline query result.
649type InputContactMessageContent struct {
650 PhoneNumber string `json:"phone_number"`
651 FirstName string `json:"first_name"`
652 LastName string `json:"last_name"`
653}
654
655// Invoice contains information about invoice
656type Invoice struct {
657 Title string `json:"title"`
658 Description string `json:"description"`
659 StartParameter string `json:"start_parameter"`
660 Currency string `json:"currency"`
661 TotalAmount int `json:"total_amount"`
662}
663
664type LabeledPrice struct {
665 Label string `json:"label"`
666 Amount int `json:"amount"`
667}
668
669type ShippingAddress struct {
670 CountryCode string `json:"country_code"`
671 State string `json:"state"`
672 City string `json:"city"`
673 StreetLine1 string `json:"street_line1"`
674 StreetLine2 string `json:"street_line2"`
675 PostCode string `json:"post_code"`
676}
677
678type OrderInfo struct {
679 Name string `json:"name,omitempty"`
680 PhoneNumber string `json:"phone_number,omitempty"`
681 Email string `json:"email,omitempty"`
682 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
683}
684
685type ShippingOption struct {
686 ID string `json:"id"`
687 Title string `json:"title"`
688 Prices *[]LabeledPrice `json:"prices"`
689}
690
691type SuccessfulPayment struct {
692 Currency string `json:"currency"`
693 TotalAmount int `json:"total_amount"`
694 InvoicePayload string `json:"invoice_payload"`
695 ShippingOptionID string `json:"shipping_option_id,omitempty"`
696 OrderInfo *OrderInfo `json:"order_info,omitempty"`
697 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
698 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
699}
700
701type ShippingQuery struct {
702 ID string `json:"id"`
703 From *User `json:"from"`
704 InvoicePayload string `json:"invoice_payload"`
705 ShippingAddress *ShippingAddress `json:"shipping_address"`
706}
707
708type PreCheckoutQuery struct {
709 ID string `json:"id"`
710 From *User `json:"from"`
711 Currency string `json:"currency"`
712 TotalAmount int `json:"total_amount"`
713 InvoicePayload string `json:"invoice_payload"`
714 ShippingOptionID string `json:"shipping_option_id,omitempty"`
715 OrderInfo *OrderInfo `json:"order_info,omitempty"`
716}