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,omitempty"`
17 ErrorCode int `json:"error_code,omitempty"`
18 Description string `json:"description,omitempty"`
19 Parameters *ResponseParameters `json:"parameters,omitempty"`
20}
21
22// Error is an error containing extra information returned by the Telegram API.
23type Error struct {
24 Code int
25 Message string
26 ResponseParameters
27}
28
29// Error message string.
30func (e Error) Error() string {
31 return e.Message
32}
33
34// Update is an update response, from GetUpdates.
35type Update struct {
36 // UpdateID is the update's unique identifier.
37 // Update identifiers start from a certain positive number and increase
38 // sequentially.
39 // This ID becomes especially handy if you're using Webhooks,
40 // since it allows you to ignore repeated updates or to restore
41 // the correct update sequence, should they get out of order.
42 // If there are no new updates for at least a week, then identifier
43 // of the next update will be chosen randomly instead of sequentially.
44 UpdateID int `json:"update_id"`
45 // Message new incoming message of any kind — text, photo, sticker, etc.
46 //
47 // optional
48 Message *Message `json:"message,omitempty"`
49 // EditedMessage new version of a message that is known to the bot and was
50 // edited
51 //
52 // optional
53 EditedMessage *Message `json:"edited_message,omitempty"`
54 // ChannelPost new version of a message that is known to the bot and was
55 // edited
56 //
57 // optional
58 ChannelPost *Message `json:"channel_post,omitempty"`
59 // EditedChannelPost new incoming channel post of any kind — text, photo,
60 // sticker, etc.
61 //
62 // optional
63 EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
64 // InlineQuery new incoming inline query
65 //
66 // optional
67 InlineQuery *InlineQuery `json:"inline_query,omitempty"`
68 // ChosenInlineResult is the result of an inline query
69 // that was chosen by a user and sent to their chat partner.
70 // Please see our documentation on the feedback collecting
71 // for details on how to enable these updates for your bot.
72 //
73 // optional
74 ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
75 // CallbackQuery new incoming callback query
76 //
77 // optional
78 CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
79 // ShippingQuery new incoming shipping query. Only for invoices with
80 // flexible price
81 //
82 // optional
83 ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
84 // PreCheckoutQuery new incoming pre-checkout query. Contains full
85 // information about checkout
86 //
87 // optional
88 PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
89 // Pool new poll state. Bots receive only updates about stopped polls and
90 // polls, which are sent by the bot
91 //
92 // optional
93 Poll *Poll `json:"poll,omitempty"`
94 // PollAnswer user changed their answer in a non-anonymous poll. Bots
95 // receive new votes only in polls that were sent by the bot itself.
96 //
97 // optional
98 PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
99 // MyChatMember is the bot's chat member status was updated in a chat. For
100 // private chats, this update is received only when the bot is blocked or
101 // unblocked by the user.
102 //
103 // optional
104 MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
105 // ChatMember is a chat member's status was updated in a chat. The bot must
106 // be an administrator in the chat and must explicitly specify "chat_member"
107 // in the list of allowed_updates to receive these updates.
108 //
109 // optional
110 ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
111 // ChatJoinRequest is a request to join the chat has been sent. The bot must
112 // have the can_invite_users administrator right in the chat to receive
113 // these updates.
114 //
115 // optional
116 ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`
117}
118
119// SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
120// about the user in the update object.
121func (u *Update) SentFrom() *User {
122 switch {
123 case u.Message != nil:
124 return u.Message.From
125 case u.EditedMessage != nil:
126 return u.EditedMessage.From
127 case u.InlineQuery != nil:
128 return u.InlineQuery.From
129 case u.ChosenInlineResult != nil:
130 return u.ChosenInlineResult.From
131 case u.CallbackQuery != nil:
132 return u.CallbackQuery.From
133 case u.ShippingQuery != nil:
134 return u.ShippingQuery.From
135 case u.PreCheckoutQuery != nil:
136 return u.PreCheckoutQuery.From
137 default:
138 return nil
139 }
140}
141
142// CallbackData returns the callback query data, if it exists.
143func (u *Update) CallbackData() string {
144 if u.CallbackQuery != nil {
145 return u.CallbackQuery.Data
146 }
147 return ""
148}
149
150// FromChat returns the chat where an update occurred.
151func (u *Update) FromChat() *Chat {
152 switch {
153 case u.Message != nil:
154 return u.Message.Chat
155 case u.EditedMessage != nil:
156 return u.EditedMessage.Chat
157 case u.ChannelPost != nil:
158 return u.ChannelPost.Chat
159 case u.EditedChannelPost != nil:
160 return u.EditedChannelPost.Chat
161 case u.CallbackQuery != nil:
162 return u.CallbackQuery.Message.Chat
163 default:
164 return nil
165 }
166}
167
168// UpdatesChannel is the channel for getting updates.
169type UpdatesChannel <-chan Update
170
171// Clear discards all unprocessed incoming updates.
172func (ch UpdatesChannel) Clear() {
173 for len(ch) != 0 {
174 <-ch
175 }
176}
177
178// User represents a Telegram user or bot.
179type User struct {
180 // ID is a unique identifier for this user or bot
181 ID int64 `json:"id"`
182 // IsBot true, if this user is a bot
183 //
184 // optional
185 IsBot bool `json:"is_bot,omitempty"`
186 // FirstName user's or bot's first name
187 FirstName string `json:"first_name"`
188 // LastName user's or bot's last name
189 //
190 // optional
191 LastName string `json:"last_name,omitempty"`
192 // UserName user's or bot's username
193 //
194 // optional
195 UserName string `json:"username,omitempty"`
196 // LanguageCode IETF language tag of the user's language
197 // more info: https://en.wikipedia.org/wiki/IETF_language_tag
198 //
199 // optional
200 LanguageCode string `json:"language_code,omitempty"`
201 // CanJoinGroups is true, if the bot can be invited to groups.
202 // Returned only in getMe.
203 //
204 // optional
205 CanJoinGroups bool `json:"can_join_groups,omitempty"`
206 // CanReadAllGroupMessages is true, if privacy mode is disabled for the bot.
207 // Returned only in getMe.
208 //
209 // optional
210 CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
211 // SupportsInlineQueries is true, if the bot supports inline queries.
212 // Returned only in getMe.
213 //
214 // optional
215 SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
216}
217
218// String displays a simple text version of a user.
219//
220// It is normally a user's username, but falls back to a first/last
221// name as available.
222func (u *User) String() string {
223 if u == nil {
224 return ""
225 }
226 if u.UserName != "" {
227 return u.UserName
228 }
229
230 name := u.FirstName
231 if u.LastName != "" {
232 name += " " + u.LastName
233 }
234
235 return name
236}
237
238// Chat represents a chat.
239type Chat struct {
240 // ID is a unique identifier for this chat
241 ID int64 `json:"id"`
242 // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
243 Type string `json:"type"`
244 // Title for supergroups, channels and group chats
245 //
246 // optional
247 Title string `json:"title,omitempty"`
248 // UserName for private chats, supergroups and channels if available
249 //
250 // optional
251 UserName string `json:"username,omitempty"`
252 // FirstName of the other party in a private chat
253 //
254 // optional
255 FirstName string `json:"first_name,omitempty"`
256 // LastName of the other party in a private chat
257 //
258 // optional
259 LastName string `json:"last_name,omitempty"`
260 // Photo is a chat photo
261 Photo *ChatPhoto `json:"photo"`
262 // Bio is the bio of the other party in a private chat. Returned only in
263 // getChat
264 //
265 // optional
266 Bio string `json:"bio,omitempty"`
267 // HasPrivateForwards is true if privacy settings of the other party in the
268 // private chat allows to use tg://user?id=<user_id> links only in chats
269 // with the user. Returned only in getChat.
270 //
271 // optional
272 HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
273 // Description for groups, supergroups and channel chats
274 //
275 // optional
276 Description string `json:"description,omitempty"`
277 // InviteLink is a chat invite link, for groups, supergroups and channel chats.
278 // Each administrator in a chat generates their own invite links,
279 // so the bot must first generate the link using exportChatInviteLink
280 //
281 // optional
282 InviteLink string `json:"invite_link,omitempty"`
283 // PinnedMessage is the pinned message, for groups, supergroups and channels
284 //
285 // optional
286 PinnedMessage *Message `json:"pinned_message,omitempty"`
287 // Permissions are default chat member permissions, for groups and
288 // supergroups. Returned only in getChat.
289 //
290 // optional
291 Permissions *ChatPermissions `json:"permissions,omitempty"`
292 // SlowModeDelay is for supergroups, the minimum allowed delay between
293 // consecutive messages sent by each unprivileged user. Returned only in
294 // getChat.
295 //
296 // optional
297 SlowModeDelay int `json:"slow_mode_delay,omitempty"`
298 // MessageAutoDeleteTime is the time after which all messages sent to the
299 // chat will be automatically deleted; in seconds. Returned only in getChat.
300 //
301 // optional
302 MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
303 // HasProtectedContent is true if messages from the chat can't be forwarded
304 // to other chats. Returned only in getChat.
305 //
306 // optional
307 HasProtectedContent bool `json:"has_protected_content,omitempty"`
308 // StickerSetName is for supergroups, name of group sticker set.Returned
309 // only in getChat.
310 //
311 // optional
312 StickerSetName string `json:"sticker_set_name,omitempty"`
313 // CanSetStickerSet is true, if the bot can change the group sticker set.
314 // Returned only in getChat.
315 //
316 // optional
317 CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
318 // LinkedChatID is a unique identifier for the linked chat, i.e. the
319 // discussion group identifier for a channel and vice versa; for supergroups
320 // and channel chats.
321 //
322 // optional
323 LinkedChatID int64 `json:"linked_chat_id,omitempty"`
324 // Location is for supergroups, the location to which the supergroup is
325 // connected. Returned only in getChat.
326 //
327 // optional
328 Location *ChatLocation `json:"location,omitempty"`
329}
330
331// IsPrivate returns if the Chat is a private conversation.
332func (c Chat) IsPrivate() bool {
333 return c.Type == "private"
334}
335
336// IsGroup returns if the Chat is a group.
337func (c Chat) IsGroup() bool {
338 return c.Type == "group"
339}
340
341// IsSuperGroup returns if the Chat is a supergroup.
342func (c Chat) IsSuperGroup() bool {
343 return c.Type == "supergroup"
344}
345
346// IsChannel returns if the Chat is a channel.
347func (c Chat) IsChannel() bool {
348 return c.Type == "channel"
349}
350
351// ChatConfig returns a ChatConfig struct for chat related methods.
352func (c Chat) ChatConfig() ChatConfig {
353 return ChatConfig{ChatID: c.ID}
354}
355
356// Message represents a message.
357type Message struct {
358 // MessageID is a unique message identifier inside this chat
359 MessageID int `json:"message_id"`
360 // From is a sender, empty for messages sent to channels;
361 //
362 // optional
363 From *User `json:"from,omitempty"`
364 // SenderChat is the sender of the message, sent on behalf of a chat. The
365 // channel itself for channel messages. The supergroup itself for messages
366 // from anonymous group administrators. The linked channel for messages
367 // automatically forwarded to the discussion group
368 //
369 // optional
370 SenderChat *Chat `json:"sender_chat,omitempty"`
371 // Date of the message was sent in Unix time
372 Date int `json:"date"`
373 // Chat is the conversation the message belongs to
374 Chat *Chat `json:"chat"`
375 // ForwardFrom for forwarded messages, sender of the original message;
376 //
377 // optional
378 ForwardFrom *User `json:"forward_from,omitempty"`
379 // ForwardFromChat for messages forwarded from channels,
380 // information about the original channel;
381 //
382 // optional
383 ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
384 // ForwardFromMessageID for messages forwarded from channels,
385 // identifier of the original message in the channel;
386 //
387 // optional
388 ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
389 // ForwardSignature for messages forwarded from channels, signature of the
390 // post author if present
391 //
392 // optional
393 ForwardSignature string `json:"forward_signature,omitempty"`
394 // ForwardSenderName is the sender's name for messages forwarded from users
395 // who disallow adding a link to their account in forwarded messages
396 //
397 // optional
398 ForwardSenderName string `json:"forward_sender_name,omitempty"`
399 // ForwardDate for forwarded messages, date the original message was sent in Unix time;
400 //
401 // optional
402 ForwardDate int `json:"forward_date,omitempty"`
403 // IsAutomaticForward is true if the message is a channel post that was
404 // automatically forwarded to the connected discussion group.
405 //
406 // optional
407 IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
408 // ReplyToMessage for replies, the original message.
409 // Note that the Message object in this field will not contain further ReplyToMessage fields
410 // even if it itself is a reply;
411 //
412 // optional
413 ReplyToMessage *Message `json:"reply_to_message,omitempty"`
414 // ViaBot through which the message was sent;
415 //
416 // optional
417 ViaBot *User `json:"via_bot,omitempty"`
418 // EditDate of the message was last edited in Unix time;
419 //
420 // optional
421 EditDate int `json:"edit_date,omitempty"`
422 // HasProtectedContent is true if the message can't be forwarded.
423 //
424 // optional
425 HasProtectedContent bool `json:"has_protected_content,omitempty"`
426 // MediaGroupID is the unique identifier of a media message group this message belongs to;
427 //
428 // optional
429 MediaGroupID string `json:"media_group_id,omitempty"`
430 // AuthorSignature is the signature of the post author for messages in channels;
431 //
432 // optional
433 AuthorSignature string `json:"author_signature,omitempty"`
434 // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
435 //
436 // optional
437 Text string `json:"text,omitempty"`
438 // Entities are for text messages, special entities like usernames,
439 // URLs, bot commands, etc. that appear in the text;
440 //
441 // optional
442 Entities []MessageEntity `json:"entities,omitempty"`
443 // Animation message is an animation, information about the animation.
444 // For backward compatibility, when this field is set, the document field will also be set;
445 //
446 // optional
447 Animation *Animation `json:"animation,omitempty"`
448 // Audio message is an audio file, information about the file;
449 //
450 // optional
451 Audio *Audio `json:"audio,omitempty"`
452 // Document message is a general file, information about the file;
453 //
454 // optional
455 Document *Document `json:"document,omitempty"`
456 // Photo message is a photo, available sizes of the photo;
457 //
458 // optional
459 Photo []PhotoSize `json:"photo,omitempty"`
460 // Sticker message is a sticker, information about the sticker;
461 //
462 // optional
463 Sticker *Sticker `json:"sticker,omitempty"`
464 // Video message is a video, information about the video;
465 //
466 // optional
467 Video *Video `json:"video,omitempty"`
468 // VideoNote message is a video note, information about the video message;
469 //
470 // optional
471 VideoNote *VideoNote `json:"video_note,omitempty"`
472 // Voice message is a voice message, information about the file;
473 //
474 // optional
475 Voice *Voice `json:"voice,omitempty"`
476 // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
477 //
478 // optional
479 Caption string `json:"caption,omitempty"`
480 // CaptionEntities;
481 //
482 // optional
483 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
484 // Contact message is a shared contact, information about the contact;
485 //
486 // optional
487 Contact *Contact `json:"contact,omitempty"`
488 // Dice is a dice with random value;
489 //
490 // optional
491 Dice *Dice `json:"dice,omitempty"`
492 // Game message is a game, information about the game;
493 //
494 // optional
495 Game *Game `json:"game,omitempty"`
496 // Poll is a native poll, information about the poll;
497 //
498 // optional
499 Poll *Poll `json:"poll,omitempty"`
500 // Venue message is a venue, information about the venue.
501 // For backward compatibility, when this field is set, the location field
502 // will also be set;
503 //
504 // optional
505 Venue *Venue `json:"venue,omitempty"`
506 // Location message is a shared location, information about the location;
507 //
508 // optional
509 Location *Location `json:"location,omitempty"`
510 // NewChatMembers that were added to the group or supergroup
511 // and information about them (the bot itself may be one of these members);
512 //
513 // optional
514 NewChatMembers []User `json:"new_chat_members,omitempty"`
515 // LeftChatMember is a member was removed from the group,
516 // information about them (this member may be the bot itself);
517 //
518 // optional
519 LeftChatMember *User `json:"left_chat_member,omitempty"`
520 // NewChatTitle is a chat title was changed to this value;
521 //
522 // optional
523 NewChatTitle string `json:"new_chat_title,omitempty"`
524 // NewChatPhoto is a chat photo was change to this value;
525 //
526 // optional
527 NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
528 // DeleteChatPhoto is a service message: the chat photo was deleted;
529 //
530 // optional
531 DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
532 // GroupChatCreated is a service message: the group has been created;
533 //
534 // optional
535 GroupChatCreated bool `json:"group_chat_created,omitempty"`
536 // SuperGroupChatCreated is a service message: the supergroup has been created.
537 // This field can't be received in a message coming through updates,
538 // because bot can't be a member of a supergroup when it is created.
539 // It can only be found in ReplyToMessage if someone replies to a very first message
540 // in a directly created supergroup;
541 //
542 // optional
543 SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
544 // ChannelChatCreated is a service message: the channel has been created.
545 // This field can't be received in a message coming through updates,
546 // because bot can't be a member of a channel when it is created.
547 // It can only be found in ReplyToMessage
548 // if someone replies to a very first message in a channel;
549 //
550 // optional
551 ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
552 // MessageAutoDeleteTimerChanged is a service message: auto-delete timer
553 // settings changed in the chat.
554 //
555 // optional
556 MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`
557 // MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
558 // This number may be greater than 32 bits and some programming languages
559 // may have difficulty/silent defects in interpreting it.
560 // But it is smaller than 52 bits, so a signed 64-bit integer
561 // or double-precision float type are safe for storing this identifier;
562 //
563 // optional
564 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
565 // MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
566 // This number may be greater than 32 bits and some programming languages
567 // may have difficulty/silent defects in interpreting it.
568 // But it is smaller than 52 bits, so a signed 64-bit integer
569 // or double-precision float type are safe for storing this identifier;
570 //
571 // optional
572 MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
573 // PinnedMessage is a specified message was pinned.
574 // Note that the Message object in this field will not contain further ReplyToMessage
575 // fields even if it is itself a reply;
576 //
577 // optional
578 PinnedMessage *Message `json:"pinned_message,omitempty"`
579 // Invoice message is an invoice for a payment;
580 //
581 // optional
582 Invoice *Invoice `json:"invoice,omitempty"`
583 // SuccessfulPayment message is a service message about a successful payment,
584 // information about the payment;
585 //
586 // optional
587 SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
588 // ConnectedWebsite is the domain name of the website on which the user has
589 // logged in;
590 //
591 // optional
592 ConnectedWebsite string `json:"connected_website,omitempty"`
593 // PassportData is a Telegram Passport data;
594 //
595 // optional
596 PassportData *PassportData `json:"passport_data,omitempty"`
597 // ProximityAlertTriggered is a service message. A user in the chat
598 // triggered another user's proximity alert while sharing Live Location
599 //
600 // optional
601 ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
602 // VideoChatScheduled is a service message: video chat scheduled.
603 //
604 // optional
605 VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"`
606 // VideoChatStarted is a service message: video chat started.
607 //
608 // optional
609 VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"`
610 // VideoChatEnded is a service message: video chat ended.
611 //
612 // optional
613 VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"`
614 // VideoChatParticipantsInvited is a service message: new participants
615 // invited to a video chat.
616 //
617 // optional
618 VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited,omitempty"`
619 // WebAppData is a service message: data sent by a Web App.
620 //
621 // optional
622 WebAppData *WebAppData `json:"web_app_data,omitempty"`
623 // ReplyMarkup is the Inline keyboard attached to the message.
624 // login_url buttons are represented as ordinary url buttons.
625 //
626 // optional
627 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
628}
629
630// Time converts the message timestamp into a Time.
631func (m *Message) Time() time.Time {
632 return time.Unix(int64(m.Date), 0)
633}
634
635// IsCommand returns true if message starts with a "bot_command" entity.
636func (m *Message) IsCommand() bool {
637 if m.Entities == nil || len(m.Entities) == 0 {
638 return false
639 }
640
641 entity := m.Entities[0]
642 return entity.Offset == 0 && entity.IsCommand()
643}
644
645// Command checks if the message was a command and if it was, returns the
646// command. If the Message was not a command, it returns an empty string.
647//
648// If the command contains the at name syntax, it is removed. Use
649// CommandWithAt() if you do not want that.
650func (m *Message) Command() string {
651 command := m.CommandWithAt()
652
653 if i := strings.Index(command, "@"); i != -1 {
654 command = command[:i]
655 }
656
657 return command
658}
659
660// CommandWithAt checks if the message was a command and if it was, returns the
661// command. If the Message was not a command, it returns an empty string.
662//
663// If the command contains the at name syntax, it is not removed. Use Command()
664// if you want that.
665func (m *Message) CommandWithAt() string {
666 if !m.IsCommand() {
667 return ""
668 }
669
670 // IsCommand() checks that the message begins with a bot_command entity
671 entity := m.Entities[0]
672 return m.Text[1:entity.Length]
673}
674
675// CommandArguments checks if the message was a command and if it was,
676// returns all text after the command name. If the Message was not a
677// command, it returns an empty string.
678//
679// Note: The first character after the command name is omitted:
680// - "/foo bar baz" yields "bar baz", not " bar baz"
681// - "/foo-bar baz" yields "bar baz", too
682// Even though the latter is not a command conforming to the spec, the API
683// marks "/foo" as command entity.
684func (m *Message) CommandArguments() string {
685 if !m.IsCommand() {
686 return ""
687 }
688
689 // IsCommand() checks that the message begins with a bot_command entity
690 entity := m.Entities[0]
691
692 if len(m.Text) == entity.Length {
693 return "" // The command makes up the whole message
694 }
695
696 return m.Text[entity.Length+1:]
697}
698
699// MessageID represents a unique message identifier.
700type MessageID struct {
701 MessageID int `json:"message_id"`
702}
703
704// MessageEntity represents one special entity in a text message.
705type MessageEntity struct {
706 // Type of the entity.
707 // Can be:
708 // “mention” (@username),
709 // “hashtag” (#hashtag),
710 // “cashtag” ($USD),
711 // “bot_command” (/start@jobs_bot),
712 // “url” (https://telegram.org),
713 // “email” (do-not-reply@telegram.org),
714 // “phone_number” (+1-212-555-0123),
715 // “bold” (bold text),
716 // “italic” (italic text),
717 // “underline” (underlined text),
718 // “strikethrough” (strikethrough text),
719 // "spoiler" (spoiler message),
720 // “code” (monowidth string),
721 // “pre” (monowidth block),
722 // “text_link” (for clickable text URLs),
723 // “text_mention” (for users without usernames)
724 Type string `json:"type"`
725 // Offset in UTF-16 code units to the start of the entity
726 Offset int `json:"offset"`
727 // Length
728 Length int `json:"length"`
729 // URL for “text_link” only, url that will be opened after user taps on the text
730 //
731 // optional
732 URL string `json:"url,omitempty"`
733 // User for “text_mention” only, the mentioned user
734 //
735 // optional
736 User *User `json:"user,omitempty"`
737 // Language for “pre” only, the programming language of the entity text
738 //
739 // optional
740 Language string `json:"language,omitempty"`
741}
742
743// ParseURL attempts to parse a URL contained within a MessageEntity.
744func (e MessageEntity) ParseURL() (*url.URL, error) {
745 if e.URL == "" {
746 return nil, errors.New(ErrBadURL)
747 }
748
749 return url.Parse(e.URL)
750}
751
752// IsMention returns true if the type of the message entity is "mention" (@username).
753func (e MessageEntity) IsMention() bool {
754 return e.Type == "mention"
755}
756
757// IsTextMention returns true if the type of the message entity is "text_mention"
758// (At this time, the user field exists, and occurs when tagging a member without a username)
759func (e MessageEntity) IsTextMention() bool {
760 return e.Type == "text_mention"
761}
762
763// IsHashtag returns true if the type of the message entity is "hashtag".
764func (e MessageEntity) IsHashtag() bool {
765 return e.Type == "hashtag"
766}
767
768// IsCommand returns true if the type of the message entity is "bot_command".
769func (e MessageEntity) IsCommand() bool {
770 return e.Type == "bot_command"
771}
772
773// IsURL returns true if the type of the message entity is "url".
774func (e MessageEntity) IsURL() bool {
775 return e.Type == "url"
776}
777
778// IsEmail returns true if the type of the message entity is "email".
779func (e MessageEntity) IsEmail() bool {
780 return e.Type == "email"
781}
782
783// IsBold returns true if the type of the message entity is "bold" (bold text).
784func (e MessageEntity) IsBold() bool {
785 return e.Type == "bold"
786}
787
788// IsItalic returns true if the type of the message entity is "italic" (italic text).
789func (e MessageEntity) IsItalic() bool {
790 return e.Type == "italic"
791}
792
793// IsCode returns true if the type of the message entity is "code" (monowidth string).
794func (e MessageEntity) IsCode() bool {
795 return e.Type == "code"
796}
797
798// IsPre returns true if the type of the message entity is "pre" (monowidth block).
799func (e MessageEntity) IsPre() bool {
800 return e.Type == "pre"
801}
802
803// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
804func (e MessageEntity) IsTextLink() bool {
805 return e.Type == "text_link"
806}
807
808// PhotoSize represents one size of a photo or a file / sticker thumbnail.
809type PhotoSize struct {
810 // FileID identifier for this file, which can be used to download or reuse
811 // the file
812 FileID string `json:"file_id"`
813 // FileUniqueID is the unique identifier for this file, which is supposed to
814 // be the same over time and for different bots. Can't be used to download
815 // or reuse the file.
816 FileUniqueID string `json:"file_unique_id"`
817 // Width photo width
818 Width int `json:"width"`
819 // Height photo height
820 Height int `json:"height"`
821 // FileSize file size
822 //
823 // optional
824 FileSize int `json:"file_size,omitempty"`
825}
826
827// Animation represents an animation file.
828type Animation struct {
829 // FileID is the identifier for this file, which can be used to download or reuse
830 // the file
831 FileID string `json:"file_id"`
832 // FileUniqueID is the unique identifier for this file, which is supposed to
833 // be the same over time and for different bots. Can't be used to download
834 // or reuse the file.
835 FileUniqueID string `json:"file_unique_id"`
836 // Width video width as defined by sender
837 Width int `json:"width"`
838 // Height video height as defined by sender
839 Height int `json:"height"`
840 // Duration of the video in seconds as defined by sender
841 Duration int `json:"duration"`
842 // Thumbnail animation thumbnail as defined by sender
843 //
844 // optional
845 Thumbnail *PhotoSize `json:"thumb,omitempty"`
846 // FileName original animation filename as defined by sender
847 //
848 // optional
849 FileName string `json:"file_name,omitempty"`
850 // MimeType of the file as defined by sender
851 //
852 // optional
853 MimeType string `json:"mime_type,omitempty"`
854 // FileSize file size
855 //
856 // optional
857 FileSize int `json:"file_size,omitempty"`
858}
859
860// Audio represents an audio file to be treated as music by the Telegram clients.
861type Audio struct {
862 // FileID is an identifier for this file, which can be used to download or
863 // reuse the file
864 FileID string `json:"file_id"`
865 // FileUniqueID is the unique identifier for this file, which is supposed to
866 // be the same over time and for different bots. Can't be used to download
867 // or reuse the file.
868 FileUniqueID string `json:"file_unique_id"`
869 // Duration of the audio in seconds as defined by sender
870 Duration int `json:"duration"`
871 // Performer of the audio as defined by sender or by audio tags
872 //
873 // optional
874 Performer string `json:"performer,omitempty"`
875 // Title of the audio as defined by sender or by audio tags
876 //
877 // optional
878 Title string `json:"title,omitempty"`
879 // FileName is the original filename as defined by sender
880 //
881 // optional
882 FileName string `json:"file_name,omitempty"`
883 // MimeType of the file as defined by sender
884 //
885 // optional
886 MimeType string `json:"mime_type,omitempty"`
887 // FileSize file size
888 //
889 // optional
890 FileSize int `json:"file_size,omitempty"`
891 // Thumbnail is the album cover to which the music file belongs
892 //
893 // optional
894 Thumbnail *PhotoSize `json:"thumb,omitempty"`
895}
896
897// Document represents a general file.
898type Document struct {
899 // FileID is an identifier for this file, which can be used to download or
900 // reuse the file
901 FileID string `json:"file_id"`
902 // FileUniqueID is the unique identifier for this file, which is supposed to
903 // be the same over time and for different bots. Can't be used to download
904 // or reuse the file.
905 FileUniqueID string `json:"file_unique_id"`
906 // Thumbnail document thumbnail as defined by sender
907 //
908 // optional
909 Thumbnail *PhotoSize `json:"thumb,omitempty"`
910 // FileName original filename as defined by sender
911 //
912 // optional
913 FileName string `json:"file_name,omitempty"`
914 // MimeType of the file as defined by sender
915 //
916 // optional
917 MimeType string `json:"mime_type,omitempty"`
918 // FileSize file size
919 //
920 // optional
921 FileSize int `json:"file_size,omitempty"`
922}
923
924// Video represents a video file.
925type Video struct {
926 // FileID identifier for this file, which can be used to download or reuse
927 // the file
928 FileID string `json:"file_id"`
929 // FileUniqueID is the unique identifier for this file, which is supposed to
930 // be the same over time and for different bots. Can't be used to download
931 // or reuse the file.
932 FileUniqueID string `json:"file_unique_id"`
933 // Width video width as defined by sender
934 Width int `json:"width"`
935 // Height video height as defined by sender
936 Height int `json:"height"`
937 // Duration of the video in seconds as defined by sender
938 Duration int `json:"duration"`
939 // Thumbnail video thumbnail
940 //
941 // optional
942 Thumbnail *PhotoSize `json:"thumb,omitempty"`
943 // FileName is the original filename as defined by sender
944 //
945 // optional
946 FileName string `json:"file_name,omitempty"`
947 // MimeType of a file as defined by sender
948 //
949 // optional
950 MimeType string `json:"mime_type,omitempty"`
951 // FileSize file size
952 //
953 // optional
954 FileSize int `json:"file_size,omitempty"`
955}
956
957// VideoNote object represents a video message.
958type VideoNote struct {
959 // FileID identifier for this file, which can be used to download or reuse the file
960 FileID string `json:"file_id"`
961 // FileUniqueID is the unique identifier for this file, which is supposed to
962 // be the same over time and for different bots. Can't be used to download
963 // or reuse the file.
964 FileUniqueID string `json:"file_unique_id"`
965 // Length video width and height (diameter of the video message) as defined by sender
966 Length int `json:"length"`
967 // Duration of the video in seconds as defined by sender
968 Duration int `json:"duration"`
969 // Thumbnail video thumbnail
970 //
971 // optional
972 Thumbnail *PhotoSize `json:"thumb,omitempty"`
973 // FileSize file size
974 //
975 // optional
976 FileSize int `json:"file_size,omitempty"`
977}
978
979// Voice represents a voice note.
980type Voice struct {
981 // FileID identifier for this file, which can be used to download or reuse the file
982 FileID string `json:"file_id"`
983 // FileUniqueID is the unique identifier for this file, which is supposed to
984 // be the same over time and for different bots. Can't be used to download
985 // or reuse the file.
986 FileUniqueID string `json:"file_unique_id"`
987 // Duration of the audio in seconds as defined by sender
988 Duration int `json:"duration"`
989 // MimeType of the file as defined by sender
990 //
991 // optional
992 MimeType string `json:"mime_type,omitempty"`
993 // FileSize file size
994 //
995 // optional
996 FileSize int `json:"file_size,omitempty"`
997}
998
999// Contact represents a phone contact.
1000//
1001// Note that LastName and UserID may be empty.
1002type Contact struct {
1003 // PhoneNumber contact's phone number
1004 PhoneNumber string `json:"phone_number"`
1005 // FirstName contact's first name
1006 FirstName string `json:"first_name"`
1007 // LastName contact's last name
1008 //
1009 // optional
1010 LastName string `json:"last_name,omitempty"`
1011 // UserID contact's user identifier in Telegram
1012 //
1013 // optional
1014 UserID int64 `json:"user_id,omitempty"`
1015 // VCard is additional data about the contact in the form of a vCard.
1016 //
1017 // optional
1018 VCard string `json:"vcard,omitempty"`
1019}
1020
1021// Dice represents an animated emoji that displays a random value.
1022type Dice struct {
1023 // Emoji on which the dice throw animation is based
1024 Emoji string `json:"emoji"`
1025 // Value of the dice
1026 Value int `json:"value"`
1027}
1028
1029// PollOption contains information about one answer option in a poll.
1030type PollOption struct {
1031 // Text is the option text, 1-100 characters
1032 Text string `json:"text"`
1033 // VoterCount is the number of users that voted for this option
1034 VoterCount int `json:"voter_count"`
1035}
1036
1037// PollAnswer represents an answer of a user in a non-anonymous poll.
1038type PollAnswer struct {
1039 // PollID is the unique poll identifier
1040 PollID string `json:"poll_id"`
1041 // User who changed the answer to the poll
1042 User User `json:"user"`
1043 // OptionIDs is the 0-based identifiers of poll options chosen by the user.
1044 // May be empty if user retracted vote.
1045 OptionIDs []int `json:"option_ids"`
1046}
1047
1048// Poll contains information about a poll.
1049type Poll struct {
1050 // ID is the unique poll identifier
1051 ID string `json:"id"`
1052 // Question is the poll question, 1-255 characters
1053 Question string `json:"question"`
1054 // Options is the list of poll options
1055 Options []PollOption `json:"options"`
1056 // TotalVoterCount is the total numbers of users who voted in the poll
1057 TotalVoterCount int `json:"total_voter_count"`
1058 // IsClosed is if the poll is closed
1059 IsClosed bool `json:"is_closed"`
1060 // IsAnonymous is if the poll is anonymous
1061 IsAnonymous bool `json:"is_anonymous"`
1062 // Type is the poll type, currently can be "regular" or "quiz"
1063 Type string `json:"type"`
1064 // AllowsMultipleAnswers is true, if the poll allows multiple answers
1065 AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
1066 // CorrectOptionID is the 0-based identifier of the correct answer option.
1067 // Available only for polls in quiz mode, which are closed, or was sent (not
1068 // forwarded) by the bot or to the private chat with the bot.
1069 //
1070 // optional
1071 CorrectOptionID int `json:"correct_option_id,omitempty"`
1072 // Explanation is text that is shown when a user chooses an incorrect answer
1073 // or taps on the lamp icon in a quiz-style poll, 0-200 characters
1074 //
1075 // optional
1076 Explanation string `json:"explanation,omitempty"`
1077 // ExplanationEntities are special entities like usernames, URLs, bot
1078 // commands, etc. that appear in the explanation
1079 //
1080 // optional
1081 ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
1082 // OpenPeriod is the amount of time in seconds the poll will be active
1083 // after creation
1084 //
1085 // optional
1086 OpenPeriod int `json:"open_period,omitempty"`
1087 // CloseDate is the point in time (unix timestamp) when the poll will be
1088 // automatically closed
1089 //
1090 // optional
1091 CloseDate int `json:"close_date,omitempty"`
1092}
1093
1094// Location represents a point on the map.
1095type Location struct {
1096 // Longitude as defined by sender
1097 Longitude float64 `json:"longitude"`
1098 // Latitude as defined by sender
1099 Latitude float64 `json:"latitude"`
1100 // HorizontalAccuracy is the radius of uncertainty for the location,
1101 // measured in meters; 0-1500
1102 //
1103 // optional
1104 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
1105 // LivePeriod is time relative to the message sending date, during which the
1106 // location can be updated, in seconds. For active live locations only.
1107 //
1108 // optional
1109 LivePeriod int `json:"live_period,omitempty"`
1110 // Heading is the direction in which user is moving, in degrees; 1-360. For
1111 // active live locations only.
1112 //
1113 // optional
1114 Heading int `json:"heading,omitempty"`
1115 // ProximityAlertRadius is the maximum distance for proximity alerts about
1116 // approaching another chat member, in meters. For sent live locations only.
1117 //
1118 // optional
1119 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
1120}
1121
1122// Venue represents a venue.
1123type Venue struct {
1124 // Location is the venue location
1125 Location Location `json:"location"`
1126 // Title is the name of the venue
1127 Title string `json:"title"`
1128 // Address of the venue
1129 Address string `json:"address"`
1130 // FoursquareID is the foursquare identifier of the venue
1131 //
1132 // optional
1133 FoursquareID string `json:"foursquare_id,omitempty"`
1134 // FoursquareType is the foursquare type of the venue
1135 //
1136 // optional
1137 FoursquareType string `json:"foursquare_type,omitempty"`
1138 // GooglePlaceID is the Google Places identifier of the venue
1139 //
1140 // optional
1141 GooglePlaceID string `json:"google_place_id,omitempty"`
1142 // GooglePlaceType is the Google Places type of the venue
1143 //
1144 // optional
1145 GooglePlaceType string `json:"google_place_type,omitempty"`
1146}
1147
1148// WebAppData Contains data sent from a Web App to the bot.
1149type WebAppData struct {
1150 // Data is the data. Be aware that a bad client can send arbitrary data in this field.
1151 Data string `json:"data"`
1152 // ButtonText is the text of the web_app keyboard button, from which the Web App
1153 // was opened. Be aware that a bad client can send arbitrary data in this field.
1154 ButtonText string `json:"button_text"`
1155}
1156
1157// ProximityAlertTriggered represents a service message sent when a user in the
1158// chat triggers a proximity alert sent by another user.
1159type ProximityAlertTriggered struct {
1160 // Traveler is the user that triggered the alert
1161 Traveler User `json:"traveler"`
1162 // Watcher is the user that set the alert
1163 Watcher User `json:"watcher"`
1164 // Distance is the distance between the users
1165 Distance int `json:"distance"`
1166}
1167
1168// MessageAutoDeleteTimerChanged represents a service message about a change in
1169// auto-delete timer settings.
1170type MessageAutoDeleteTimerChanged struct {
1171 // New auto-delete time for messages in the chat.
1172 MessageAutoDeleteTime int `json:"message_auto_delete_time"`
1173}
1174
1175// VideoChatScheduled represents a service message about a voice chat scheduled
1176// in the chat.
1177type VideoChatScheduled struct {
1178 // Point in time (Unix timestamp) when the voice chat is supposed to be
1179 // started by a chat administrator
1180 StartDate int `json:"start_date"`
1181}
1182
1183// Time converts the scheduled start date into a Time.
1184func (m *VideoChatScheduled) Time() time.Time {
1185 return time.Unix(int64(m.StartDate), 0)
1186}
1187
1188// VideoChatStarted represents a service message about a voice chat started in
1189// the chat.
1190type VideoChatStarted struct{}
1191
1192// VideoChatEnded represents a service message about a voice chat ended in the
1193// chat.
1194type VideoChatEnded struct {
1195 // Voice chat duration; in seconds.
1196 Duration int `json:"duration"`
1197}
1198
1199// VideoChatParticipantsInvited represents a service message about new members
1200// invited to a voice chat.
1201type VideoChatParticipantsInvited struct {
1202 // New members that were invited to the voice chat.
1203 //
1204 // optional
1205 Users []User `json:"users,omitempty"`
1206}
1207
1208// UserProfilePhotos contains a set of user profile photos.
1209type UserProfilePhotos struct {
1210 // TotalCount total number of profile pictures the target user has
1211 TotalCount int `json:"total_count"`
1212 // Photos requested profile pictures (in up to 4 sizes each)
1213 Photos [][]PhotoSize `json:"photos"`
1214}
1215
1216// File contains information about a file to download from Telegram.
1217type File struct {
1218 // FileID identifier for this file, which can be used to download or reuse
1219 // the file
1220 FileID string `json:"file_id"`
1221 // FileUniqueID is the unique identifier for this file, which is supposed to
1222 // be the same over time and for different bots. Can't be used to download
1223 // or reuse the file.
1224 FileUniqueID string `json:"file_unique_id"`
1225 // FileSize file size, if known
1226 //
1227 // optional
1228 FileSize int `json:"file_size,omitempty"`
1229 // FilePath file path
1230 //
1231 // optional
1232 FilePath string `json:"file_path,omitempty"`
1233}
1234
1235// Link returns a full path to the download URL for a File.
1236//
1237// It requires the Bot token to create the link.
1238func (f *File) Link(token string) string {
1239 return fmt.Sprintf(FileEndpoint, token, f.FilePath)
1240}
1241
1242// WebAppInfo contains information about a Web App.
1243type WebAppInfo struct {
1244 // URL is the HTTPS URL of a Web App to be opened with additional data as
1245 // specified in Initializing Web Apps.
1246 URL string `json:"url"`
1247}
1248
1249// ReplyKeyboardMarkup represents a custom keyboard with reply options.
1250type ReplyKeyboardMarkup struct {
1251 // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
1252 Keyboard [][]KeyboardButton `json:"keyboard"`
1253 // ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
1254 // (e.g., make the keyboard smaller if there are just two rows of buttons).
1255 // Defaults to false, in which case the custom keyboard
1256 // is always of the same height as the app's standard keyboard.
1257 //
1258 // optional
1259 ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
1260 // OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
1261 // The keyboard will still be available, but clients will automatically display
1262 // the usual letter-keyboard in the chat – the user can press a special button
1263 // in the input field to see the custom keyboard again.
1264 // Defaults to false.
1265 //
1266 // optional
1267 OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
1268 // InputFieldPlaceholder is the placeholder to be shown in the input field when
1269 // the keyboard is active; 1-64 characters.
1270 //
1271 // optional
1272 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
1273 // Selective use this parameter if you want to show the keyboard to specific users only.
1274 // Targets:
1275 // 1) users that are @mentioned in the text of the Message object;
1276 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
1277 //
1278 // Example: A user requests to change the bot's language,
1279 // bot replies to the request with a keyboard to select the new language.
1280 // Other users in the group don't see the keyboard.
1281 //
1282 // optional
1283 Selective bool `json:"selective,omitempty"`
1284}
1285
1286// KeyboardButton represents one button of the reply keyboard. For simple text
1287// buttons String can be used instead of this object to specify text of the
1288// button. Optional fields request_contact, request_location, and request_poll
1289// are mutually exclusive.
1290type KeyboardButton struct {
1291 // Text of the button. If none of the optional fields are used,
1292 // it will be sent as a message when the button is pressed.
1293 Text string `json:"text"`
1294 // RequestContact if True, the user's phone number will be sent
1295 // as a contact when the button is pressed.
1296 // Available in private chats only.
1297 //
1298 // optional
1299 RequestContact bool `json:"request_contact,omitempty"`
1300 // RequestLocation if True, the user's current location will be sent when
1301 // the button is pressed.
1302 // Available in private chats only.
1303 //
1304 // optional
1305 RequestLocation bool `json:"request_location,omitempty"`
1306 // RequestPoll if specified, the user will be asked to create a poll and send it
1307 // to the bot when the button is pressed. Available in private chats only
1308 //
1309 // optional
1310 RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
1311 // WebApp if specified, the described Web App will be launched when the button
1312 // is pressed. The Web App will be able to send a “web_app_data” service
1313 // message. Available in private chats only.
1314 //
1315 // optional
1316 WebApp *WebAppInfo `json:"web_app,omitempty"`
1317}
1318
1319// KeyboardButtonPollType represents type of poll, which is allowed to
1320// be created and sent when the corresponding button is pressed.
1321type KeyboardButtonPollType struct {
1322 // Type is if quiz is passed, the user will be allowed to create only polls
1323 // in the quiz mode. If regular is passed, only regular polls will be
1324 // allowed. Otherwise, the user will be allowed to create a poll of any type.
1325 Type string `json:"type"`
1326}
1327
1328// ReplyKeyboardRemove Upon receiving a message with this object, Telegram
1329// clients will remove the current custom keyboard and display the default
1330// letter-keyboard. By default, custom keyboards are displayed until a new
1331// keyboard is sent by a bot. An exception is made for one-time keyboards
1332// that are hidden immediately after the user presses a button.
1333type ReplyKeyboardRemove struct {
1334 // RemoveKeyboard requests clients to remove the custom keyboard
1335 // (user will not be able to summon this keyboard;
1336 // if you want to hide the keyboard from sight but keep it accessible,
1337 // use one_time_keyboard in ReplyKeyboardMarkup).
1338 RemoveKeyboard bool `json:"remove_keyboard"`
1339 // Selective use this parameter if you want to remove the keyboard for specific users only.
1340 // Targets:
1341 // 1) users that are @mentioned in the text of the Message object;
1342 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
1343 //
1344 // Example: A user votes in a poll, bot returns confirmation message
1345 // in reply to the vote and removes the keyboard for that user,
1346 // while still showing the keyboard with poll options to users who haven't voted yet.
1347 //
1348 // optional
1349 Selective bool `json:"selective,omitempty"`
1350}
1351
1352// InlineKeyboardMarkup represents an inline keyboard that appears right next to
1353// the message it belongs to.
1354type InlineKeyboardMarkup struct {
1355 // InlineKeyboard array of button rows, each represented by an Array of
1356 // InlineKeyboardButton objects
1357 InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
1358}
1359
1360// InlineKeyboardButton represents one button of an inline keyboard. You must
1361// use exactly one of the optional fields.
1362//
1363// Note that some values are references as even an empty string
1364// will change behavior.
1365//
1366// CallbackGame, if set, MUST be first button in first row.
1367type InlineKeyboardButton struct {
1368 // Text label text on the button
1369 Text string `json:"text"`
1370 // URL HTTP or tg:// url to be opened when button is pressed.
1371 //
1372 // optional
1373 URL *string `json:"url,omitempty"`
1374 // LoginURL is an HTTP URL used to automatically authorize the user. Can be
1375 // used as a replacement for the Telegram Login Widget
1376 //
1377 // optional
1378 LoginURL *LoginURL `json:"login_url,omitempty"`
1379 // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
1380 //
1381 // optional
1382 CallbackData *string `json:"callback_data,omitempty"`
1383 // WebApp is the Description of the Web App that will be launched when the user presses the button.
1384 // The Web App will be able to send an arbitrary message on behalf of the user using the method
1385 // answerWebAppQuery. Available only in private chats between a user and the bot.
1386 //
1387 // optional
1388 WebApp *WebAppInfo `json:"web_app,omitempty"`
1389 // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
1390 // open that chat and insert the bot's username and the specified inline query in the input field.
1391 // Can be empty, in which case just the bot's username will be inserted.
1392 //
1393 // This offers an easy way for users to start using your bot
1394 // in inline mode when they are currently in a private chat with it.
1395 // Especially useful when combined with switch_pm… actions – in this case
1396 // the user will be automatically returned to the chat they switched from,
1397 // skipping the chat selection screen.
1398 //
1399 // optional
1400 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
1401 // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
1402 // and the specified inline query in the current chat's input field.
1403 // Can be empty, in which case only the bot's username will be inserted.
1404 //
1405 // This offers a quick way for the user to open your bot in inline mode
1406 // in the same chat – good for selecting something from multiple options.
1407 //
1408 // optional
1409 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
1410 // CallbackGame description of the game that will be launched when the user presses the button.
1411 //
1412 // optional
1413 CallbackGame *CallbackGame `json:"callback_game,omitempty"`
1414 // Pay specify True, to send a Pay button.
1415 //
1416 // NOTE: This type of button must always be the first button in the first row.
1417 //
1418 // optional
1419 Pay bool `json:"pay,omitempty"`
1420}
1421
1422// LoginURL represents a parameter of the inline keyboard button used to
1423// automatically authorize a user. Serves as a great replacement for the
1424// Telegram Login Widget when the user is coming from Telegram. All the user
1425// needs to do is tap/click a button and confirm that they want to log in.
1426type LoginURL struct {
1427 // URL is an HTTP URL to be opened with user authorization data added to the
1428 // query string when the button is pressed. If the user refuses to provide
1429 // authorization data, the original URL without information about the user
1430 // will be opened. The data added is the same as described in Receiving
1431 // authorization data.
1432 //
1433 // NOTE: You must always check the hash of the received data to verify the
1434 // authentication and the integrity of the data as described in Checking
1435 // authorization.
1436 URL string `json:"url"`
1437 // ForwardText is the new text of the button in forwarded messages
1438 //
1439 // optional
1440 ForwardText string `json:"forward_text,omitempty"`
1441 // BotUsername is the username of a bot, which will be used for user
1442 // authorization. See Setting up a bot for more details. If not specified,
1443 // the current bot's username will be assumed. The url's domain must be the
1444 // same as the domain linked with the bot. See Linking your domain to the
1445 // bot for more details.
1446 //
1447 // optional
1448 BotUsername string `json:"bot_username,omitempty"`
1449 // RequestWriteAccess if true requests permission for your bot to send
1450 // messages to the user
1451 //
1452 // optional
1453 RequestWriteAccess bool `json:"request_write_access,omitempty"`
1454}
1455
1456// CallbackQuery represents an incoming callback query from a callback button in
1457// an inline keyboard. If the button that originated the query was attached to a
1458// message sent by the bot, the field message will be present. If the button was
1459// attached to a message sent via the bot (in inline mode), the field
1460// inline_message_id will be present. Exactly one of the fields data or
1461// game_short_name will be present.
1462type CallbackQuery struct {
1463 // ID unique identifier for this query
1464 ID string `json:"id"`
1465 // From sender
1466 From *User `json:"from"`
1467 // Message with the callback button that originated the query.
1468 // Note that message content and message date will not be available if the
1469 // message is too old.
1470 //
1471 // optional
1472 Message *Message `json:"message,omitempty"`
1473 // InlineMessageID identifier of the message sent via the bot in inline
1474 // mode, that originated the query.
1475 //
1476 // optional
1477 InlineMessageID string `json:"inline_message_id,omitempty"`
1478 // ChatInstance global identifier, uniquely corresponding to the chat to
1479 // which the message with the callback button was sent. Useful for high
1480 // scores in games.
1481 ChatInstance string `json:"chat_instance"`
1482 // Data associated with the callback button. Be aware that
1483 // a bad client can send arbitrary data in this field.
1484 //
1485 // optional
1486 Data string `json:"data,omitempty"`
1487 // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
1488 //
1489 // optional
1490 GameShortName string `json:"game_short_name,omitempty"`
1491}
1492
1493// ForceReply when receiving a message with this object, Telegram clients will
1494// display a reply interface to the user (act as if the user has selected the
1495// bot's message and tapped 'Reply'). This can be extremely useful if you want
1496// to create user-friendly step-by-step interfaces without having to sacrifice
1497// privacy mode.
1498type ForceReply struct {
1499 // ForceReply shows reply interface to the user,
1500 // as if they manually selected the bot's message and tapped 'Reply'.
1501 ForceReply bool `json:"force_reply"`
1502 // InputFieldPlaceholder is the placeholder to be shown in the input field when
1503 // the reply is active; 1-64 characters.
1504 //
1505 // optional
1506 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
1507 // Selective use this parameter if you want to force reply from specific users only.
1508 // Targets:
1509 // 1) users that are @mentioned in the text of the Message object;
1510 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
1511 //
1512 // optional
1513 Selective bool `json:"selective,omitempty"`
1514}
1515
1516// ChatPhoto represents a chat photo.
1517type ChatPhoto struct {
1518 // SmallFileID is a file identifier of small (160x160) chat photo.
1519 // This file_id can be used only for photo download and
1520 // only for as long as the photo is not changed.
1521 SmallFileID string `json:"small_file_id"`
1522 // SmallFileUniqueID is a unique file identifier of small (160x160) chat
1523 // photo, which is supposed to be the same over time and for different bots.
1524 // Can't be used to download or reuse the file.
1525 SmallFileUniqueID string `json:"small_file_unique_id"`
1526 // BigFileID is a file identifier of big (640x640) chat photo.
1527 // This file_id can be used only for photo download and
1528 // only for as long as the photo is not changed.
1529 BigFileID string `json:"big_file_id"`
1530 // BigFileUniqueID is a file identifier of big (640x640) chat photo, which
1531 // is supposed to be the same over time and for different bots. Can't be
1532 // used to download or reuse the file.
1533 BigFileUniqueID string `json:"big_file_unique_id"`
1534}
1535
1536// ChatInviteLink represents an invite link for a chat.
1537type ChatInviteLink struct {
1538 // InviteLink is the invite link. If the link was created by another chat
1539 // administrator, then the second part of the link will be replaced with “…”.
1540 InviteLink string `json:"invite_link"`
1541 // Creator of the link.
1542 Creator User `json:"creator"`
1543 // CreatesJoinRequest is true if users joining the chat via the link need to
1544 // be approved by chat administrators.
1545 //
1546 // optional
1547 CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
1548 // IsPrimary is true, if the link is primary.
1549 IsPrimary bool `json:"is_primary"`
1550 // IsRevoked is true, if the link is revoked.
1551 IsRevoked bool `json:"is_revoked"`
1552 // Name is the name of the invite link.
1553 //
1554 // optional
1555 Name string `json:"name,omitempty"`
1556 // ExpireDate is the point in time (Unix timestamp) when the link will
1557 // expire or has been expired.
1558 //
1559 // optional
1560 ExpireDate int `json:"expire_date,omitempty"`
1561 // MemberLimit is the maximum number of users that can be members of the
1562 // chat simultaneously after joining the chat via this invite link; 1-99999.
1563 //
1564 // optional
1565 MemberLimit int `json:"member_limit,omitempty"`
1566 // PendingJoinRequestCount is the number of pending join requests created
1567 // using this link.
1568 //
1569 // optional
1570 PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
1571}
1572
1573type ChatAdministratorRights struct {
1574 IsAnonymous bool `json:"is_anonymous"`
1575 CanManageChat bool `json:"can_manage_chat"`
1576 CanDeleteMessages bool `json:"can_delete_messages"`
1577 CanManageVideoChats bool `json:"can_manage_video_chats"`
1578 CanRestrictMembers bool `json:"can_restrict_members"`
1579 CanPromoteMembers bool `json:"can_promote_members"`
1580 CanChangeInfo bool `json:"can_change_info"`
1581 CanInviteUsers bool `json:"can_invite_users"`
1582 CanPostMessages bool `json:"can_post_messages"`
1583 CanEditMessages bool `json:"can_edit_messages"`
1584 CanPinMessages bool `json:"can_pin_messages"`
1585}
1586
1587// ChatMember contains information about one member of a chat.
1588type ChatMember struct {
1589 // User information about the user
1590 User *User `json:"user"`
1591 // Status the member's status in the chat.
1592 // Can be
1593 // “creator”,
1594 // “administrator”,
1595 // “member”,
1596 // “restricted”,
1597 // “left” or
1598 // “kicked”
1599 Status string `json:"status"`
1600 // CustomTitle owner and administrators only. Custom title for this user
1601 //
1602 // optional
1603 CustomTitle string `json:"custom_title,omitempty"`
1604 // IsAnonymous owner and administrators only. True, if the user's presence
1605 // in the chat is hidden
1606 //
1607 // optional
1608 IsAnonymous bool `json:"is_anonymous,omitempty"`
1609 // UntilDate restricted and kicked only.
1610 // Date when restrictions will be lifted for this user;
1611 // unix time.
1612 //
1613 // optional
1614 UntilDate int64 `json:"until_date,omitempty"`
1615 // CanBeEdited administrators only.
1616 // True, if the bot is allowed to edit administrator privileges of that user.
1617 //
1618 // optional
1619 CanBeEdited bool `json:"can_be_edited,omitempty"`
1620 // CanManageChat administrators only.
1621 // True, if the administrator can access the chat event log, chat
1622 // statistics, message statistics in channels, see channel members, see
1623 // anonymous administrators in supergroups and ignore slow mode. Implied by
1624 // any other administrator privilege.
1625 //
1626 // optional
1627 CanManageChat bool `json:"can_manage_chat,omitempty"`
1628 // CanPostMessages administrators only.
1629 // True, if the administrator can post in the channel;
1630 // channels only.
1631 //
1632 // optional
1633 CanPostMessages bool `json:"can_post_messages,omitempty"`
1634 // CanEditMessages administrators only.
1635 // True, if the administrator can edit messages of other users and can pin messages;
1636 // channels only.
1637 //
1638 // optional
1639 CanEditMessages bool `json:"can_edit_messages,omitempty"`
1640 // CanDeleteMessages administrators only.
1641 // True, if the administrator can delete messages of other users.
1642 //
1643 // optional
1644 CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
1645 // CanManageVideoChats administrators only.
1646 // True, if the administrator can manage video chats.
1647 //
1648 // optional
1649 CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
1650 // CanRestrictMembers administrators only.
1651 // True, if the administrator can restrict, ban or unban chat members.
1652 //
1653 // optional
1654 CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
1655 // CanPromoteMembers administrators only.
1656 // True, if the administrator can add new administrators
1657 // with a subset of their own privileges or demote administrators that he has promoted,
1658 // directly or indirectly (promoted by administrators that were appointed by the user).
1659 //
1660 // optional
1661 CanPromoteMembers bool `json:"can_promote_members,omitempty"`
1662 // CanChangeInfo administrators and restricted only.
1663 // True, if the user is allowed to change the chat title, photo and other settings.
1664 //
1665 // optional
1666 CanChangeInfo bool `json:"can_change_info,omitempty"`
1667 // CanInviteUsers administrators and restricted only.
1668 // True, if the user is allowed to invite new users to the chat.
1669 //
1670 // optional
1671 CanInviteUsers bool `json:"can_invite_users,omitempty"`
1672 // CanPinMessages administrators and restricted only.
1673 // True, if the user is allowed to pin messages; groups and supergroups only
1674 //
1675 // optional
1676 CanPinMessages bool `json:"can_pin_messages,omitempty"`
1677 // IsMember is true, if the user is a member of the chat at the moment of
1678 // the request
1679 IsMember bool `json:"is_member"`
1680 // CanSendMessages
1681 //
1682 // optional
1683 CanSendMessages bool `json:"can_send_messages,omitempty"`
1684 // CanSendMediaMessages restricted only.
1685 // True, if the user is allowed to send text messages, contacts, locations and venues
1686 //
1687 // optional
1688 CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
1689 // CanSendPolls restricted only.
1690 // True, if the user is allowed to send polls
1691 //
1692 // optional
1693 CanSendPolls bool `json:"can_send_polls,omitempty"`
1694 // CanSendOtherMessages restricted only.
1695 // True, if the user is allowed to send audios, documents,
1696 // photos, videos, video notes and voice notes.
1697 //
1698 // optional
1699 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
1700 // CanAddWebPagePreviews restricted only.
1701 // True, if the user is allowed to add web page previews to their messages.
1702 //
1703 // optional
1704 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
1705}
1706
1707// IsCreator returns if the ChatMember was the creator of the chat.
1708func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
1709
1710// IsAdministrator returns if the ChatMember is a chat administrator.
1711func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
1712
1713// HasLeft returns if the ChatMember left the chat.
1714func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
1715
1716// WasKicked returns if the ChatMember was kicked from the chat.
1717func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
1718
1719// ChatMemberUpdated represents changes in the status of a chat member.
1720type ChatMemberUpdated struct {
1721 // Chat the user belongs to.
1722 Chat Chat `json:"chat"`
1723 // From is the performer of the action, which resulted in the change.
1724 From User `json:"from"`
1725 // Date the change was done in Unix time.
1726 Date int `json:"date"`
1727 // Previous information about the chat member.
1728 OldChatMember ChatMember `json:"old_chat_member"`
1729 // New information about the chat member.
1730 NewChatMember ChatMember `json:"new_chat_member"`
1731 // InviteLink is the link which was used by the user to join the chat;
1732 // for joining by invite link events only.
1733 //
1734 // optional
1735 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
1736}
1737
1738// ChatJoinRequest represents a join request sent to a chat.
1739type ChatJoinRequest struct {
1740 // Chat to which the request was sent.
1741 Chat Chat `json:"chat"`
1742 // User that sent the join request.
1743 From User `json:"from"`
1744 // Date the request was sent in Unix time.
1745 Date int `json:"date"`
1746 // Bio of the user.
1747 //
1748 // optional
1749 Bio string `json:"bio,omitempty"`
1750 // InviteLink is the link that was used by the user to send the join request.
1751 //
1752 // optional
1753 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
1754}
1755
1756// ChatPermissions describes actions that a non-administrator user is
1757// allowed to take in a chat. All fields are optional.
1758type ChatPermissions struct {
1759 // CanSendMessages is true, if the user is allowed to send text messages,
1760 // contacts, locations and venues
1761 //
1762 // optional
1763 CanSendMessages bool `json:"can_send_messages,omitempty"`
1764 // CanSendMediaMessages is true, if the user is allowed to send audios,
1765 // documents, photos, videos, video notes and voice notes, implies
1766 // can_send_messages
1767 //
1768 // optional
1769 CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
1770 // CanSendPolls is true, if the user is allowed to send polls, implies
1771 // can_send_messages
1772 //
1773 // optional
1774 CanSendPolls bool `json:"can_send_polls,omitempty"`
1775 // CanSendOtherMessages is true, if the user is allowed to send animations,
1776 // games, stickers and use inline bots, implies can_send_media_messages
1777 //
1778 // optional
1779 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
1780 // CanAddWebPagePreviews is true, if the user is allowed to add web page
1781 // previews to their messages, implies can_send_media_messages
1782 //
1783 // optional
1784 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
1785 // CanChangeInfo is true, if the user is allowed to change the chat title,
1786 // photo and other settings. Ignored in public supergroups
1787 //
1788 // optional
1789 CanChangeInfo bool `json:"can_change_info,omitempty"`
1790 // CanInviteUsers is true, if the user is allowed to invite new users to the
1791 // chat
1792 //
1793 // optional
1794 CanInviteUsers bool `json:"can_invite_users,omitempty"`
1795 // CanPinMessages is true, if the user is allowed to pin messages. Ignored
1796 // in public supergroups
1797 //
1798 // optional
1799 CanPinMessages bool `json:"can_pin_messages,omitempty"`
1800}
1801
1802// ChatLocation represents a location to which a chat is connected.
1803type ChatLocation struct {
1804 // Location is the location to which the supergroup is connected. Can't be a
1805 // live location.
1806 Location Location `json:"location"`
1807 // Address is the location address; 1-64 characters, as defined by the chat
1808 // owner
1809 Address string `json:"address"`
1810}
1811
1812// BotCommand represents a bot command.
1813type BotCommand struct {
1814 // Command text of the command, 1-32 characters.
1815 // Can contain only lowercase English letters, digits and underscores.
1816 Command string `json:"command"`
1817 // Description of the command, 3-256 characters.
1818 Description string `json:"description"`
1819}
1820
1821// BotCommandScope represents the scope to which bot commands are applied.
1822//
1823// It contains the fields for all types of scopes, different types only support
1824// specific (or no) fields.
1825type BotCommandScope struct {
1826 Type string `json:"type"`
1827 ChatID int64 `json:"chat_id,omitempty"`
1828 UserID int64 `json:"user_id,omitempty"`
1829}
1830
1831// MenuButton describes the bot's menu button in a private chat.
1832type MenuButton struct {
1833 // Type is the type of menu button, must be one of:
1834 // - `commands`
1835 // - `web_app`
1836 // - `default`
1837 Type string `json:"type"`
1838 // Text is the text on the button, for `web_app` type.
1839 Text string `json:"text,omitempty"`
1840 // WebApp is the description of the Web App that will be launched when the
1841 // user presses the button for the `web_app` type.
1842 WebApp *WebAppInfo `json:"web_app,omitempty"`
1843}
1844
1845// ResponseParameters are various errors that can be returned in APIResponse.
1846type ResponseParameters struct {
1847 // The group has been migrated to a supergroup with the specified identifier.
1848 //
1849 // optional
1850 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
1851 // In case of exceeding flood control, the number of seconds left to wait
1852 // before the request can be repeated.
1853 //
1854 // optional
1855 RetryAfter int `json:"retry_after,omitempty"`
1856}
1857
1858// BaseInputMedia is a base type for the InputMedia types.
1859type BaseInputMedia struct {
1860 // Type of the result.
1861 Type string `json:"type"`
1862 // Media file to send. Pass a file_id to send a file
1863 // that exists on the Telegram servers (recommended),
1864 // pass an HTTP URL for Telegram to get a file from the Internet,
1865 // or pass “attach://<file_attach_name>” to upload a new one
1866 // using multipart/form-data under <file_attach_name> name.
1867 Media RequestFileData `json:"media"`
1868 // thumb intentionally missing as it is not currently compatible
1869
1870 // Caption of the video to be sent, 0-1024 characters after entities parsing.
1871 //
1872 // optional
1873 Caption string `json:"caption,omitempty"`
1874 // ParseMode mode for parsing entities in the video caption.
1875 // See formatting options for more details
1876 // (https://core.telegram.org/bots/api#formatting-options).
1877 //
1878 // optional
1879 ParseMode string `json:"parse_mode,omitempty"`
1880 // CaptionEntities is a list of special entities that appear in the caption,
1881 // which can be specified instead of parse_mode
1882 //
1883 // optional
1884 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
1885}
1886
1887// InputMediaPhoto is a photo to send as part of a media group.
1888type InputMediaPhoto struct {
1889 BaseInputMedia
1890}
1891
1892// InputMediaVideo is a video to send as part of a media group.
1893type InputMediaVideo struct {
1894 BaseInputMedia
1895 // Thumbnail of the file sent; can be ignored if thumbnail generation for
1896 // the file is supported server-side.
1897 //
1898 // optional
1899 Thumb RequestFileData `json:"thumb,omitempty"`
1900 // Width video width
1901 //
1902 // optional
1903 Width int `json:"width,omitempty"`
1904 // Height video height
1905 //
1906 // optional
1907 Height int `json:"height,omitempty"`
1908 // Duration video duration
1909 //
1910 // optional
1911 Duration int `json:"duration,omitempty"`
1912 // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
1913 //
1914 // optional
1915 SupportsStreaming bool `json:"supports_streaming,omitempty"`
1916}
1917
1918// InputMediaAnimation is an animation to send as part of a media group.
1919type InputMediaAnimation struct {
1920 BaseInputMedia
1921 // Thumbnail of the file sent; can be ignored if thumbnail generation for
1922 // the file is supported server-side.
1923 //
1924 // optional
1925 Thumb RequestFileData `json:"thumb,omitempty"`
1926 // Width video width
1927 //
1928 // optional
1929 Width int `json:"width,omitempty"`
1930 // Height video height
1931 //
1932 // optional
1933 Height int `json:"height,omitempty"`
1934 // Duration video duration
1935 //
1936 // optional
1937 Duration int `json:"duration,omitempty"`
1938}
1939
1940// InputMediaAudio is an audio to send as part of a media group.
1941type InputMediaAudio struct {
1942 BaseInputMedia
1943 // Thumbnail of the file sent; can be ignored if thumbnail generation for
1944 // the file is supported server-side.
1945 //
1946 // optional
1947 Thumb RequestFileData `json:"thumb,omitempty"`
1948 // Duration of the audio in seconds
1949 //
1950 // optional
1951 Duration int `json:"duration,omitempty"`
1952 // Performer of the audio
1953 //
1954 // optional
1955 Performer string `json:"performer,omitempty"`
1956 // Title of the audio
1957 //
1958 // optional
1959 Title string `json:"title,omitempty"`
1960}
1961
1962// InputMediaDocument is a general file to send as part of a media group.
1963type InputMediaDocument struct {
1964 BaseInputMedia
1965 // Thumbnail of the file sent; can be ignored if thumbnail generation for
1966 // the file is supported server-side.
1967 //
1968 // optional
1969 Thumb RequestFileData `json:"thumb,omitempty"`
1970 // DisableContentTypeDetection disables automatic server-side content type
1971 // detection for files uploaded using multipart/form-data. Always true, if
1972 // the document is sent as part of an album
1973 //
1974 // optional
1975 DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
1976}
1977
1978// Sticker represents a sticker.
1979type Sticker struct {
1980 // FileID is an identifier for this file, which can be used to download or
1981 // reuse the file
1982 FileID string `json:"file_id"`
1983 // FileUniqueID is a unique identifier for this file,
1984 // which is supposed to be the same over time and for different bots.
1985 // Can't be used to download or reuse the file.
1986 FileUniqueID string `json:"file_unique_id"`
1987 // Width sticker width
1988 Width int `json:"width"`
1989 // Height sticker height
1990 Height int `json:"height"`
1991 // IsAnimated true, if the sticker is animated
1992 //
1993 // optional
1994 IsAnimated bool `json:"is_animated,omitempty"`
1995 // IsVideo true, if the sticker is a video sticker
1996 //
1997 // optional
1998 IsVideo bool `json:"is_video,omitempty"`
1999 // Thumbnail sticker thumbnail in the .WEBP or .JPG format
2000 //
2001 // optional
2002 Thumbnail *PhotoSize `json:"thumb,omitempty"`
2003 // Emoji associated with the sticker
2004 //
2005 // optional
2006 Emoji string `json:"emoji,omitempty"`
2007 // SetName of the sticker set to which the sticker belongs
2008 //
2009 // optional
2010 SetName string `json:"set_name,omitempty"`
2011 // PremiumAnimation for premium regular stickers, premium animation for the sticker
2012 //
2013 // optional
2014 PremiumAnimation *File `json:"premium_animation,omitempty"`
2015 // MaskPosition is for mask stickers, the position where the mask should be
2016 // placed
2017 //
2018 // optional
2019 MaskPosition *MaskPosition `json:"mask_position,omitempty"`
2020 // CustomEmojiID for custom emoji stickers, unique identifier of the custom emoji
2021 //
2022 // optional
2023 CustomEmojiID string `json:"custom_emoji_id,omitempty"`
2024 // FileSize
2025 //
2026 // optional
2027 FileSize int `json:"file_size,omitempty"`
2028}
2029
2030// StickerSet represents a sticker set.
2031type StickerSet struct {
2032 // Name sticker set name
2033 Name string `json:"name"`
2034 // Title sticker set title
2035 Title string `json:"title"`
2036 // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
2037 StickerType string `json:"sticker_type"`
2038 // IsAnimated true, if the sticker set contains animated stickers
2039 IsAnimated bool `json:"is_animated"`
2040 // IsVideo true, if the sticker set contains video stickers
2041 IsVideo bool `json:"is_video"`
2042 // ContainsMasks true, if the sticker set contains masks
2043 ContainsMasks bool `json:"contains_masks"`
2044 // Stickers list of all set stickers
2045 Stickers []Sticker `json:"stickers"`
2046 // Thumb is the sticker set thumbnail in the .WEBP or .TGS format
2047 Thumbnail *PhotoSize `json:"thumb"`
2048}
2049
2050// MaskPosition describes the position on faces where a mask should be placed
2051// by default.
2052type MaskPosition struct {
2053 // The part of the face relative to which the mask should be placed.
2054 // One of “forehead”, “eyes”, “mouth”, or “chin”.
2055 Point string `json:"point"`
2056 // Shift by X-axis measured in widths of the mask scaled to the face size,
2057 // from left to right. For example, choosing -1.0 will place mask just to
2058 // the left of the default mask position.
2059 XShift float64 `json:"x_shift"`
2060 // Shift by Y-axis measured in heights of the mask scaled to the face size,
2061 // from top to bottom. For example, 1.0 will place the mask just below the
2062 // default mask position.
2063 YShift float64 `json:"y_shift"`
2064 // Mask scaling coefficient. For example, 2.0 means double size.
2065 Scale float64 `json:"scale"`
2066}
2067
2068// Game represents a game. Use BotFather to create and edit games, their short
2069// names will act as unique identifiers.
2070type Game struct {
2071 // Title of the game
2072 Title string `json:"title"`
2073 // Description of the game
2074 Description string `json:"description"`
2075 // Photo that will be displayed in the game message in chats.
2076 Photo []PhotoSize `json:"photo"`
2077 // Text a brief description of the game or high scores included in the game message.
2078 // Can be automatically edited to include current high scores for the game
2079 // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
2080 //
2081 // optional
2082 Text string `json:"text,omitempty"`
2083 // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
2084 //
2085 // optional
2086 TextEntities []MessageEntity `json:"text_entities,omitempty"`
2087 // Animation is an animation that will be displayed in the game message in chats.
2088 // Upload via BotFather (https://t.me/botfather).
2089 //
2090 // optional
2091 Animation Animation `json:"animation,omitempty"`
2092}
2093
2094// GameHighScore is a user's score and position on the leaderboard.
2095type GameHighScore struct {
2096 // Position in high score table for the game
2097 Position int `json:"position"`
2098 // User user
2099 User User `json:"user"`
2100 // Score score
2101 Score int `json:"score"`
2102}
2103
2104// CallbackGame is for starting a game in an inline keyboard button.
2105type CallbackGame struct{}
2106
2107// WebhookInfo is information about a currently set webhook.
2108type WebhookInfo struct {
2109 // URL webhook URL, may be empty if webhook is not set up.
2110 URL string `json:"url"`
2111 // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
2112 HasCustomCertificate bool `json:"has_custom_certificate"`
2113 // PendingUpdateCount number of updates awaiting delivery.
2114 PendingUpdateCount int `json:"pending_update_count"`
2115 // IPAddress is the currently used webhook IP address
2116 //
2117 // optional
2118 IPAddress string `json:"ip_address,omitempty"`
2119 // LastErrorDate unix time for the most recent error
2120 // that happened when trying to deliver an update via webhook.
2121 //
2122 // optional
2123 LastErrorDate int `json:"last_error_date,omitempty"`
2124 // LastErrorMessage error message in human-readable format for the most recent error
2125 // that happened when trying to deliver an update via webhook.
2126 //
2127 // optional
2128 LastErrorMessage string `json:"last_error_message,omitempty"`
2129 // LastSynchronizationErrorDate is the unix time of the most recent error that
2130 // happened when trying to synchronize available updates with Telegram datacenters.
2131 LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
2132 // MaxConnections maximum allowed number of simultaneous
2133 // HTTPS connections to the webhook for update delivery.
2134 //
2135 // optional
2136 MaxConnections int `json:"max_connections,omitempty"`
2137 // AllowedUpdates is a list of update types the bot is subscribed to.
2138 // Defaults to all update types
2139 //
2140 // optional
2141 AllowedUpdates []string `json:"allowed_updates,omitempty"`
2142}
2143
2144// IsSet returns true if a webhook is currently set.
2145func (info WebhookInfo) IsSet() bool {
2146 return info.URL != ""
2147}
2148
2149// InlineQuery is a Query from Telegram for an inline request.
2150type InlineQuery struct {
2151 // ID unique identifier for this query
2152 ID string `json:"id"`
2153 // From sender
2154 From *User `json:"from"`
2155 // Query text of the query (up to 256 characters).
2156 Query string `json:"query"`
2157 // Offset of the results to be returned, can be controlled by the bot.
2158 Offset string `json:"offset"`
2159 // Type of the chat, from which the inline query was sent. Can be either
2160 // “sender” for a private chat with the inline query sender, “private”,
2161 // “group”, “supergroup”, or “channel”. The chat type should be always known
2162 // for requests sent from official clients and most third-party clients,
2163 // unless the request was sent from a secret chat
2164 //
2165 // optional
2166 ChatType string `json:"chat_type,omitempty"`
2167 // Location sender location, only for bots that request user location.
2168 //
2169 // optional
2170 Location *Location `json:"location,omitempty"`
2171}
2172
2173// InlineQueryResultCachedAudio is an inline query response with cached audio.
2174type InlineQueryResultCachedAudio struct {
2175 // Type of the result, must be audio
2176 Type string `json:"type"`
2177 // ID unique identifier for this result, 1-64 bytes
2178 ID string `json:"id"`
2179 // AudioID a valid file identifier for the audio file
2180 AudioID string `json:"audio_file_id"`
2181 // Caption 0-1024 characters after entities parsing
2182 //
2183 // optional
2184 Caption string `json:"caption,omitempty"`
2185 // ParseMode mode for parsing entities in the video caption.
2186 // See formatting options for more details
2187 // (https://core.telegram.org/bots/api#formatting-options).
2188 //
2189 // optional
2190 ParseMode string `json:"parse_mode,omitempty"`
2191 // CaptionEntities is a list of special entities that appear in the caption,
2192 // which can be specified instead of parse_mode
2193 //
2194 // optional
2195 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2196 // ReplyMarkup inline keyboard attached to the message
2197 //
2198 // optional
2199 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2200 // InputMessageContent content of the message to be sent instead of the audio
2201 //
2202 // optional
2203 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2204}
2205
2206// InlineQueryResultCachedDocument is an inline query response with cached document.
2207type InlineQueryResultCachedDocument struct {
2208 // Type of the result, must be a document
2209 Type string `json:"type"`
2210 // ID unique identifier for this result, 1-64 bytes
2211 ID string `json:"id"`
2212 // DocumentID a valid file identifier for the file
2213 DocumentID string `json:"document_file_id"`
2214 // Title for the result
2215 //
2216 // optional
2217 Title string `json:"title,omitempty"`
2218 // Caption of the document to be sent, 0-1024 characters after entities parsing
2219 //
2220 // optional
2221 Caption string `json:"caption,omitempty"`
2222 // Description short description of the result
2223 //
2224 // optional
2225 Description string `json:"description,omitempty"`
2226 // ParseMode mode for parsing entities in the video caption.
2227 // // See formatting options for more details
2228 // // (https://core.telegram.org/bots/api#formatting-options).
2229 //
2230 // optional
2231 ParseMode string `json:"parse_mode,omitempty"`
2232 // CaptionEntities is a list of special entities that appear in the caption,
2233 // which can be specified instead of parse_mode
2234 //
2235 // optional
2236 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2237 // ReplyMarkup inline keyboard attached to the message
2238 //
2239 // optional
2240 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2241 // InputMessageContent content of the message to be sent instead of the file
2242 //
2243 // optional
2244 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2245}
2246
2247// InlineQueryResultCachedGIF is an inline query response with cached gif.
2248type InlineQueryResultCachedGIF struct {
2249 // Type of the result, must be gif.
2250 Type string `json:"type"`
2251 // ID unique identifier for this result, 1-64 bytes.
2252 ID string `json:"id"`
2253 // GifID a valid file identifier for the GIF file.
2254 GIFID string `json:"gif_file_id"`
2255 // Title for the result
2256 //
2257 // optional
2258 Title string `json:"title,omitempty"`
2259 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
2260 //
2261 // optional
2262 Caption string `json:"caption,omitempty"`
2263 // ParseMode mode for parsing entities in the caption.
2264 // See formatting options for more details
2265 // (https://core.telegram.org/bots/api#formatting-options).
2266 //
2267 // optional
2268 ParseMode string `json:"parse_mode,omitempty"`
2269 // CaptionEntities is a list of special entities that appear in the caption,
2270 // which can be specified instead of parse_mode
2271 //
2272 // optional
2273 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2274 // ReplyMarkup inline keyboard attached to the message.
2275 //
2276 // optional
2277 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2278 // InputMessageContent content of the message to be sent instead of the GIF animation.
2279 //
2280 // optional
2281 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2282}
2283
2284// InlineQueryResultCachedMPEG4GIF is an inline query response with cached
2285// H.264/MPEG-4 AVC video without sound gif.
2286type InlineQueryResultCachedMPEG4GIF struct {
2287 // Type of the result, must be mpeg4_gif
2288 Type string `json:"type"`
2289 // ID unique identifier for this result, 1-64 bytes
2290 ID string `json:"id"`
2291 // MPEG4FileID a valid file identifier for the MP4 file
2292 MPEG4FileID string `json:"mpeg4_file_id"`
2293 // Title for the result
2294 //
2295 // optional
2296 Title string `json:"title,omitempty"`
2297 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
2298 //
2299 // optional
2300 Caption string `json:"caption,omitempty"`
2301 // ParseMode mode for parsing entities in the caption.
2302 // See formatting options for more details
2303 // (https://core.telegram.org/bots/api#formatting-options).
2304 //
2305 // optional
2306 ParseMode string `json:"parse_mode,omitempty"`
2307 // ParseMode mode for parsing entities in the video caption.
2308 // See formatting options for more details
2309 // (https://core.telegram.org/bots/api#formatting-options).
2310 //
2311 // optional
2312 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2313 // ReplyMarkup inline keyboard attached to the message.
2314 //
2315 // optional
2316 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2317 // InputMessageContent content of the message to be sent instead of the video animation.
2318 //
2319 // optional
2320 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2321}
2322
2323// InlineQueryResultCachedPhoto is an inline query response with cached photo.
2324type InlineQueryResultCachedPhoto struct {
2325 // Type of the result, must be a photo.
2326 Type string `json:"type"`
2327 // ID unique identifier for this result, 1-64 bytes.
2328 ID string `json:"id"`
2329 // PhotoID a valid file identifier of the photo.
2330 PhotoID string `json:"photo_file_id"`
2331 // Title for the result.
2332 //
2333 // optional
2334 Title string `json:"title,omitempty"`
2335 // Description short description of the result.
2336 //
2337 // optional
2338 Description string `json:"description,omitempty"`
2339 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
2340 //
2341 // optional
2342 Caption string `json:"caption,omitempty"`
2343 // ParseMode mode for parsing entities in the photo caption.
2344 // See formatting options for more details
2345 // (https://core.telegram.org/bots/api#formatting-options).
2346 //
2347 // optional
2348 ParseMode string `json:"parse_mode,omitempty"`
2349 // CaptionEntities is a list of special entities that appear in the caption,
2350 // which can be specified instead of parse_mode
2351 //
2352 // optional
2353 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2354 // ReplyMarkup inline keyboard attached to the message.
2355 //
2356 // optional
2357 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2358 // InputMessageContent content of the message to be sent instead of the photo.
2359 //
2360 // optional
2361 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2362}
2363
2364// InlineQueryResultCachedSticker is an inline query response with cached sticker.
2365type InlineQueryResultCachedSticker struct {
2366 // Type of the result, must be a sticker
2367 Type string `json:"type"`
2368 // ID unique identifier for this result, 1-64 bytes
2369 ID string `json:"id"`
2370 // StickerID a valid file identifier of the sticker
2371 StickerID string `json:"sticker_file_id"`
2372 // Title is a title
2373 Title string `json:"title"`
2374 // ReplyMarkup inline keyboard attached to the message
2375 //
2376 // optional
2377 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2378 // InputMessageContent content of the message to be sent instead of the sticker
2379 //
2380 // optional
2381 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2382}
2383
2384// InlineQueryResultCachedVideo is an inline query response with cached video.
2385type InlineQueryResultCachedVideo struct {
2386 // Type of the result, must be video
2387 Type string `json:"type"`
2388 // ID unique identifier for this result, 1-64 bytes
2389 ID string `json:"id"`
2390 // VideoID a valid file identifier for the video file
2391 VideoID string `json:"video_file_id"`
2392 // Title for the result
2393 Title string `json:"title"`
2394 // Description short description of the result
2395 //
2396 // optional
2397 Description string `json:"description,omitempty"`
2398 // Caption of the video to be sent, 0-1024 characters after entities parsing
2399 //
2400 // optional
2401 Caption string `json:"caption,omitempty"`
2402 // ParseMode mode for parsing entities in the video caption.
2403 // See formatting options for more details
2404 // (https://core.telegram.org/bots/api#formatting-options).
2405 //
2406 // optional
2407 ParseMode string `json:"parse_mode,omitempty"`
2408 // CaptionEntities is a list of special entities that appear in the caption,
2409 // which can be specified instead of parse_mode
2410 //
2411 // optional
2412 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2413 // ReplyMarkup inline keyboard attached to the message
2414 //
2415 // optional
2416 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2417 // InputMessageContent content of the message to be sent instead of the video
2418 //
2419 // optional
2420 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2421}
2422
2423// InlineQueryResultCachedVoice is an inline query response with cached voice.
2424type InlineQueryResultCachedVoice struct {
2425 // Type of the result, must be voice
2426 Type string `json:"type"`
2427 // ID unique identifier for this result, 1-64 bytes
2428 ID string `json:"id"`
2429 // VoiceID a valid file identifier for the voice message
2430 VoiceID string `json:"voice_file_id"`
2431 // Title voice message title
2432 Title string `json:"title"`
2433 // Caption 0-1024 characters after entities parsing
2434 //
2435 // optional
2436 Caption string `json:"caption,omitempty"`
2437 // ParseMode mode for parsing entities in the video caption.
2438 // See formatting options for more details
2439 // (https://core.telegram.org/bots/api#formatting-options).
2440 //
2441 // optional
2442 ParseMode string `json:"parse_mode,omitempty"`
2443 // CaptionEntities is a list of special entities that appear in the caption,
2444 // which can be specified instead of parse_mode
2445 //
2446 // optional
2447 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2448 // ReplyMarkup inline keyboard attached to the message
2449 //
2450 // optional
2451 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2452 // InputMessageContent content of the message to be sent instead of the voice message
2453 //
2454 // optional
2455 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2456}
2457
2458// InlineQueryResultArticle represents a link to an article or web page.
2459type InlineQueryResultArticle struct {
2460 // Type of the result, must be article.
2461 Type string `json:"type"`
2462 // ID unique identifier for this result, 1-64 Bytes.
2463 ID string `json:"id"`
2464 // Title of the result
2465 Title string `json:"title"`
2466 // InputMessageContent content of the message to be sent.
2467 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2468 // ReplyMarkup Inline keyboard attached to the message.
2469 //
2470 // optional
2471 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2472 // URL of the result.
2473 //
2474 // optional
2475 URL string `json:"url,omitempty"`
2476 // HideURL pass True, if you don't want the URL to be shown in the message.
2477 //
2478 // optional
2479 HideURL bool `json:"hide_url,omitempty"`
2480 // Description short description of the result.
2481 //
2482 // optional
2483 Description string `json:"description,omitempty"`
2484 // ThumbURL url of the thumbnail for the result
2485 //
2486 // optional
2487 ThumbURL string `json:"thumb_url,omitempty"`
2488 // ThumbWidth thumbnail width
2489 //
2490 // optional
2491 ThumbWidth int `json:"thumb_width,omitempty"`
2492 // ThumbHeight thumbnail height
2493 //
2494 // optional
2495 ThumbHeight int `json:"thumb_height,omitempty"`
2496}
2497
2498// InlineQueryResultAudio is an inline query response audio.
2499type InlineQueryResultAudio struct {
2500 // Type of the result, must be audio
2501 Type string `json:"type"`
2502 // ID unique identifier for this result, 1-64 bytes
2503 ID string `json:"id"`
2504 // URL a valid url for the audio file
2505 URL string `json:"audio_url"`
2506 // Title is a title
2507 Title string `json:"title"`
2508 // Caption 0-1024 characters after entities parsing
2509 //
2510 // optional
2511 Caption string `json:"caption,omitempty"`
2512 // ParseMode mode for parsing entities in the video caption.
2513 // See formatting options for more details
2514 // (https://core.telegram.org/bots/api#formatting-options).
2515 //
2516 // optional
2517 ParseMode string `json:"parse_mode,omitempty"`
2518 // CaptionEntities is a list of special entities that appear in the caption,
2519 // which can be specified instead of parse_mode
2520 //
2521 // optional
2522 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2523 // Performer is a performer
2524 //
2525 // optional
2526 Performer string `json:"performer,omitempty"`
2527 // Duration audio duration in seconds
2528 //
2529 // optional
2530 Duration int `json:"audio_duration,omitempty"`
2531 // ReplyMarkup inline keyboard attached to the message
2532 //
2533 // optional
2534 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2535 // InputMessageContent content of the message to be sent instead of the audio
2536 //
2537 // optional
2538 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2539}
2540
2541// InlineQueryResultContact is an inline query response contact.
2542type InlineQueryResultContact struct {
2543 Type string `json:"type"` // required
2544 ID string `json:"id"` // required
2545 PhoneNumber string `json:"phone_number"` // required
2546 FirstName string `json:"first_name"` // required
2547 LastName string `json:"last_name"`
2548 VCard string `json:"vcard"`
2549 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2550 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2551 ThumbURL string `json:"thumb_url"`
2552 ThumbWidth int `json:"thumb_width"`
2553 ThumbHeight int `json:"thumb_height"`
2554}
2555
2556// InlineQueryResultGame is an inline query response game.
2557type InlineQueryResultGame struct {
2558 // Type of the result, must be game
2559 Type string `json:"type"`
2560 // ID unique identifier for this result, 1-64 bytes
2561 ID string `json:"id"`
2562 // GameShortName short name of the game
2563 GameShortName string `json:"game_short_name"`
2564 // ReplyMarkup inline keyboard attached to the message
2565 //
2566 // optional
2567 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2568}
2569
2570// InlineQueryResultDocument is an inline query response document.
2571type InlineQueryResultDocument struct {
2572 // Type of the result, must be a document
2573 Type string `json:"type"`
2574 // ID unique identifier for this result, 1-64 bytes
2575 ID string `json:"id"`
2576 // Title for the result
2577 Title string `json:"title"`
2578 // Caption of the document to be sent, 0-1024 characters after entities parsing
2579 //
2580 // optional
2581 Caption string `json:"caption,omitempty"`
2582 // URL a valid url for the file
2583 URL string `json:"document_url"`
2584 // MimeType of the content of the file, either “application/pdf” or “application/zip”
2585 MimeType string `json:"mime_type"`
2586 // Description short description of the result
2587 //
2588 // optional
2589 Description string `json:"description,omitempty"`
2590 // ReplyMarkup inline keyboard attached to the message
2591 //
2592 // optional
2593 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2594 // InputMessageContent content of the message to be sent instead of the file
2595 //
2596 // optional
2597 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2598 // ThumbURL url of the thumbnail (jpeg only) for the file
2599 //
2600 // optional
2601 ThumbURL string `json:"thumb_url,omitempty"`
2602 // ThumbWidth thumbnail width
2603 //
2604 // optional
2605 ThumbWidth int `json:"thumb_width,omitempty"`
2606 // ThumbHeight thumbnail height
2607 //
2608 // optional
2609 ThumbHeight int `json:"thumb_height,omitempty"`
2610}
2611
2612// InlineQueryResultGIF is an inline query response GIF.
2613type InlineQueryResultGIF struct {
2614 // Type of the result, must be gif.
2615 Type string `json:"type"`
2616 // ID unique identifier for this result, 1-64 bytes.
2617 ID string `json:"id"`
2618 // URL a valid URL for the GIF file. File size must not exceed 1MB.
2619 URL string `json:"gif_url"`
2620 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
2621 ThumbURL string `json:"thumb_url"`
2622 // Width of the GIF
2623 //
2624 // optional
2625 Width int `json:"gif_width,omitempty"`
2626 // Height of the GIF
2627 //
2628 // optional
2629 Height int `json:"gif_height,omitempty"`
2630 // Duration of the GIF
2631 //
2632 // optional
2633 Duration int `json:"gif_duration,omitempty"`
2634 // Title for the result
2635 //
2636 // optional
2637 Title string `json:"title,omitempty"`
2638 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
2639 //
2640 // optional
2641 Caption string `json:"caption,omitempty"`
2642 // ParseMode mode for parsing entities in the video caption.
2643 // See formatting options for more details
2644 // (https://core.telegram.org/bots/api#formatting-options).
2645 //
2646 // optional
2647 ParseMode string `json:"parse_mode,omitempty"`
2648 // CaptionEntities is a list of special entities that appear in the caption,
2649 // which can be specified instead of parse_mode
2650 //
2651 // optional
2652 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2653 // ReplyMarkup inline keyboard attached to the message
2654 //
2655 // optional
2656 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2657 // InputMessageContent content of the message to be sent instead of the GIF animation.
2658 //
2659 // optional
2660 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2661}
2662
2663// InlineQueryResultLocation is an inline query response location.
2664type InlineQueryResultLocation struct {
2665 // Type of the result, must be location
2666 Type string `json:"type"`
2667 // ID unique identifier for this result, 1-64 Bytes
2668 ID string `json:"id"`
2669 // Latitude of the location in degrees
2670 Latitude float64 `json:"latitude"`
2671 // Longitude of the location in degrees
2672 Longitude float64 `json:"longitude"`
2673 // Title of the location
2674 Title string `json:"title"`
2675 // HorizontalAccuracy is the radius of uncertainty for the location,
2676 // measured in meters; 0-1500
2677 //
2678 // optional
2679 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
2680 // LivePeriod is the period in seconds for which the location can be
2681 // updated, should be between 60 and 86400.
2682 //
2683 // optional
2684 LivePeriod int `json:"live_period,omitempty"`
2685 // Heading is for live locations, a direction in which the user is moving,
2686 // in degrees. Must be between 1 and 360 if specified.
2687 //
2688 // optional
2689 Heading int `json:"heading,omitempty"`
2690 // ProximityAlertRadius is for live locations, a maximum distance for
2691 // proximity alerts about approaching another chat member, in meters. Must
2692 // be between 1 and 100000 if specified.
2693 //
2694 // optional
2695 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
2696 // ReplyMarkup inline keyboard attached to the message
2697 //
2698 // optional
2699 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2700 // InputMessageContent content of the message to be sent instead of the location
2701 //
2702 // optional
2703 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2704 // ThumbURL url of the thumbnail for the result
2705 //
2706 // optional
2707 ThumbURL string `json:"thumb_url,omitempty"`
2708 // ThumbWidth thumbnail width
2709 //
2710 // optional
2711 ThumbWidth int `json:"thumb_width,omitempty"`
2712 // ThumbHeight thumbnail height
2713 //
2714 // optional
2715 ThumbHeight int `json:"thumb_height,omitempty"`
2716}
2717
2718// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
2719type InlineQueryResultMPEG4GIF struct {
2720 // Type of the result, must be mpeg4_gif
2721 Type string `json:"type"`
2722 // ID unique identifier for this result, 1-64 bytes
2723 ID string `json:"id"`
2724 // URL a valid URL for the MP4 file. File size must not exceed 1MB
2725 URL string `json:"mpeg4_url"`
2726 // Width video width
2727 //
2728 // optional
2729 Width int `json:"mpeg4_width,omitempty"`
2730 // Height vVideo height
2731 //
2732 // optional
2733 Height int `json:"mpeg4_height,omitempty"`
2734 // Duration video duration
2735 //
2736 // optional
2737 Duration int `json:"mpeg4_duration,omitempty"`
2738 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
2739 ThumbURL string `json:"thumb_url"`
2740 // Title for the result
2741 //
2742 // optional
2743 Title string `json:"title,omitempty"`
2744 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
2745 //
2746 // optional
2747 Caption string `json:"caption,omitempty"`
2748 // ParseMode mode for parsing entities in the video caption.
2749 // See formatting options for more details
2750 // (https://core.telegram.org/bots/api#formatting-options).
2751 //
2752 // optional
2753 ParseMode string `json:"parse_mode,omitempty"`
2754 // CaptionEntities is a list of special entities that appear in the caption,
2755 // which can be specified instead of parse_mode
2756 //
2757 // optional
2758 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2759 // ReplyMarkup inline keyboard attached to the message
2760 //
2761 // optional
2762 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2763 // InputMessageContent content of the message to be sent instead of the video animation
2764 //
2765 // optional
2766 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2767}
2768
2769// InlineQueryResultPhoto is an inline query response photo.
2770type InlineQueryResultPhoto struct {
2771 // Type of the result, must be article.
2772 Type string `json:"type"`
2773 // ID unique identifier for this result, 1-64 Bytes.
2774 ID string `json:"id"`
2775 // URL a valid URL of the photo. Photo must be in jpeg format.
2776 // Photo size must not exceed 5MB.
2777 URL string `json:"photo_url"`
2778 // MimeType
2779 MimeType string `json:"mime_type"`
2780 // Width of the photo
2781 //
2782 // optional
2783 Width int `json:"photo_width,omitempty"`
2784 // Height of the photo
2785 //
2786 // optional
2787 Height int `json:"photo_height,omitempty"`
2788 // ThumbURL url of the thumbnail for the photo.
2789 //
2790 // optional
2791 ThumbURL string `json:"thumb_url,omitempty"`
2792 // Title for the result
2793 //
2794 // optional
2795 Title string `json:"title,omitempty"`
2796 // Description short description of the result
2797 //
2798 // optional
2799 Description string `json:"description,omitempty"`
2800 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
2801 //
2802 // optional
2803 Caption string `json:"caption,omitempty"`
2804 // ParseMode mode for parsing entities in the photo caption.
2805 // See formatting options for more details
2806 // (https://core.telegram.org/bots/api#formatting-options).
2807 //
2808 // optional
2809 ParseMode string `json:"parse_mode,omitempty"`
2810 // ReplyMarkup inline keyboard attached to the message.
2811 //
2812 // optional
2813 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2814 // CaptionEntities is a list of special entities that appear in the caption,
2815 // which can be specified instead of parse_mode
2816 //
2817 // optional
2818 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2819 // InputMessageContent content of the message to be sent instead of the photo.
2820 //
2821 // optional
2822 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2823}
2824
2825// InlineQueryResultVenue is an inline query response venue.
2826type InlineQueryResultVenue struct {
2827 // Type of the result, must be venue
2828 Type string `json:"type"`
2829 // ID unique identifier for this result, 1-64 Bytes
2830 ID string `json:"id"`
2831 // Latitude of the venue location in degrees
2832 Latitude float64 `json:"latitude"`
2833 // Longitude of the venue location in degrees
2834 Longitude float64 `json:"longitude"`
2835 // Title of the venue
2836 Title string `json:"title"`
2837 // Address of the venue
2838 Address string `json:"address"`
2839 // FoursquareID foursquare identifier of the venue if known
2840 //
2841 // optional
2842 FoursquareID string `json:"foursquare_id,omitempty"`
2843 // FoursquareType foursquare type of the venue, if known.
2844 // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
2845 //
2846 // optional
2847 FoursquareType string `json:"foursquare_type,omitempty"`
2848 // GooglePlaceID is the Google Places identifier of the venue
2849 //
2850 // optional
2851 GooglePlaceID string `json:"google_place_id,omitempty"`
2852 // GooglePlaceType is the Google Places type of the venue
2853 //
2854 // optional
2855 GooglePlaceType string `json:"google_place_type,omitempty"`
2856 // ReplyMarkup inline keyboard attached to the message
2857 //
2858 // optional
2859 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2860 // InputMessageContent content of the message to be sent instead of the venue
2861 //
2862 // optional
2863 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2864 // ThumbURL url of the thumbnail for the result
2865 //
2866 // optional
2867 ThumbURL string `json:"thumb_url,omitempty"`
2868 // ThumbWidth thumbnail width
2869 //
2870 // optional
2871 ThumbWidth int `json:"thumb_width,omitempty"`
2872 // ThumbHeight thumbnail height
2873 //
2874 // optional
2875 ThumbHeight int `json:"thumb_height,omitempty"`
2876}
2877
2878// InlineQueryResultVideo is an inline query response video.
2879type InlineQueryResultVideo struct {
2880 // Type of the result, must be video
2881 Type string `json:"type"`
2882 // ID unique identifier for this result, 1-64 bytes
2883 ID string `json:"id"`
2884 // URL a valid url for the embedded video player or video file
2885 URL string `json:"video_url"`
2886 // MimeType of the content of video url, “text/html” or “video/mp4”
2887 MimeType string `json:"mime_type"`
2888 //
2889 // ThumbURL url of the thumbnail (jpeg only) for the video
2890 // optional
2891 ThumbURL string `json:"thumb_url,omitempty"`
2892 // Title for the result
2893 Title string `json:"title"`
2894 // Caption of the video to be sent, 0-1024 characters after entities parsing
2895 //
2896 // optional
2897 Caption string `json:"caption,omitempty"`
2898 // Width video width
2899 //
2900 // optional
2901 Width int `json:"video_width,omitempty"`
2902 // Height video height
2903 //
2904 // optional
2905 Height int `json:"video_height,omitempty"`
2906 // Duration video duration in seconds
2907 //
2908 // optional
2909 Duration int `json:"video_duration,omitempty"`
2910 // Description short description of the result
2911 //
2912 // optional
2913 Description string `json:"description,omitempty"`
2914 // ReplyMarkup inline keyboard attached to the message
2915 //
2916 // optional
2917 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2918 // InputMessageContent content of the message to be sent instead of the video.
2919 // This field is required if InlineQueryResultVideo is used to send
2920 // an HTML-page as a result (e.g., a YouTube video).
2921 //
2922 // optional
2923 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2924}
2925
2926// InlineQueryResultVoice is an inline query response voice.
2927type InlineQueryResultVoice struct {
2928 // Type of the result, must be voice
2929 Type string `json:"type"`
2930 // ID unique identifier for this result, 1-64 bytes
2931 ID string `json:"id"`
2932 // URL a valid URL for the voice recording
2933 URL string `json:"voice_url"`
2934 // Title recording title
2935 Title string `json:"title"`
2936 // Caption 0-1024 characters after entities parsing
2937 //
2938 // optional
2939 Caption string `json:"caption,omitempty"`
2940 // ParseMode mode for parsing entities in the video caption.
2941 // See formatting options for more details
2942 // (https://core.telegram.org/bots/api#formatting-options).
2943 //
2944 // optional
2945 ParseMode string `json:"parse_mode,omitempty"`
2946 // CaptionEntities is a list of special entities that appear in the caption,
2947 // which can be specified instead of parse_mode
2948 //
2949 // optional
2950 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2951 // Duration recording duration in seconds
2952 //
2953 // optional
2954 Duration int `json:"voice_duration,omitempty"`
2955 // ReplyMarkup inline keyboard attached to the message
2956 //
2957 // optional
2958 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2959 // InputMessageContent content of the message to be sent instead of the voice recording
2960 //
2961 // optional
2962 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2963}
2964
2965// ChosenInlineResult is an inline query result chosen by a User
2966type ChosenInlineResult struct {
2967 // ResultID the unique identifier for the result that was chosen
2968 ResultID string `json:"result_id"`
2969 // From the user that chose the result
2970 From *User `json:"from"`
2971 // Location sender location, only for bots that require user location
2972 //
2973 // optional
2974 Location *Location `json:"location,omitempty"`
2975 // InlineMessageID identifier of the sent inline message.
2976 // Available only if there is an inline keyboard attached to the message.
2977 // Will be also received in callback queries and can be used to edit the message.
2978 //
2979 // optional
2980 InlineMessageID string `json:"inline_message_id,omitempty"`
2981 // Query the query that was used to obtain the result
2982 Query string `json:"query"`
2983}
2984
2985// SentWebAppMessage contains information about an inline message sent by a Web App
2986// on behalf of a user.
2987type SentWebAppMessage struct {
2988 // Identifier of the sent inline message. Available only if there is an inline
2989 // keyboard attached to the message.
2990 //
2991 // optional
2992 InlineMessageID string `json:"inline_message_id,omitempty"`
2993}
2994
2995// InputTextMessageContent contains text for displaying
2996// as an inline query result.
2997type InputTextMessageContent struct {
2998 // Text of the message to be sent, 1-4096 characters
2999 Text string `json:"message_text"`
3000 // ParseMode mode for parsing entities in the message text.
3001 // See formatting options for more details
3002 // (https://core.telegram.org/bots/api#formatting-options).
3003 //
3004 // optional
3005 ParseMode string `json:"parse_mode,omitempty"`
3006 // Entities is a list of special entities that appear in message text, which
3007 // can be specified instead of parse_mode
3008 //
3009 // optional
3010 Entities []MessageEntity `json:"entities,omitempty"`
3011 // DisableWebPagePreview disables link previews for links in the sent message
3012 //
3013 // optional
3014 DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
3015}
3016
3017// InputLocationMessageContent contains a location for displaying
3018// as an inline query result.
3019type InputLocationMessageContent struct {
3020 // Latitude of the location in degrees
3021 Latitude float64 `json:"latitude"`
3022 // Longitude of the location in degrees
3023 Longitude float64 `json:"longitude"`
3024 // HorizontalAccuracy is the radius of uncertainty for the location,
3025 // measured in meters; 0-1500
3026 //
3027 // optional
3028 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
3029 // LivePeriod is the period in seconds for which the location can be
3030 // updated, should be between 60 and 86400
3031 //
3032 // optional
3033 LivePeriod int `json:"live_period,omitempty"`
3034 // Heading is for live locations, a direction in which the user is moving,
3035 // in degrees. Must be between 1 and 360 if specified.
3036 //
3037 // optional
3038 Heading int `json:"heading,omitempty"`
3039 // ProximityAlertRadius is for live locations, a maximum distance for
3040 // proximity alerts about approaching another chat member, in meters. Must
3041 // be between 1 and 100000 if specified.
3042 //
3043 // optional
3044 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
3045}
3046
3047// InputVenueMessageContent contains a venue for displaying
3048// as an inline query result.
3049type InputVenueMessageContent struct {
3050 // Latitude of the venue in degrees
3051 Latitude float64 `json:"latitude"`
3052 // Longitude of the venue in degrees
3053 Longitude float64 `json:"longitude"`
3054 // Title name of the venue
3055 Title string `json:"title"`
3056 // Address of the venue
3057 Address string `json:"address"`
3058 // FoursquareID foursquare identifier of the venue, if known
3059 //
3060 // optional
3061 FoursquareID string `json:"foursquare_id,omitempty"`
3062 // FoursquareType Foursquare type of the venue, if known
3063 //
3064 // optional
3065 FoursquareType string `json:"foursquare_type,omitempty"`
3066 // GooglePlaceID is the Google Places identifier of the venue
3067 //
3068 // optional
3069 GooglePlaceID string `json:"google_place_id,omitempty"`
3070 // GooglePlaceType is the Google Places type of the venue
3071 //
3072 // optional
3073 GooglePlaceType string `json:"google_place_type,omitempty"`
3074}
3075
3076// InputContactMessageContent contains a contact for displaying
3077// as an inline query result.
3078type InputContactMessageContent struct {
3079 // PhoneNumber contact's phone number
3080 PhoneNumber string `json:"phone_number"`
3081 // FirstName contact's first name
3082 FirstName string `json:"first_name"`
3083 // LastName contact's last name
3084 //
3085 // optional
3086 LastName string `json:"last_name,omitempty"`
3087 // Additional data about the contact in the form of a vCard
3088 //
3089 // optional
3090 VCard string `json:"vcard,omitempty"`
3091}
3092
3093// InputInvoiceMessageContent represents the content of an invoice message to be
3094// sent as the result of an inline query.
3095type InputInvoiceMessageContent struct {
3096 // Product name, 1-32 characters
3097 Title string `json:"title"`
3098 // Product description, 1-255 characters
3099 Description string `json:"description"`
3100 // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
3101 // the user, use for your internal processes.
3102 Payload string `json:"payload"`
3103 // Payment provider token, obtained via Botfather
3104 ProviderToken string `json:"provider_token"`
3105 // Three-letter ISO 4217 currency code
3106 Currency string `json:"currency"`
3107 // Price breakdown, a JSON-serialized list of components (e.g. product
3108 // price, tax, discount, delivery cost, delivery tax, bonus, etc.)
3109 Prices []LabeledPrice `json:"prices"`
3110 // The maximum accepted amount for tips in the smallest units of the
3111 // currency (integer, not float/double).
3112 //
3113 // optional
3114 MaxTipAmount int `json:"max_tip_amount,omitempty"`
3115 // An array of suggested amounts of tip in the smallest units of the
3116 // currency (integer, not float/double). At most 4 suggested tip amounts can
3117 // be specified. The suggested tip amounts must be positive, passed in a
3118 // strictly increased order and must not exceed max_tip_amount.
3119 //
3120 // optional
3121 SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
3122 // A JSON-serialized object for data about the invoice, which will be shared
3123 // with the payment provider. A detailed description of the required fields
3124 // should be provided by the payment provider.
3125 //
3126 // optional
3127 ProviderData string `json:"provider_data,omitempty"`
3128 // URL of the product photo for the invoice. Can be a photo of the goods or
3129 // a marketing image for a service. People like it better when they see what
3130 // they are paying for.
3131 //
3132 // optional
3133 PhotoURL string `json:"photo_url,omitempty"`
3134 // Photo size
3135 //
3136 // optional
3137 PhotoSize int `json:"photo_size,omitempty"`
3138 // Photo width
3139 //
3140 // optional
3141 PhotoWidth int `json:"photo_width,omitempty"`
3142 // Photo height
3143 //
3144 // optional
3145 PhotoHeight int `json:"photo_height,omitempty"`
3146 // Pass True, if you require the user's full name to complete the order
3147 //
3148 // optional
3149 NeedName bool `json:"need_name,omitempty"`
3150 // Pass True, if you require the user's phone number to complete the order
3151 //
3152 // optional
3153 NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
3154 // Pass True, if you require the user's email address to complete the order
3155 //
3156 // optional
3157 NeedEmail bool `json:"need_email,omitempty"`
3158 // Pass True, if you require the user's shipping address to complete the order
3159 //
3160 // optional
3161 NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
3162 // Pass True, if user's phone number should be sent to provider
3163 //
3164 // optional
3165 SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
3166 // Pass True, if user's email address should be sent to provider
3167 //
3168 // optional
3169 SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
3170 // Pass True, if the final price depends on the shipping method
3171 //
3172 // optional
3173 IsFlexible bool `json:"is_flexible,omitempty"`
3174}
3175
3176// LabeledPrice represents a portion of the price for goods or services.
3177type LabeledPrice struct {
3178 // Label portion label
3179 Label string `json:"label"`
3180 // Amount price of the product in the smallest units of the currency (integer, not float/double).
3181 // For example, for a price of US$ 1.45 pass amount = 145.
3182 // See the exp parameter in currencies.json
3183 // (https://core.telegram.org/bots/payments/currencies.json),
3184 // it shows the number of digits past the decimal point
3185 // for each currency (2 for the majority of currencies).
3186 Amount int `json:"amount"`
3187}
3188
3189// Invoice contains basic information about an invoice.
3190type Invoice struct {
3191 // Title product name
3192 Title string `json:"title"`
3193 // Description product description
3194 Description string `json:"description"`
3195 // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
3196 StartParameter string `json:"start_parameter"`
3197 // Currency three-letter ISO 4217 currency code
3198 // (see https://core.telegram.org/bots/payments#supported-currencies)
3199 Currency string `json:"currency"`
3200 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
3201 // For example, for a price of US$ 1.45 pass amount = 145.
3202 // See the exp parameter in currencies.json
3203 // (https://core.telegram.org/bots/payments/currencies.json),
3204 // it shows the number of digits past the decimal point
3205 // for each currency (2 for the majority of currencies).
3206 TotalAmount int `json:"total_amount"`
3207}
3208
3209// ShippingAddress represents a shipping address.
3210type ShippingAddress struct {
3211 // CountryCode ISO 3166-1 alpha-2 country code
3212 CountryCode string `json:"country_code"`
3213 // State if applicable
3214 State string `json:"state"`
3215 // City city
3216 City string `json:"city"`
3217 // StreetLine1 first line for the address
3218 StreetLine1 string `json:"street_line1"`
3219 // StreetLine2 second line for the address
3220 StreetLine2 string `json:"street_line2"`
3221 // PostCode address post code
3222 PostCode string `json:"post_code"`
3223}
3224
3225// OrderInfo represents information about an order.
3226type OrderInfo struct {
3227 // Name user name
3228 //
3229 // optional
3230 Name string `json:"name,omitempty"`
3231 // PhoneNumber user's phone number
3232 //
3233 // optional
3234 PhoneNumber string `json:"phone_number,omitempty"`
3235 // Email user email
3236 //
3237 // optional
3238 Email string `json:"email,omitempty"`
3239 // ShippingAddress user shipping address
3240 //
3241 // optional
3242 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
3243}
3244
3245// ShippingOption represents one shipping option.
3246type ShippingOption struct {
3247 // ID shipping option identifier
3248 ID string `json:"id"`
3249 // Title option title
3250 Title string `json:"title"`
3251 // Prices list of price portions
3252 Prices []LabeledPrice `json:"prices"`
3253}
3254
3255// SuccessfulPayment contains basic information about a successful payment.
3256type SuccessfulPayment struct {
3257 // Currency three-letter ISO 4217 currency code
3258 // (see https://core.telegram.org/bots/payments#supported-currencies)
3259 Currency string `json:"currency"`
3260 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
3261 // For example, for a price of US$ 1.45 pass amount = 145.
3262 // See the exp parameter in currencies.json,
3263 // (https://core.telegram.org/bots/payments/currencies.json)
3264 // it shows the number of digits past the decimal point
3265 // for each currency (2 for the majority of currencies).
3266 TotalAmount int `json:"total_amount"`
3267 // InvoicePayload bot specified invoice payload
3268 InvoicePayload string `json:"invoice_payload"`
3269 // ShippingOptionID identifier of the shipping option chosen by the user
3270 //
3271 // optional
3272 ShippingOptionID string `json:"shipping_option_id,omitempty"`
3273 // OrderInfo order info provided by the user
3274 //
3275 // optional
3276 OrderInfo *OrderInfo `json:"order_info,omitempty"`
3277 // TelegramPaymentChargeID telegram payment identifier
3278 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
3279 // ProviderPaymentChargeID provider payment identifier
3280 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
3281}
3282
3283// ShippingQuery contains information about an incoming shipping query.
3284type ShippingQuery struct {
3285 // ID unique query identifier
3286 ID string `json:"id"`
3287 // From user who sent the query
3288 From *User `json:"from"`
3289 // InvoicePayload bot specified invoice payload
3290 InvoicePayload string `json:"invoice_payload"`
3291 // ShippingAddress user specified shipping address
3292 ShippingAddress *ShippingAddress `json:"shipping_address"`
3293}
3294
3295// PreCheckoutQuery contains information about an incoming pre-checkout query.
3296type PreCheckoutQuery struct {
3297 // ID unique query identifier
3298 ID string `json:"id"`
3299 // From user who sent the query
3300 From *User `json:"from"`
3301 // Currency three-letter ISO 4217 currency code
3302 // // (see https://core.telegram.org/bots/payments#supported-currencies)
3303 Currency string `json:"currency"`
3304 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
3305 // // For example, for a price of US$ 1.45 pass amount = 145.
3306 // // See the exp parameter in currencies.json,
3307 // // (https://core.telegram.org/bots/payments/currencies.json)
3308 // // it shows the number of digits past the decimal point
3309 // // for each currency (2 for the majority of currencies).
3310 TotalAmount int `json:"total_amount"`
3311 // InvoicePayload bot specified invoice payload
3312 InvoicePayload string `json:"invoice_payload"`
3313 // ShippingOptionID identifier of the shipping option chosen by the user
3314 //
3315 // optional
3316 ShippingOptionID string `json:"shipping_option_id,omitempty"`
3317 // OrderInfo order info provided by the user
3318 //
3319 // optional
3320 OrderInfo *OrderInfo `json:"order_info,omitempty"`
3321}