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