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}
415
416// IsCreator returns if the ChatMember was the creator of the chat.
417func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
418
419// IsAdministrator returns if the ChatMember is a chat administrator.
420func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
421
422// IsMember returns if the ChatMember is a current member of the chat.
423func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
424
425// HasLeft returns if the ChatMember left the chat.
426func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
427
428// WasKicked returns if the ChatMember was kicked from the chat.
429func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
430
431// Game is a game within Telegram.
432type Game struct {
433 Title string `json:"title"`
434 Description string `json:"description"`
435 Photo []PhotoSize `json:"photo"`
436 Text string `json:"text"`
437 TextEntities []MessageEntity `json:"text_entities"`
438 Animation Animation `json:"animation"`
439}
440
441// Animation is a GIF animation demonstrating the game.
442type Animation struct {
443 FileID string `json:"file_id"`
444 Thumb PhotoSize `json:"thumb"`
445 FileName string `json:"file_name"`
446 MimeType string `json:"mime_type"`
447 FileSize int `json:"file_size"`
448}
449
450// GameHighScore is a user's score and position on the leaderboard.
451type GameHighScore struct {
452 Position int `json:"position"`
453 User User `json:"user"`
454 Score int `json:"score"`
455}
456
457// CallbackGame is for starting a game in an inline keyboard button.
458type CallbackGame struct{}
459
460// WebhookInfo is information about a currently set webhook.
461type WebhookInfo struct {
462 URL string `json:"url"`
463 HasCustomCertificate bool `json:"has_custom_certificate"`
464 PendingUpdateCount int `json:"pending_update_count"`
465 LastErrorDate int `json:"last_error_date"` // optional
466 LastErrorMessage string `json:"last_error_message"` // optional
467}
468
469// IsSet returns true if a webhook is currently set.
470func (info WebhookInfo) IsSet() bool {
471 return info.URL != ""
472}
473
474// InlineQuery is a Query from Telegram for an inline request.
475type InlineQuery struct {
476 ID string `json:"id"`
477 From *User `json:"from"`
478 Location *Location `json:"location"` // optional
479 Query string `json:"query"`
480 Offset string `json:"offset"`
481}
482
483// InlineQueryResultArticle is an inline query response article.
484type InlineQueryResultArticle struct {
485 Type string `json:"type"` // required
486 ID string `json:"id"` // required
487 Title string `json:"title"` // required
488 InputMessageContent interface{} `json:"input_message_content,omitempty"` // required
489 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
490 URL string `json:"url"`
491 HideURL bool `json:"hide_url"`
492 Description string `json:"description"`
493 ThumbURL string `json:"thumb_url"`
494 ThumbWidth int `json:"thumb_width"`
495 ThumbHeight int `json:"thumb_height"`
496}
497
498// InlineQueryResultPhoto is an inline query response photo.
499type InlineQueryResultPhoto struct {
500 Type string `json:"type"` // required
501 ID string `json:"id"` // required
502 URL string `json:"photo_url"` // required
503 MimeType string `json:"mime_type"`
504 Width int `json:"photo_width"`
505 Height int `json:"photo_height"`
506 ThumbURL string `json:"thumb_url"`
507 Title string `json:"title"`
508 Description string `json:"description"`
509 Caption string `json:"caption"`
510 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
511 InputMessageContent interface{} `json:"input_message_content,omitempty"`
512}
513
514// InlineQueryResultGIF is an inline query response GIF.
515type InlineQueryResultGIF struct {
516 Type string `json:"type"` // required
517 ID string `json:"id"` // required
518 URL string `json:"gif_url"` // required
519 Width int `json:"gif_width"`
520 Height int `json:"gif_height"`
521 Duration int `json:"gif_duration"`
522 ThumbURL string `json:"thumb_url"`
523 Title string `json:"title"`
524 Caption string `json:"caption"`
525 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
526 InputMessageContent interface{} `json:"input_message_content,omitempty"`
527}
528
529// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
530type InlineQueryResultMPEG4GIF struct {
531 Type string `json:"type"` // required
532 ID string `json:"id"` // required
533 URL string `json:"mpeg4_url"` // required
534 Width int `json:"mpeg4_width"`
535 Height int `json:"mpeg4_height"`
536 Duration int `json:"mpeg4_duration"`
537 ThumbURL string `json:"thumb_url"`
538 Title string `json:"title"`
539 Caption string `json:"caption"`
540 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
541 InputMessageContent interface{} `json:"input_message_content,omitempty"`
542}
543
544// InlineQueryResultVideo is an inline query response video.
545type InlineQueryResultVideo struct {
546 Type string `json:"type"` // required
547 ID string `json:"id"` // required
548 URL string `json:"video_url"` // required
549 MimeType string `json:"mime_type"` // required
550 ThumbURL string `json:"thumb_url"`
551 Title string `json:"title"`
552 Caption string `json:"caption"`
553 Width int `json:"video_width"`
554 Height int `json:"video_height"`
555 Duration int `json:"video_duration"`
556 Description string `json:"description"`
557 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
558 InputMessageContent interface{} `json:"input_message_content,omitempty"`
559}
560
561// InlineQueryResultAudio is an inline query response audio.
562type InlineQueryResultAudio struct {
563 Type string `json:"type"` // required
564 ID string `json:"id"` // required
565 URL string `json:"audio_url"` // required
566 Title string `json:"title"` // required
567 Caption string `json:"caption"`
568 Performer string `json:"performer"`
569 Duration int `json:"audio_duration"`
570 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
571 InputMessageContent interface{} `json:"input_message_content,omitempty"`
572}
573
574// InlineQueryResultVoice is an inline query response voice.
575type InlineQueryResultVoice struct {
576 Type string `json:"type"` // required
577 ID string `json:"id"` // required
578 URL string `json:"voice_url"` // required
579 Title string `json:"title"` // required
580 Caption string `json:"caption"`
581 Duration int `json:"voice_duration"`
582 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
583 InputMessageContent interface{} `json:"input_message_content,omitempty"`
584}
585
586// InlineQueryResultDocument is an inline query response document.
587type InlineQueryResultDocument struct {
588 Type string `json:"type"` // required
589 ID string `json:"id"` // required
590 Title string `json:"title"` // required
591 Caption string `json:"caption"`
592 URL string `json:"document_url"` // required
593 MimeType string `json:"mime_type"` // required
594 Description string `json:"description"`
595 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
596 InputMessageContent interface{} `json:"input_message_content,omitempty"`
597 ThumbURL string `json:"thumb_url"`
598 ThumbWidth int `json:"thumb_width"`
599 ThumbHeight int `json:"thumb_height"`
600}
601
602// InlineQueryResultLocation is an inline query response location.
603type InlineQueryResultLocation struct {
604 Type string `json:"type"` // required
605 ID string `json:"id"` // required
606 Latitude float64 `json:"latitude"` // required
607 Longitude float64 `json:"longitude"` // required
608 Title string `json:"title"` // required
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// InlineQueryResultGame is an inline query response game.
617type InlineQueryResultGame struct {
618 Type string `json:"type"`
619 ID string `json:"id"`
620 GameShortName string `json:"game_short_name"`
621 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
622}
623
624// ChosenInlineResult is an inline query result chosen by a User
625type ChosenInlineResult struct {
626 ResultID string `json:"result_id"`
627 From *User `json:"from"`
628 Location *Location `json:"location"`
629 InlineMessageID string `json:"inline_message_id"`
630 Query string `json:"query"`
631}
632
633// InputTextMessageContent contains text for displaying
634// as an inline query result.
635type InputTextMessageContent struct {
636 Text string `json:"message_text"`
637 ParseMode string `json:"parse_mode"`
638 DisableWebPagePreview bool `json:"disable_web_page_preview"`
639}
640
641// InputLocationMessageContent contains a location for displaying
642// as an inline query result.
643type InputLocationMessageContent struct {
644 Latitude float64 `json:"latitude"`
645 Longitude float64 `json:"longitude"`
646}
647
648// InputVenueMessageContent contains a venue for displaying
649// as an inline query result.
650type InputVenueMessageContent struct {
651 Latitude float64 `json:"latitude"`
652 Longitude float64 `json:"longitude"`
653 Title string `json:"title"`
654 Address string `json:"address"`
655 FoursquareID string `json:"foursquare_id"`
656}
657
658// InputContactMessageContent contains a contact for displaying
659// as an inline query result.
660type InputContactMessageContent struct {
661 PhoneNumber string `json:"phone_number"`
662 FirstName string `json:"first_name"`
663 LastName string `json:"last_name"`
664}
665
666// Invoice contains basic information about an invoice.
667type Invoice struct {
668 Title string `json:"title"`
669 Description string `json:"description"`
670 StartParameter string `json:"start_parameter"`
671 Currency string `json:"currency"`
672 TotalAmount int `json:"total_amount"`
673}
674
675// LabeledPrice represents a portion of the price for goods or services.
676type LabeledPrice struct {
677 Label string `json:"label"`
678 Amount int `json:"amount"`
679}
680
681// ShippingAddress represents a shipping address.
682type ShippingAddress struct {
683 CountryCode string `json:"country_code"`
684 State string `json:"state"`
685 City string `json:"city"`
686 StreetLine1 string `json:"street_line1"`
687 StreetLine2 string `json:"street_line2"`
688 PostCode string `json:"post_code"`
689}
690
691// OrderInfo represents information about an order.
692type OrderInfo struct {
693 Name string `json:"name,omitempty"`
694 PhoneNumber string `json:"phone_number,omitempty"`
695 Email string `json:"email,omitempty"`
696 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
697}
698
699// ShippingOption represents one shipping option.
700type ShippingOption struct {
701 ID string `json:"id"`
702 Title string `json:"title"`
703 Prices *[]LabeledPrice `json:"prices"`
704}
705
706// SuccessfulPayment contains basic information about a successful payment.
707type SuccessfulPayment struct {
708 Currency string `json:"currency"`
709 TotalAmount int `json:"total_amount"`
710 InvoicePayload string `json:"invoice_payload"`
711 ShippingOptionID string `json:"shipping_option_id,omitempty"`
712 OrderInfo *OrderInfo `json:"order_info,omitempty"`
713 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
714 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
715}
716
717// ShippingQuery contains information about an incoming shipping query.
718type ShippingQuery struct {
719 ID string `json:"id"`
720 From *User `json:"from"`
721 InvoicePayload string `json:"invoice_payload"`
722 ShippingAddress *ShippingAddress `json:"shipping_address"`
723}
724
725// PreCheckoutQuery contains information about an incoming pre-checkout query.
726type PreCheckoutQuery struct {
727 ID string `json:"id"`
728 From *User `json:"from"`
729 Currency string `json:"currency"`
730 TotalAmount int `json:"total_amount"`
731 InvoicePayload string `json:"invoice_payload"`
732 ShippingOptionID string `json:"shipping_option_id,omitempty"`
733 OrderInfo *OrderInfo `json:"order_info,omitempty"`
734}