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 // MessageReaction is a reaction to a message was changed by a user.
65 //
66 // optional
67 MessageReaction *MessageReactionUpdated `json:"message_reaction,omitempty"`
68 // MessageReactionCount reactions to a message with anonymous reactions were changed.
69 //
70 // optional
71 MessageReactionCount *MessageReactionCountUpdated `json:"message_reaction_count,omitempty"`
72 // InlineQuery new incoming inline query
73 //
74 // optional
75 InlineQuery *InlineQuery `json:"inline_query,omitempty"`
76 // ChosenInlineResult is the result of an inline query
77 // that was chosen by a user and sent to their chat partner.
78 // Please see our documentation on the feedback collecting
79 // for details on how to enable these updates for your bot.
80 //
81 // optional
82 ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
83 // CallbackQuery new incoming callback query
84 //
85 // optional
86 CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
87 // ShippingQuery new incoming shipping query. Only for invoices with
88 // flexible price
89 //
90 // optional
91 ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
92 // PreCheckoutQuery new incoming pre-checkout query. Contains full
93 // information about checkout
94 //
95 // optional
96 PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
97 // Pool new poll state. Bots receive only updates about stopped polls and
98 // polls, which are sent by the bot
99 //
100 // optional
101 Poll *Poll `json:"poll,omitempty"`
102 // PollAnswer user changed their answer in a non-anonymous poll. Bots
103 // receive new votes only in polls that were sent by the bot itself.
104 //
105 // optional
106 PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
107 // MyChatMember is the bot's chat member status was updated in a chat. For
108 // private chats, this update is received only when the bot is blocked or
109 // unblocked by the user.
110 //
111 // optional
112 MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
113 // ChatMember is a chat member's status was updated in a chat. The bot must
114 // be an administrator in the chat and must explicitly specify "chat_member"
115 // in the list of allowed_updates to receive these updates.
116 //
117 // optional
118 ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
119 // ChatJoinRequest is a request to join the chat has been sent. The bot must
120 // have the can_invite_users administrator right in the chat to receive
121 // these updates.
122 //
123 // optional
124 ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`
125}
126
127// SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
128// about the user in the update object.
129func (u *Update) SentFrom() *User {
130 switch {
131 case u.Message != nil:
132 return u.Message.From
133 case u.EditedMessage != nil:
134 return u.EditedMessage.From
135 case u.InlineQuery != nil:
136 return u.InlineQuery.From
137 case u.ChosenInlineResult != nil:
138 return u.ChosenInlineResult.From
139 case u.CallbackQuery != nil:
140 return u.CallbackQuery.From
141 case u.ShippingQuery != nil:
142 return u.ShippingQuery.From
143 case u.PreCheckoutQuery != nil:
144 return u.PreCheckoutQuery.From
145 default:
146 return nil
147 }
148}
149
150// CallbackData returns the callback query data, if it exists.
151func (u *Update) CallbackData() string {
152 if u.CallbackQuery != nil {
153 return u.CallbackQuery.Data
154 }
155 return ""
156}
157
158// FromChat returns the chat where an update occurred.
159func (u *Update) FromChat() *Chat {
160 switch {
161 case u.Message != nil:
162 return u.Message.Chat
163 case u.EditedMessage != nil:
164 return u.EditedMessage.Chat
165 case u.ChannelPost != nil:
166 return u.ChannelPost.Chat
167 case u.EditedChannelPost != nil:
168 return u.EditedChannelPost.Chat
169 case u.CallbackQuery != nil && u.CallbackQuery.Message != nil:
170 return u.CallbackQuery.Message.Chat
171 default:
172 return nil
173 }
174}
175
176// UpdatesChannel is the channel for getting updates.
177type UpdatesChannel <-chan Update
178
179// Clear discards all unprocessed incoming updates.
180func (ch UpdatesChannel) Clear() {
181 for len(ch) != 0 {
182 <-ch
183 }
184}
185
186// User represents a Telegram user or bot.
187type User struct {
188 // ID is a unique identifier for this user or bot
189 ID int64 `json:"id"`
190 // IsBot true, if this user is a bot
191 //
192 // optional
193 IsBot bool `json:"is_bot,omitempty"`
194 // IsPremium true, if user has Telegram Premium
195 //
196 // optional
197 IsPremium bool `json:"is_premium,omitempty"`
198 // AddedToAttachmentMenu true, if this user added the bot to the attachment menu
199 //
200 // optional
201 AddedToAttachmentMenu bool `json:"added_to_attachment_menu,omitempty"`
202 // FirstName user's or bot's first name
203 FirstName string `json:"first_name"`
204 // LastName user's or bot's last name
205 //
206 // optional
207 LastName string `json:"last_name,omitempty"`
208 // UserName user's or bot's username
209 //
210 // optional
211 UserName string `json:"username,omitempty"`
212 // LanguageCode IETF language tag of the user's language
213 // more info: https://en.wikipedia.org/wiki/IETF_language_tag
214 //
215 // optional
216 LanguageCode string `json:"language_code,omitempty"`
217 // CanJoinGroups is true, if the bot can be invited to groups.
218 // Returned only in getMe.
219 //
220 // optional
221 CanJoinGroups bool `json:"can_join_groups,omitempty"`
222 // CanReadAllGroupMessages is true, if privacy mode is disabled for the bot.
223 // Returned only in getMe.
224 //
225 // optional
226 CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
227 // SupportsInlineQueries is true, if the bot supports inline queries.
228 // Returned only in getMe.
229 //
230 // optional
231 SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
232}
233
234// String displays a simple text version of a user.
235//
236// It is normally a user's username, but falls back to a first/last
237// name as available.
238func (u *User) String() string {
239 if u == nil {
240 return ""
241 }
242 if u.UserName != "" {
243 return u.UserName
244 }
245
246 name := u.FirstName
247 if u.LastName != "" {
248 name += " " + u.LastName
249 }
250
251 return name
252}
253
254// Chat represents a chat.
255type Chat struct {
256 // ID is a unique identifier for this chat
257 ID int64 `json:"id"`
258 // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
259 Type string `json:"type"`
260 // Title for supergroups, channels and group chats
261 //
262 // optional
263 Title string `json:"title,omitempty"`
264 // UserName for private chats, supergroups and channels if available
265 //
266 // optional
267 UserName string `json:"username,omitempty"`
268 // FirstName of the other party in a private chat
269 //
270 // optional
271 FirstName string `json:"first_name,omitempty"`
272 // LastName of the other party in a private chat
273 //
274 // optional
275 LastName string `json:"last_name,omitempty"`
276 // IsForum is true if the supergroup chat is a forum (has topics enabled)
277 //
278 // optional
279 IsForum bool `json:"is_forum,omitempty"`
280 // Photo is a chat photo
281 Photo *ChatPhoto `json:"photo"`
282 // If non-empty, the list of all active chat usernames;
283 // for private chats, supergroups and channels. Returned only in getChat.
284 //
285 // optional
286 ActiveUsernames []string `json:"active_usernames,omitempty"`
287 // AvailableReactions is a list of available reactions allowed in the chat.
288 // If omitted, then all emoji reactions are allowed. Returned only in getChat.
289 //
290 // optional
291 AvailableReactions []ReactionType `json:"available_reactions,omitempty"`
292 // Custom emoji identifier of emoji status of the other party
293 // in a private chat. Returned only in getChat.
294 //
295 // optional
296 EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
297 // Expiration date of the emoji status of the chat or the other party
298 // in a private chat, in Unix time, if any. Returned only in getChat.
299 //
300 // optional
301 EmojiStatusCustomEmojiDate int64 `json:"emoji_status_expiration_date,omitempty"`
302 // Bio is the bio of the other party in a private chat. Returned only in
303 // getChat
304 //
305 // optional
306 Bio string `json:"bio,omitempty"`
307 // HasPrivateForwards is true if privacy settings of the other party in the
308 // private chat allows to use tg://user?id=<user_id> links only in chats
309 // with the user. Returned only in getChat.
310 //
311 // optional
312 HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
313 // HasRestrictedVoiceAndVideoMessages if the privacy settings of the other party
314 // restrict sending voice and video note messages
315 // in the private chat. Returned only in getChat.
316 //
317 // optional
318 HasRestrictedVoiceAndVideoMessages bool `json:"has_restricted_voice_and_video_messages,omitempty"`
319 // JoinToSendMessages is true, if users need to join the supergroup
320 // before they can send messages.
321 // Returned only in getChat
322 //
323 // optional
324 JoinToSendMessages bool `json:"join_to_send_messages,omitempty"`
325 // JoinByRequest is true, if all users directly joining the supergroup
326 // need to be approved by supergroup administrators.
327 // Returned only in getChat.
328 //
329 // optional
330 JoinByRequest bool `json:"join_by_request,omitempty"`
331 // Description for groups, supergroups and channel chats
332 //
333 // optional
334 Description string `json:"description,omitempty"`
335 // InviteLink is a chat invite link, for groups, supergroups and channel chats.
336 // Each administrator in a chat generates their own invite links,
337 // so the bot must first generate the link using exportChatInviteLink
338 //
339 // optional
340 InviteLink string `json:"invite_link,omitempty"`
341 // PinnedMessage is the pinned message, for groups, supergroups and channels
342 //
343 // optional
344 PinnedMessage *Message `json:"pinned_message,omitempty"`
345 // Permissions are default chat member permissions, for groups and
346 // supergroups. Returned only in getChat.
347 //
348 // optional
349 Permissions *ChatPermissions `json:"permissions,omitempty"`
350 // SlowModeDelay is for supergroups, the minimum allowed delay between
351 // consecutive messages sent by each unprivileged user. Returned only in
352 // getChat.
353 //
354 // optional
355 SlowModeDelay int `json:"slow_mode_delay,omitempty"`
356 // MessageAutoDeleteTime is the time after which all messages sent to the
357 // chat will be automatically deleted; in seconds. Returned only in getChat.
358 //
359 // optional
360 MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
361 // HasAggressiveAntiSpamEnabled is true if aggressive anti-spam checks are enabled
362 // in the supergroup. The field is only available to chat administrators.
363 // Returned only in getChat.
364 //
365 // optional
366 HasAggressiveAntiSpamEnabled bool `json:"has_aggressive_anti_spam_enabled,omitempty"`
367 // HasHiddenMembers is true if non-administrators can only get
368 // the list of bots and administrators in the chat.
369 //
370 // optional
371 HasHiddenMembers bool `json:"has_hidden_members,omitempty"`
372 // HasProtectedContent is true if messages from the chat can't be forwarded
373 // to other chats. Returned only in getChat.
374 //
375 // optional
376 HasProtectedContent bool `json:"has_protected_content,omitempty"`
377 // StickerSetName is for supergroups, name of group sticker set.Returned
378 // only in getChat.
379 //
380 // optional
381 StickerSetName string `json:"sticker_set_name,omitempty"`
382 // CanSetStickerSet is true, if the bot can change the group sticker set.
383 // Returned only in getChat.
384 //
385 // optional
386 CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
387 // LinkedChatID is a unique identifier for the linked chat, i.e. the
388 // discussion group identifier for a channel and vice versa; for supergroups
389 // and channel chats.
390 //
391 // optional
392 LinkedChatID int64 `json:"linked_chat_id,omitempty"`
393 // Location is for supergroups, the location to which the supergroup is
394 // connected. Returned only in getChat.
395 //
396 // optional
397 Location *ChatLocation `json:"location,omitempty"`
398}
399
400// IsPrivate returns if the Chat is a private conversation.
401func (c Chat) IsPrivate() bool {
402 return c.Type == "private"
403}
404
405// IsGroup returns if the Chat is a group.
406func (c Chat) IsGroup() bool {
407 return c.Type == "group"
408}
409
410// IsSuperGroup returns if the Chat is a supergroup.
411func (c Chat) IsSuperGroup() bool {
412 return c.Type == "supergroup"
413}
414
415// IsChannel returns if the Chat is a channel.
416func (c Chat) IsChannel() bool {
417 return c.Type == "channel"
418}
419
420// ChatConfig returns a ChatConfig struct for chat related methods.
421func (c Chat) ChatConfig() ChatConfig {
422 return ChatConfig{ChatID: c.ID}
423}
424
425// Message represents a message.
426type Message struct {
427 // MessageID is a unique message identifier inside this chat
428 MessageID int `json:"message_id"`
429 // Unique identifier of a message thread to which the message belongs;
430 // for supergroups only
431 //
432 // optional
433 MessageThreadID int `json:"message_thread_id,omitempty"`
434 // From is a sender, empty for messages sent to channels;
435 //
436 // optional
437 From *User `json:"from,omitempty"`
438 // SenderChat is the sender of the message, sent on behalf of a chat. The
439 // channel itself for channel messages. The supergroup itself for messages
440 // from anonymous group administrators. The linked channel for messages
441 // automatically forwarded to the discussion group
442 //
443 // optional
444 SenderChat *Chat `json:"sender_chat,omitempty"`
445 // Date of the message was sent in Unix time
446 Date int `json:"date"`
447 // Chat is the conversation the message belongs to
448 Chat *Chat `json:"chat"`
449 // ForwardFrom for forwarded messages, sender of the original message;
450 //
451 // optional
452 ForwardFrom *User `json:"forward_from,omitempty"`
453 // ForwardFromChat for messages forwarded from channels,
454 // information about the original channel;
455 //
456 // optional
457 ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
458 // ForwardFromMessageID for messages forwarded from channels,
459 // identifier of the original message in the channel;
460 //
461 // optional
462 ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
463 // ForwardSignature for messages forwarded from channels, signature of the
464 // post author if present
465 //
466 // optional
467 ForwardSignature string `json:"forward_signature,omitempty"`
468 // ForwardSenderName is the sender's name for messages forwarded from users
469 // who disallow adding a link to their account in forwarded messages
470 //
471 // optional
472 ForwardSenderName string `json:"forward_sender_name,omitempty"`
473 // ForwardDate for forwarded messages, date the original message was sent in Unix time;
474 //
475 // optional
476 ForwardDate int `json:"forward_date,omitempty"`
477 // IsTopicMessage true if the message is sent to a forum topic
478 //
479 // optional
480 IsTopicMessage bool `json:"is_topic_message,omitempty"`
481 // IsAutomaticForward is true if the message is a channel post that was
482 // automatically forwarded to the connected discussion group.
483 //
484 // optional
485 IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
486 // ReplyToMessage for replies, the original message.
487 // Note that the Message object in this field will not contain further ReplyToMessage fields
488 // even if it itself is a reply;
489 //
490 // optional
491 ReplyToMessage *Message `json:"reply_to_message,omitempty"`
492 // ExternalReply is an information about the message that is being replied to,
493 // which may come from another chat or forum topic.
494 //
495 // optional
496 ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"`
497 // Quote for replies that quote part of the original message, the quoted part of the message
498 //
499 // optional
500 Quote *TextQuote `json:"text_quote,omitempty"`
501 // ViaBot through which the message was sent;
502 //
503 // optional
504 ViaBot *User `json:"via_bot,omitempty"`
505 // EditDate of the message was last edited in Unix time;
506 //
507 // optional
508 EditDate int `json:"edit_date,omitempty"`
509 // HasProtectedContent is true if the message can't be forwarded.
510 //
511 // optional
512 HasProtectedContent bool `json:"has_protected_content,omitempty"`
513 // MediaGroupID is the unique identifier of a media message group this message belongs to;
514 //
515 // optional
516 MediaGroupID string `json:"media_group_id,omitempty"`
517 // AuthorSignature is the signature of the post author for messages in channels;
518 //
519 // optional
520 AuthorSignature string `json:"author_signature,omitempty"`
521 // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
522 //
523 // optional
524 Text string `json:"text,omitempty"`
525 // Entities are for text messages, special entities like usernames,
526 // URLs, bot commands, etc. that appear in the text;
527 //
528 // optional
529 Entities []MessageEntity `json:"entities,omitempty"`
530 // LinkPreviewOptions are options used for link preview generation for the message,
531 // if it is a text message and link preview options were changed
532 //
533 // Optional
534 LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
535 // Animation message is an animation, information about the animation.
536 // For backward compatibility, when this field is set, the document field will also be set;
537 //
538 // optional
539 Animation *Animation `json:"animation,omitempty"`
540 // PremiumAnimation message is an animation, information about the animation.
541 // For backward compatibility, when this field is set, the document field will also be set;
542 //
543 // optional
544 PremiumAnimation *Animation `json:"premium_animation,omitempty"`
545 // Audio message is an audio file, information about the file;
546 //
547 // optional
548 Audio *Audio `json:"audio,omitempty"`
549 // Document message is a general file, information about the file;
550 //
551 // optional
552 Document *Document `json:"document,omitempty"`
553 // Photo message is a photo, available sizes of the photo;
554 //
555 // optional
556 Photo []PhotoSize `json:"photo,omitempty"`
557 // Sticker message is a sticker, information about the sticker;
558 //
559 // optional
560 Sticker *Sticker `json:"sticker,omitempty"`
561 // Story message is a forwarded story;
562 //
563 // optional
564 Story *Story `json:"story,omitempty"`
565 // Video message is a video, information about the video;
566 //
567 // optional
568 Video *Video `json:"video,omitempty"`
569 // VideoNote message is a video note, information about the video message;
570 //
571 // optional
572 VideoNote *VideoNote `json:"video_note,omitempty"`
573 // Voice message is a voice message, information about the file;
574 //
575 // optional
576 Voice *Voice `json:"voice,omitempty"`
577 // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
578 //
579 // optional
580 Caption string `json:"caption,omitempty"`
581 // CaptionEntities;
582 //
583 // optional
584 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
585 // HasSpoiler True, if the message media is covered by a spoiler animation
586 //
587 // optional
588 HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"`
589 // Contact message is a shared contact, information about the contact;
590 //
591 // optional
592 Contact *Contact `json:"contact,omitempty"`
593 // Dice is a dice with random value;
594 //
595 // optional
596 Dice *Dice `json:"dice,omitempty"`
597 // Game message is a game, information about the game;
598 //
599 // optional
600 Game *Game `json:"game,omitempty"`
601 // Poll is a native poll, information about the poll;
602 //
603 // optional
604 Poll *Poll `json:"poll,omitempty"`
605 // Venue message is a venue, information about the venue.
606 // For backward compatibility, when this field is set, the location field
607 // will also be set;
608 //
609 // optional
610 Venue *Venue `json:"venue,omitempty"`
611 // Location message is a shared location, information about the location;
612 //
613 // optional
614 Location *Location `json:"location,omitempty"`
615 // NewChatMembers that were added to the group or supergroup
616 // and information about them (the bot itself may be one of these members);
617 //
618 // optional
619 NewChatMembers []User `json:"new_chat_members,omitempty"`
620 // LeftChatMember is a member was removed from the group,
621 // information about them (this member may be the bot itself);
622 //
623 // optional
624 LeftChatMember *User `json:"left_chat_member,omitempty"`
625 // NewChatTitle is a chat title was changed to this value;
626 //
627 // optional
628 NewChatTitle string `json:"new_chat_title,omitempty"`
629 // NewChatPhoto is a chat photo was change to this value;
630 //
631 // optional
632 NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
633 // DeleteChatPhoto is a service message: the chat photo was deleted;
634 //
635 // optional
636 DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
637 // GroupChatCreated is a service message: the group has been created;
638 //
639 // optional
640 GroupChatCreated bool `json:"group_chat_created,omitempty"`
641 // SuperGroupChatCreated is a service message: the supergroup has been created.
642 // This field can't be received in a message coming through updates,
643 // because bot can't be a member of a supergroup when it is created.
644 // It can only be found in ReplyToMessage if someone replies to a very first message
645 // in a directly created supergroup;
646 //
647 // optional
648 SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
649 // ChannelChatCreated is a service message: the channel has been created.
650 // This field can't be received in a message coming through updates,
651 // because bot can't be a member of a channel when it is created.
652 // It can only be found in ReplyToMessage
653 // if someone replies to a very first message in a channel;
654 //
655 // optional
656 ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
657 // MessageAutoDeleteTimerChanged is a service message: auto-delete timer
658 // settings changed in the chat.
659 //
660 // optional
661 MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`
662 // MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
663 // This number may be greater than 32 bits and some programming languages
664 // may have difficulty/silent defects in interpreting it.
665 // But it is smaller than 52 bits, so a signed 64-bit integer
666 // or double-precision float type are safe for storing this identifier;
667 //
668 // optional
669 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
670 // MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
671 // This number may be greater than 32 bits and some programming languages
672 // may have difficulty/silent defects in interpreting it.
673 // But it is smaller than 52 bits, so a signed 64-bit integer
674 // or double-precision float type are safe for storing this identifier;
675 //
676 // optional
677 MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
678 // PinnedMessage is a specified message was pinned.
679 // Note that the Message object in this field will not contain further ReplyToMessage
680 // fields even if it is itself a reply;
681 //
682 // optional
683 PinnedMessage *Message `json:"pinned_message,omitempty"`
684 // Invoice message is an invoice for a payment;
685 //
686 // optional
687 Invoice *Invoice `json:"invoice,omitempty"`
688 // SuccessfulPayment message is a service message about a successful payment,
689 // information about the payment;
690 //
691 // optional
692 SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
693 // UsersShared is a service message: the users were shared with the bot
694 //
695 // optional
696 UsersShared *UsersShared `json:"users_shared,omitempty"`
697 // ChatShared is a service message: a chat was shared with the bot
698 //
699 // optional
700 ChatShared *ChatShared `json:"chat_shared,omitempty"`
701 // ConnectedWebsite is the domain name of the website on which the user has
702 // logged in;
703 //
704 // optional
705 ConnectedWebsite string `json:"connected_website,omitempty"`
706 // WriteAccessAllowed is a service message: the user allowed the bot
707 // added to the attachment menu to write messages
708 //
709 // optional
710 WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"`
711 // PassportData is a Telegram Passport data;
712 //
713 // optional
714 PassportData *PassportData `json:"passport_data,omitempty"`
715 // ProximityAlertTriggered is a service message. A user in the chat
716 // triggered another user's proximity alert while sharing Live Location
717 //
718 // optional
719 ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
720 // ForumTopicCreated is a service message: forum topic created
721 //
722 // optional
723 ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"`
724 // ForumTopicClosed is a service message: forum topic edited
725 //
726 // optional
727 ForumTopicEdited *ForumTopicEdited `json:"forum_topic_edited,omitempty"`
728 // ForumTopicClosed is a service message: forum topic closed
729 //
730 // optional
731 ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"`
732 // ForumTopicReopened is a service message: forum topic reopened
733 //
734 // optional
735 ForumTopicReopened *ForumTopicReopened `json:"forum_topic_reopened,omitempty"`
736 // GeneralForumTopicHidden is a service message: the 'General' forum topic hidden
737 //
738 // optional
739 GeneralForumTopicHidden *GeneralForumTopicHidden `json:"general_forum_topic_hidden,omitempty"`
740 // GeneralForumTopicUnhidden is a service message: the 'General' forum topic unhidden
741 //
742 // optional
743 GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"`
744 // Service message: a scheduled giveaway was created
745 //
746 // optional
747 GiveawayCreated *GiveawayCreated `json:"giveaway_created,omitempty"`
748 // The message is a scheduled giveaway message
749 //
750 // optional
751 Giveaway *Giveaway `json:"giveaway,omitempty"`
752 // A giveaway with public winners was completed
753 //
754 // optional
755 GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`
756 // Service message: a giveaway without public winners was completed
757 //
758 // optional
759 GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"`
760 // VideoChatScheduled is a service message: video chat scheduled.
761 //
762 // optional
763 VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"`
764 // VideoChatStarted is a service message: video chat started.
765 //
766 // optional
767 VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"`
768 // VideoChatEnded is a service message: video chat ended.
769 //
770 // optional
771 VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"`
772 // VideoChatParticipantsInvited is a service message: new participants
773 // invited to a video chat.
774 //
775 // optional
776 VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited,omitempty"`
777 // WebAppData is a service message: data sent by a Web App.
778 //
779 // optional
780 WebAppData *WebAppData `json:"web_app_data,omitempty"`
781 // ReplyMarkup is the Inline keyboard attached to the message.
782 // login_url buttons are represented as ordinary url buttons.
783 //
784 // optional
785 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
786}
787
788// Time converts the message timestamp into a Time.
789func (m *Message) Time() time.Time {
790 return time.Unix(int64(m.Date), 0)
791}
792
793// IsCommand returns true if message starts with a "bot_command" entity.
794func (m *Message) IsCommand() bool {
795 if m.Entities == nil || len(m.Entities) == 0 {
796 return false
797 }
798
799 entity := m.Entities[0]
800 return entity.Offset == 0 && entity.IsCommand()
801}
802
803// Command checks if the message was a command and if it was, returns the
804// command. If the Message was not a command, it returns an empty string.
805//
806// If the command contains the at name syntax, it is removed. Use
807// CommandWithAt() if you do not want that.
808func (m *Message) Command() string {
809 command := m.CommandWithAt()
810
811 if i := strings.Index(command, "@"); i != -1 {
812 command = command[:i]
813 }
814
815 return command
816}
817
818// CommandWithAt checks if the message was a command and if it was, returns the
819// command. If the Message was not a command, it returns an empty string.
820//
821// If the command contains the at name syntax, it is not removed. Use Command()
822// if you want that.
823func (m *Message) CommandWithAt() string {
824 if !m.IsCommand() {
825 return ""
826 }
827
828 // IsCommand() checks that the message begins with a bot_command entity
829 entity := m.Entities[0]
830 return m.Text[1:entity.Length]
831}
832
833// CommandArguments checks if the message was a command and if it was,
834// returns all text after the command name. If the Message was not a
835// command, it returns an empty string.
836//
837// Note: The first character after the command name is omitted:
838// - "/foo bar baz" yields "bar baz", not " bar baz"
839// - "/foo-bar baz" yields "bar baz", too
840// Even though the latter is not a command conforming to the spec, the API
841// marks "/foo" as command entity.
842func (m *Message) CommandArguments() string {
843 if !m.IsCommand() {
844 return ""
845 }
846
847 // IsCommand() checks that the message begins with a bot_command entity
848 entity := m.Entities[0]
849
850 if len(m.Text) == entity.Length {
851 return "" // The command makes up the whole message
852 }
853
854 return m.Text[entity.Length+1:]
855}
856
857// MessageID represents a unique message identifier.
858type MessageID struct {
859 MessageID int `json:"message_id"`
860}
861
862// MessageEntity represents one special entity in a text message.
863type MessageEntity struct {
864 // Type of the entity.
865 // Can be:
866 // “mention” (@username),
867 // “hashtag” (#hashtag),
868 // “cashtag” ($USD),
869 // “bot_command” (/start@jobs_bot),
870 // “url” (https://telegram.org),
871 // “email” (do-not-reply@telegram.org),
872 // “phone_number” (+1-212-555-0123),
873 // “bold” (bold text),
874 // “italic” (italic text),
875 // “underline” (underlined text),
876 // “strikethrough” (strikethrough text),
877 // "spoiler" (spoiler message),
878 // “blockquote” (block quotation),
879 // “code” (monowidth string),
880 // “pre” (monowidth block),
881 // “text_link” (for clickable text URLs),
882 // “text_mention” (for users without usernames)
883 // “text_mention” (for inline custom emoji stickers)
884 Type string `json:"type"`
885 // Offset in UTF-16 code units to the start of the entity
886 Offset int `json:"offset"`
887 // Length
888 Length int `json:"length"`
889 // URL for “text_link” only, url that will be opened after user taps on the text
890 //
891 // optional
892 URL string `json:"url,omitempty"`
893 // User for “text_mention” only, the mentioned user
894 //
895 // optional
896 User *User `json:"user,omitempty"`
897 // Language for “pre” only, the programming language of the entity text
898 //
899 // optional
900 Language string `json:"language,omitempty"`
901 // CustomEmojiID for “custom_emoji” only, unique identifier of the custom emoji
902 //
903 // optional
904 CustomEmojiID string `json:"custom_emoji_id"`
905}
906
907// ParseURL attempts to parse a URL contained within a MessageEntity.
908func (e MessageEntity) ParseURL() (*url.URL, error) {
909 if e.URL == "" {
910 return nil, errors.New(ErrBadURL)
911 }
912
913 return url.Parse(e.URL)
914}
915
916// IsMention returns true if the type of the message entity is "mention" (@username).
917func (e MessageEntity) IsMention() bool {
918 return e.Type == "mention"
919}
920
921// IsTextMention returns true if the type of the message entity is "text_mention"
922// (At this time, the user field exists, and occurs when tagging a member without a username)
923func (e MessageEntity) IsTextMention() bool {
924 return e.Type == "text_mention"
925}
926
927// IsHashtag returns true if the type of the message entity is "hashtag".
928func (e MessageEntity) IsHashtag() bool {
929 return e.Type == "hashtag"
930}
931
932// IsCommand returns true if the type of the message entity is "bot_command".
933func (e MessageEntity) IsCommand() bool {
934 return e.Type == "bot_command"
935}
936
937// IsURL returns true if the type of the message entity is "url".
938func (e MessageEntity) IsURL() bool {
939 return e.Type == "url"
940}
941
942// IsEmail returns true if the type of the message entity is "email".
943func (e MessageEntity) IsEmail() bool {
944 return e.Type == "email"
945}
946
947// IsBold returns true if the type of the message entity is "bold" (bold text).
948func (e MessageEntity) IsBold() bool {
949 return e.Type == "bold"
950}
951
952// IsItalic returns true if the type of the message entity is "italic" (italic text).
953func (e MessageEntity) IsItalic() bool {
954 return e.Type == "italic"
955}
956
957// IsCode returns true if the type of the message entity is "code" (monowidth string).
958func (e MessageEntity) IsCode() bool {
959 return e.Type == "code"
960}
961
962// IsPre returns true if the type of the message entity is "pre" (monowidth block).
963func (e MessageEntity) IsPre() bool {
964 return e.Type == "pre"
965}
966
967// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
968func (e MessageEntity) IsTextLink() bool {
969 return e.Type == "text_link"
970}
971
972// TextQuote contains information about the quoted part of a message
973// that is replied to by the given message
974type TextQuote struct {
975 // Text of the quoted part of a message that is replied to by the given message
976 Text string `json:"text"`
977 // Entities special entities that appear in the quote.
978 // Currently, only bold, italic, underline, strikethrough, spoiler,
979 // and custom_emoji entities are kept in quotes.
980 //
981 // optional
982 Entities []MessageEntity `json:"entities,omitempty"`
983 // Position is approximate quote position in the original message
984 // in UTF-16 code units as specified by the sender
985 Position int `json:"position"`
986 // IsManual True, if the quote was chosen manually by the message sender.
987 // Otherwise, the quote was added automatically by the server.
988 //
989 // optional
990 IsManual bool `json:"is_manual,omitempty"`
991}
992
993// ExternalReplyInfo contains information about a message that is being replied to,
994// which may come from another chat or forum topic.
995type ExternalReplyInfo struct {
996 // Origin of the message replied to by the given message
997 Origin MessageOrigin `json:"origin"`
998 // Chat is the conversation the message belongs to
999 Chat *Chat `json:"chat"`
1000 // MessageID is a unique message identifier inside this chat
1001 MessageID int `json:"message_id"`
1002 // LinkPreviewOptions used for link preview generation for the original message,
1003 // if it is a text message
1004 //
1005 // Optional
1006 LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
1007 // Animation message is an animation, information about the animation.
1008 // For backward compatibility, when this field is set, the document field will also be set;
1009 //
1010 // optional
1011 Animation *Animation `json:"animation,omitempty"`
1012 // Audio message is an audio file, information about the file;
1013 //
1014 // optional
1015 Audio *Audio `json:"audio,omitempty"`
1016 // Document message is a general file, information about the file;
1017 //
1018 // optional
1019 Document *Document `json:"document,omitempty"`
1020 // Photo message is a photo, available sizes of the photo;
1021 //
1022 // optional
1023 Photo []PhotoSize `json:"photo,omitempty"`
1024 // Sticker message is a sticker, information about the sticker;
1025 //
1026 // optional
1027 Sticker *Sticker `json:"sticker,omitempty"`
1028 // Story message is a forwarded story;
1029 //
1030 // optional
1031 Story *Story `json:"story,omitempty"`
1032 // Video message is a video, information about the video;
1033 //
1034 // optional
1035 Video *Video `json:"video,omitempty"`
1036 // VideoNote message is a video note, information about the video message;
1037 //
1038 // optional
1039 VideoNote *VideoNote `json:"video_note,omitempty"`
1040 // Voice message is a voice message, information about the file;
1041 //
1042 // optional
1043 Voice *Voice `json:"voice,omitempty"`
1044 // HasMediaSpoiler True, if the message media is covered by a spoiler animation
1045 //
1046 // optional
1047 HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"`
1048 // Contact message is a shared contact, information about the contact;
1049 //
1050 // optional
1051 Contact *Contact `json:"contact,omitempty"`
1052 // Dice is a dice with random value;
1053 //
1054 // optional
1055 Dice *Dice `json:"dice,omitempty"`
1056 // Game message is a game, information about the game;
1057 //
1058 // optional
1059 Game *Game `json:"game,omitempty"`
1060 // Giveaway is information about the giveaway
1061 //
1062 // optional
1063 Giveaway *Giveaway `json:"giveaway,omitempty"`
1064 // GiveawayWinners a giveaway with public winners was completed
1065 //
1066 // optional
1067 GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`
1068 // Invoice message is an invoice for a payment;
1069 //
1070 // optional
1071 Invoice *Invoice `json:"invoice,omitempty"`
1072 // Location message is a shared location, information about the location;
1073 //
1074 // optional
1075 Location *Location `json:"location,omitempty"`
1076 // Poll is a native poll, information about the poll;
1077 //
1078 // optional
1079 Poll *Poll `json:"poll,omitempty"`
1080 // Venue message is a venue, information about the venue.
1081 // For backward compatibility, when this field is set, the location field
1082 // will also be set;
1083 //
1084 // optional
1085 Venue *Venue `json:"venue,omitempty"`
1086}
1087
1088// ReplyParameters describes reply parameters for the message that is being sent.
1089type ReplyParameters struct {
1090 // MessageID identifier of the message that will be replied to in
1091 // the current chat, or in the chat chat_id if it is specified
1092 MessageID int `json:"message_id"`
1093 // ChatID if the message to be replied to is from a different chat,
1094 // unique identifier for the chat or username of the channel (in the format @channelusername)
1095 //
1096 // optional
1097 ChatID interface{} `json:"chat_id,omitempty"`
1098 // AllowSendingWithoutReply true if the message should be sent even
1099 // if the specified message to be replied to is not found;
1100 // can be used only for replies in the same chat and forum topic.
1101 //
1102 // optional
1103 AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
1104 // Quote is a quoted part of the message to be replied to;
1105 // 0-1024 characters after entities parsing. The quote must be
1106 // an exact substring of the message to be replied to,
1107 // including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities.
1108 // The message will fail to send if the quote isn't found in the original message.
1109 //
1110 // optional
1111 Quote string `json:"quote,omitempty"`
1112 // QuoteParseMode mode for parsing entities in the quote.
1113 //
1114 // optional
1115 QuoteParseMode string `json:"quote_parse_mode,omitempty"`
1116 // QuoteEntities a JSON-serialized list of special entities that appear in the quote.
1117 // It can be specified instead of quote_parse_mode.
1118 //
1119 // optional
1120 QuoteEntities []MessageEntity `json:"quote_entities,omitempty"`
1121 // QuotePosition is a position of the quote in the original message in UTF-16 code units
1122 //
1123 // optional
1124 QuotePosition int `json:"quote_position,omitempty"`
1125}
1126
1127const (
1128 MessageOriginUser = "user"
1129 MessageOriginHiddenUser = "hidden_user"
1130 MessageOriginChat = "chat"
1131 MessageOriginChannel = "channel"
1132)
1133
1134// MessageOrigin describes the origin of a message. It can be one of: "user", "hidden_user", "origin_chat", "origin_channel"
1135type MessageOrigin struct {
1136 // Type of the message origin.
1137 Type string `json:"type"`
1138 // Date the message was sent originally in Unix time
1139 Date int64 `json:"date"`
1140 // SenderUser "user" only.
1141 // Is a user that sent the message originally
1142 SenderUser *User `json:"sender_user,omitempty"`
1143 // SenderUserName "hidden_user" only.
1144 // Name of the user that sent the message originally
1145 SenderUserName string `json:"sender_user_name,omitempty"`
1146 // SenderChat "chat" and "channel".
1147 // For "chat": Chat that sent the message originally
1148 // For "channel": Channel chat to which the message was originally sent
1149 SenderChat *Chat `json:"sender_chat,omitempty"`
1150 // AuthorSignature "chat" and "channel".
1151 // For "chat": For messages originally sent by an anonymous chat administrator,
1152 // original message author signature.
1153 // For "channel": Signature of the original post author
1154 //
1155 // Optional
1156 AuthorSignature string `json:"author_signature,omitempty"`
1157 // MessageID "channel" only.
1158 // Unique message identifier inside the chat
1159 //
1160 // Optional
1161 MessageID int `json:"message_id,omitempty"`
1162}
1163
1164func (m MessageOrigin) IsUser() bool {
1165 return m.Type == MessageOriginUser
1166}
1167
1168func (m MessageOrigin) IsHiddenUser() bool {
1169 return m.Type == MessageOriginHiddenUser
1170}
1171
1172func (m MessageOrigin) IsChat() bool {
1173 return m.Type == MessageOriginChat
1174}
1175
1176func (m MessageOrigin) IsChannel() bool {
1177 return m.Type == MessageOriginChannel
1178}
1179
1180// PhotoSize represents one size of a photo or a file / sticker thumbnail.
1181type PhotoSize struct {
1182 // FileID identifier for this file, which can be used to download or reuse
1183 // the file
1184 FileID string `json:"file_id"`
1185 // FileUniqueID is the unique identifier for this file, which is supposed to
1186 // be the same over time and for different bots. Can't be used to download
1187 // or reuse the file.
1188 FileUniqueID string `json:"file_unique_id"`
1189 // Width photo width
1190 Width int `json:"width"`
1191 // Height photo height
1192 Height int `json:"height"`
1193 // FileSize file size
1194 //
1195 // optional
1196 FileSize int `json:"file_size,omitempty"`
1197}
1198
1199// Animation represents an animation file.
1200type Animation struct {
1201 // FileID is the identifier for this file, which can be used to download or reuse
1202 // the file
1203 FileID string `json:"file_id"`
1204 // FileUniqueID is the unique identifier for this file, which is supposed to
1205 // be the same over time and for different bots. Can't be used to download
1206 // or reuse the file.
1207 FileUniqueID string `json:"file_unique_id"`
1208 // Width video width as defined by sender
1209 Width int `json:"width"`
1210 // Height video height as defined by sender
1211 Height int `json:"height"`
1212 // Duration of the video in seconds as defined by sender
1213 Duration int `json:"duration"`
1214 // Thumbnail animation thumbnail as defined by sender
1215 //
1216 // optional
1217 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
1218 // FileName original animation filename as defined by sender
1219 //
1220 // optional
1221 FileName string `json:"file_name,omitempty"`
1222 // MimeType of the file as defined by sender
1223 //
1224 // optional
1225 MimeType string `json:"mime_type,omitempty"`
1226 // FileSize file size
1227 //
1228 // optional
1229 FileSize int64 `json:"file_size,omitempty"`
1230}
1231
1232// Audio represents an audio file to be treated as music by the Telegram clients.
1233type Audio struct {
1234 // FileID is an identifier for this file, which can be used to download or
1235 // reuse the file
1236 FileID string `json:"file_id"`
1237 // FileUniqueID is the unique identifier for this file, which is supposed to
1238 // be the same over time and for different bots. Can't be used to download
1239 // or reuse the file.
1240 FileUniqueID string `json:"file_unique_id"`
1241 // Duration of the audio in seconds as defined by sender
1242 Duration int `json:"duration"`
1243 // Performer of the audio as defined by sender or by audio tags
1244 //
1245 // optional
1246 Performer string `json:"performer,omitempty"`
1247 // Title of the audio as defined by sender or by audio tags
1248 //
1249 // optional
1250 Title string `json:"title,omitempty"`
1251 // FileName is the original filename as defined by sender
1252 //
1253 // optional
1254 FileName string `json:"file_name,omitempty"`
1255 // MimeType of the file as defined by sender
1256 //
1257 // optional
1258 MimeType string `json:"mime_type,omitempty"`
1259 // FileSize file size
1260 //
1261 // optional
1262 FileSize int64 `json:"file_size,omitempty"`
1263 // Thumbnail is the album cover to which the music file belongs
1264 //
1265 // optional
1266 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
1267}
1268
1269// Document represents a general file.
1270type Document struct {
1271 // FileID is an identifier for this file, which can be used to download or
1272 // reuse the file
1273 FileID string `json:"file_id"`
1274 // FileUniqueID is the unique identifier for this file, which is supposed to
1275 // be the same over time and for different bots. Can't be used to download
1276 // or reuse the file.
1277 FileUniqueID string `json:"file_unique_id"`
1278 // Thumbnail document thumbnail as defined by sender
1279 //
1280 // optional
1281 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
1282 // FileName original filename as defined by sender
1283 //
1284 // optional
1285 FileName string `json:"file_name,omitempty"`
1286 // MimeType of the file as defined by sender
1287 //
1288 // optional
1289 MimeType string `json:"mime_type,omitempty"`
1290 // FileSize file size
1291 //
1292 // optional
1293 FileSize int64 `json:"file_size,omitempty"`
1294}
1295
1296// Story represents a message about a forwarded story in the chat.
1297type Story struct{}
1298
1299// Video represents a video file.
1300type Video struct {
1301 // FileID identifier for this file, which can be used to download or reuse
1302 // the file
1303 FileID string `json:"file_id"`
1304 // FileUniqueID is the unique identifier for this file, which is supposed to
1305 // be the same over time and for different bots. Can't be used to download
1306 // or reuse the file.
1307 FileUniqueID string `json:"file_unique_id"`
1308 // Width video width as defined by sender
1309 Width int `json:"width"`
1310 // Height video height as defined by sender
1311 Height int `json:"height"`
1312 // Duration of the video in seconds as defined by sender
1313 Duration int `json:"duration"`
1314 // Thumbnail video thumbnail
1315 //
1316 // optional
1317 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
1318 // FileName is the original filename as defined by sender
1319 //
1320 // optional
1321 FileName string `json:"file_name,omitempty"`
1322 // MimeType of a file as defined by sender
1323 //
1324 // optional
1325 MimeType string `json:"mime_type,omitempty"`
1326 // FileSize file size
1327 //
1328 // optional
1329 FileSize int64 `json:"file_size,omitempty"`
1330}
1331
1332// VideoNote object represents a video message.
1333type VideoNote struct {
1334 // FileID identifier for this file, which can be used to download or reuse the file
1335 FileID string `json:"file_id"`
1336 // FileUniqueID is the unique identifier for this file, which is supposed to
1337 // be the same over time and for different bots. Can't be used to download
1338 // or reuse the file.
1339 FileUniqueID string `json:"file_unique_id"`
1340 // Length video width and height (diameter of the video message) as defined by sender
1341 Length int `json:"length"`
1342 // Duration of the video in seconds as defined by sender
1343 Duration int `json:"duration"`
1344 // Thumbnail video thumbnail
1345 //
1346 // optional
1347 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
1348 // FileSize file size
1349 //
1350 // optional
1351 FileSize int `json:"file_size,omitempty"`
1352}
1353
1354// Voice represents a voice note.
1355type Voice struct {
1356 // FileID identifier for this file, which can be used to download or reuse the file
1357 FileID string `json:"file_id"`
1358 // FileUniqueID is the unique identifier for this file, which is supposed to
1359 // be the same over time and for different bots. Can't be used to download
1360 // or reuse the file.
1361 FileUniqueID string `json:"file_unique_id"`
1362 // Duration of the audio in seconds as defined by sender
1363 Duration int `json:"duration"`
1364 // MimeType of the file as defined by sender
1365 //
1366 // optional
1367 MimeType string `json:"mime_type,omitempty"`
1368 // FileSize file size
1369 //
1370 // optional
1371 FileSize int64 `json:"file_size,omitempty"`
1372}
1373
1374// Contact represents a phone contact.
1375//
1376// Note that LastName and UserID may be empty.
1377type Contact struct {
1378 // PhoneNumber contact's phone number
1379 PhoneNumber string `json:"phone_number"`
1380 // FirstName contact's first name
1381 FirstName string `json:"first_name"`
1382 // LastName contact's last name
1383 //
1384 // optional
1385 LastName string `json:"last_name,omitempty"`
1386 // UserID contact's user identifier in Telegram
1387 //
1388 // optional
1389 UserID int64 `json:"user_id,omitempty"`
1390 // VCard is additional data about the contact in the form of a vCard.
1391 //
1392 // optional
1393 VCard string `json:"vcard,omitempty"`
1394}
1395
1396// Dice represents an animated emoji that displays a random value.
1397type Dice struct {
1398 // Emoji on which the dice throw animation is based
1399 Emoji string `json:"emoji"`
1400 // Value of the dice
1401 Value int `json:"value"`
1402}
1403
1404// PollOption contains information about one answer option in a poll.
1405type PollOption struct {
1406 // Text is the option text, 1-100 characters
1407 Text string `json:"text"`
1408 // VoterCount is the number of users that voted for this option
1409 VoterCount int `json:"voter_count"`
1410}
1411
1412// PollAnswer represents an answer of a user in a non-anonymous poll.
1413type PollAnswer struct {
1414 // PollID is the unique poll identifier
1415 PollID string `json:"poll_id"`
1416 // Chat that changed the answer to the poll, if the voter is anonymous.
1417 //
1418 // Optional
1419 VoterChat *Chat `json:"voter_chat,omitempty"`
1420 // User who changed the answer to the poll, if the voter isn't anonymous
1421 // For backward compatibility, the field user in such objects
1422 // will contain the user 136817688 (@Channel_Bot).
1423 //
1424 // Optional
1425 User *User `json:"user,omitempty"`
1426 // OptionIDs is the 0-based identifiers of poll options chosen by the user.
1427 // May be empty if user retracted vote.
1428 OptionIDs []int `json:"option_ids"`
1429}
1430
1431// Poll contains information about a poll.
1432type Poll struct {
1433 // ID is the unique poll identifier
1434 ID string `json:"id"`
1435 // Question is the poll question, 1-255 characters
1436 Question string `json:"question"`
1437 // Options is the list of poll options
1438 Options []PollOption `json:"options"`
1439 // TotalVoterCount is the total numbers of users who voted in the poll
1440 TotalVoterCount int `json:"total_voter_count"`
1441 // IsClosed is if the poll is closed
1442 IsClosed bool `json:"is_closed"`
1443 // IsAnonymous is if the poll is anonymous
1444 IsAnonymous bool `json:"is_anonymous"`
1445 // Type is the poll type, currently can be "regular" or "quiz"
1446 Type string `json:"type"`
1447 // AllowsMultipleAnswers is true, if the poll allows multiple answers
1448 AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
1449 // CorrectOptionID is the 0-based identifier of the correct answer option.
1450 // Available only for polls in quiz mode, which are closed, or was sent (not
1451 // forwarded) by the bot or to the private chat with the bot.
1452 //
1453 // optional
1454 CorrectOptionID int `json:"correct_option_id,omitempty"`
1455 // Explanation is text that is shown when a user chooses an incorrect answer
1456 // or taps on the lamp icon in a quiz-style poll, 0-200 characters
1457 //
1458 // optional
1459 Explanation string `json:"explanation,omitempty"`
1460 // ExplanationEntities are special entities like usernames, URLs, bot
1461 // commands, etc. that appear in the explanation
1462 //
1463 // optional
1464 ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
1465 // OpenPeriod is the amount of time in seconds the poll will be active
1466 // after creation
1467 //
1468 // optional
1469 OpenPeriod int `json:"open_period,omitempty"`
1470 // CloseDate is the point in time (unix timestamp) when the poll will be
1471 // automatically closed
1472 //
1473 // optional
1474 CloseDate int `json:"close_date,omitempty"`
1475}
1476
1477// Location represents a point on the map.
1478type Location struct {
1479 // Longitude as defined by sender
1480 Longitude float64 `json:"longitude"`
1481 // Latitude as defined by sender
1482 Latitude float64 `json:"latitude"`
1483 // HorizontalAccuracy is the radius of uncertainty for the location,
1484 // measured in meters; 0-1500
1485 //
1486 // optional
1487 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
1488 // LivePeriod is time relative to the message sending date, during which the
1489 // location can be updated, in seconds. For active live locations only.
1490 //
1491 // optional
1492 LivePeriod int `json:"live_period,omitempty"`
1493 // Heading is the direction in which user is moving, in degrees; 1-360. For
1494 // active live locations only.
1495 //
1496 // optional
1497 Heading int `json:"heading,omitempty"`
1498 // ProximityAlertRadius is the maximum distance for proximity alerts about
1499 // approaching another chat member, in meters. For sent live locations only.
1500 //
1501 // optional
1502 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
1503}
1504
1505// Venue represents a venue.
1506type Venue struct {
1507 // Location is the venue location
1508 Location Location `json:"location"`
1509 // Title is the name of the venue
1510 Title string `json:"title"`
1511 // Address of the venue
1512 Address string `json:"address"`
1513 // FoursquareID is the foursquare identifier of the venue
1514 //
1515 // optional
1516 FoursquareID string `json:"foursquare_id,omitempty"`
1517 // FoursquareType is the foursquare type of the venue
1518 //
1519 // optional
1520 FoursquareType string `json:"foursquare_type,omitempty"`
1521 // GooglePlaceID is the Google Places identifier of the venue
1522 //
1523 // optional
1524 GooglePlaceID string `json:"google_place_id,omitempty"`
1525 // GooglePlaceType is the Google Places type of the venue
1526 //
1527 // optional
1528 GooglePlaceType string `json:"google_place_type,omitempty"`
1529}
1530
1531// WebAppData Contains data sent from a Web App to the bot.
1532type WebAppData struct {
1533 // Data is the data. Be aware that a bad client can send arbitrary data in this field.
1534 Data string `json:"data"`
1535 // ButtonText is the text of the web_app keyboard button, from which the Web App
1536 // was opened. Be aware that a bad client can send arbitrary data in this field.
1537 ButtonText string `json:"button_text"`
1538}
1539
1540// ProximityAlertTriggered represents a service message sent when a user in the
1541// chat triggers a proximity alert sent by another user.
1542type ProximityAlertTriggered struct {
1543 // Traveler is the user that triggered the alert
1544 Traveler User `json:"traveler"`
1545 // Watcher is the user that set the alert
1546 Watcher User `json:"watcher"`
1547 // Distance is the distance between the users
1548 Distance int `json:"distance"`
1549}
1550
1551// MessageAutoDeleteTimerChanged represents a service message about a change in
1552// auto-delete timer settings.
1553type MessageAutoDeleteTimerChanged struct {
1554 // New auto-delete time for messages in the chat.
1555 MessageAutoDeleteTime int `json:"message_auto_delete_time"`
1556}
1557
1558// ForumTopicCreated represents a service message about a new forum topic
1559// created in the chat.
1560type ForumTopicCreated struct {
1561 // Name is the name of topic
1562 Name string `json:"name"`
1563 // IconColor is the color of the topic icon in RGB format
1564 IconColor int `json:"icon_color"`
1565 // IconCustomEmojiID is the unique identifier of the custom emoji
1566 // shown as the topic icon
1567 //
1568 // optional
1569 IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
1570}
1571
1572// ForumTopicClosed represents a service message about a forum topic
1573// closed in the chat. Currently holds no information.
1574type ForumTopicClosed struct {
1575}
1576
1577// ForumTopicEdited object represents a service message about an edited forum topic.
1578type ForumTopicEdited struct {
1579 // Name is the new name of the topic, if it was edited
1580 //
1581 // optional
1582 Name string `json:"name,omitempty"`
1583 // IconCustomEmojiID is the new identifier of the custom emoji
1584 // shown as the topic icon, if it was edited;
1585 // an empty string if the icon was removed
1586 //
1587 // optional
1588 IconCustomEmojiID *string `json:"icon_custom_emoji_id,omitempty"`
1589}
1590
1591// ForumTopicReopened represents a service message about a forum topic
1592// reopened in the chat. Currently holds no information.
1593type ForumTopicReopened struct {
1594}
1595
1596// GeneralForumTopicHidden represents a service message about General forum topic
1597// hidden in the chat. Currently holds no information.
1598type GeneralForumTopicHidden struct {
1599}
1600
1601// GeneralForumTopicUnhidden represents a service message about General forum topic
1602// unhidden in the chat. Currently holds no information.
1603type GeneralForumTopicUnhidden struct {
1604}
1605
1606// UsersShared object contains information about the user whose identifier
1607// was shared with the bot using a KeyboardButtonRequestUser button.
1608type UsersShared struct {
1609 // RequestID is an indentifier of the request.
1610 RequestID int `json:"request_id"`
1611 // UserIDs are identifiers of the shared user.
1612 UserIDs []int64 `json:"user_ids"`
1613}
1614
1615// ChatShared contains information about the chat whose identifier
1616// was shared with the bot using a KeyboardButtonRequestChat button.
1617type ChatShared struct {
1618 // RequestID is an indentifier of the request.
1619 RequestID int `json:"request_id"`
1620 // ChatID is an identifier of the shared chat.
1621 ChatID int64 `json:"chat_id"`
1622}
1623
1624// WriteAccessAllowed represents a service message about a user allowing a bot
1625// to write messages after adding the bot to the attachment menu or launching
1626// a Web App from a link.
1627type WriteAccessAllowed struct {
1628 // FromRequest is true, if the access was granted after
1629 // the user accepted an explicit request from a Web App
1630 // sent by the method requestWriteAccess.
1631 //
1632 // Optional
1633 FromRequest bool `json:"from_request,omitempty"`
1634 // Name of the Web App which was launched from a link
1635 //
1636 // Optional
1637 WebAppName string `json:"web_app_name,omitempty"`
1638 // FromAttachmentMenu is true, if the access was granted when
1639 // the bot was added to the attachment or side menu
1640 //
1641 // Optional
1642 FromAttachmentMenu bool `json:"from_attachment_menu,omitempty"`
1643}
1644
1645// VideoChatScheduled represents a service message about a voice chat scheduled
1646// in the chat.
1647type VideoChatScheduled struct {
1648 // Point in time (Unix timestamp) when the voice chat is supposed to be
1649 // started by a chat administrator
1650 StartDate int `json:"start_date"`
1651}
1652
1653// Time converts the scheduled start date into a Time.
1654func (m *VideoChatScheduled) Time() time.Time {
1655 return time.Unix(int64(m.StartDate), 0)
1656}
1657
1658// VideoChatStarted represents a service message about a voice chat started in
1659// the chat.
1660type VideoChatStarted struct{}
1661
1662// VideoChatEnded represents a service message about a voice chat ended in the
1663// chat.
1664type VideoChatEnded struct {
1665 // Voice chat duration; in seconds.
1666 Duration int `json:"duration"`
1667}
1668
1669// VideoChatParticipantsInvited represents a service message about new members
1670// invited to a voice chat.
1671type VideoChatParticipantsInvited struct {
1672 // New members that were invited to the voice chat.
1673 //
1674 // optional
1675 Users []User `json:"users,omitempty"`
1676}
1677
1678// This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
1679type GiveawayCreated struct{}
1680
1681// Giveaway represents a message about a scheduled giveaway.
1682type Giveaway struct {
1683 // Chats is the list of chats which the user must join to participate in the giveaway
1684 Chats []Chat `json:"chats"`
1685 // WinnersSelectionDate is point in time (Unix timestamp) when
1686 // winners of the giveaway will be selected
1687 WinnersSelectionDate int64 `json:"winners_selection_date"`
1688 // WinnerCount is the number of users which are supposed
1689 // to be selected as winners of the giveaway
1690 WinnerCount int `json:"winner_count"`
1691 // OnlyNewMembers True, if only users who join the chats after
1692 // the giveaway started should be eligible to win
1693 //
1694 // optional
1695 OnlyNewMembers bool `json:"only_new_members,omitempty"`
1696 // HasPublicWinners True, if the list of giveaway winners will be visible to everyone
1697 //
1698 // optional
1699 HasPublicWinners bool `json:"has_public_winners,omitempty"`
1700 // PrizeDescription is description of additional giveaway prize
1701 //
1702 // optional
1703 PrizeDescription string `json:"prize_description,omitempty"`
1704 // CountryCodes is a list of two-letter ISO 3166-1 alpha-2 country codes
1705 // indicating the countries from which eligible users for the giveaway must come.
1706 // If empty, then all users can participate in the giveaway.
1707 //
1708 // optional
1709 CountryCodes []string `json:"country_codes,omitempty"`
1710 // PremiumSubscriptionMonthCount the number of months the Telegram Premium
1711 // subscription won from the giveaway will be active for
1712 //
1713 // optional
1714 PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
1715}
1716
1717// Giveaway represents a message about a scheduled giveaway.
1718type GiveawayWinners struct {
1719 // Chat that created the giveaway
1720 Chat Chat `json:"chat"`
1721 // GiveawayMessageID is the identifier of the messsage with the giveaway in the chat
1722 GiveawayMessageID int `json:"giveaway_message_id"`
1723 // WinnersSelectionDate is point in time (Unix timestamp) when
1724 // winners of the giveaway will be selected
1725 WinnersSelectionDate int64 `json:"winners_selection_date"`
1726 // WinnerCount is the number of users which are supposed
1727 // to be selected as winners of the giveaway
1728 WinnerCount int `json:"winner_count"`
1729 // Winners is a list of up to 100 winners of the giveaway
1730 Winners []User `json:"winners"`
1731 // AdditionalChatCount is the number of other chats
1732 // the user had to join in order to be eligible for the giveaway
1733 //
1734 // optional
1735 AdditionalChatCount int `json:"additional_chat_count,omitempty"`
1736 // PremiumSubscriptionMonthCount the number of months the Telegram Premium
1737 // subscription won from the giveaway will be active for
1738 //
1739 // optional
1740 PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
1741 // UnclaimedPrizeCount is the number of undistributed prizes
1742 //
1743 // optional
1744 UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
1745 // OnlyNewMembers True, if only users who join the chats after
1746 // the giveaway started should be eligible to win
1747 //
1748 // optional
1749 OnlyNewMembers bool `json:"only_new_members,omitempty"`
1750 // WasRefunded True, if the giveaway was canceled because the payment for it was refunded
1751 //
1752 // optional
1753 WasRefunded bool `json:"was_refunded,omitempty"`
1754 // PrizeDescription is description of additional giveaway prize
1755 //
1756 // optional
1757 PrizeDescription string `json:"prize_description,omitempty"`
1758}
1759
1760// This object represents a service message about the completion of a giveaway without public winners.
1761type GiveawayCompleted struct {
1762 // Number of winners in the giveaway
1763 WinnerCount int `json:"winner_count"`
1764 // Number of undistributed prizes
1765 //
1766 // optional
1767 UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
1768 // Message with the giveaway that was completed, if it wasn't deleted
1769 //
1770 // optional
1771 GiveawayMessage *Message `json:"giveaway_message,omitempty"`
1772}
1773
1774// LinkPreviewOptions describes the options used for link preview generation.
1775type LinkPreviewOptions struct {
1776 // IsDisabled True, if the link preview is disabled
1777 //
1778 // optional
1779 IsDisabled bool `json:"is_disabled,omitempty"`
1780 // URL to use for the link preview. If empty,
1781 // then the first URL found in the message text will be used
1782 //
1783 // optional
1784 URL string `json:"url,omitempty"`
1785 // PreferSmallMedia True, if the media in the link preview is suppposed
1786 // to be shrunk; ignored if the URL isn't explicitly specified
1787 // or media size change isn't supported for the preview
1788 //
1789 // optional
1790 PreferSmallMedia bool `json:"prefer_small_media,omitempty"`
1791 // PreferLargeMedia True, if the media in the link preview is suppposed
1792 // to be enlarged; ignored if the URL isn't explicitly specified
1793 // or media size change isn't supported for the preview
1794 //
1795 // optional
1796 PreferLargeMedia bool `json:"prefer_large_media,omitempty"`
1797 // ShowAboveText True, if the link preview must be shown above the message text;
1798 // otherwise, the link preview will be shown below the message text
1799 //
1800 // optional
1801 ShowAboveText bool `json:"show_above_text,omitempty"`
1802}
1803
1804// UserProfilePhotos contains a set of user profile photos.
1805type UserProfilePhotos struct {
1806 // TotalCount total number of profile pictures the target user has
1807 TotalCount int `json:"total_count"`
1808 // Photos requested profile pictures (in up to 4 sizes each)
1809 Photos [][]PhotoSize `json:"photos"`
1810}
1811
1812// File contains information about a file to download from Telegram.
1813type File struct {
1814 // FileID identifier for this file, which can be used to download or reuse
1815 // the file
1816 FileID string `json:"file_id"`
1817 // FileUniqueID is the unique identifier for this file, which is supposed to
1818 // be the same over time and for different bots. Can't be used to download
1819 // or reuse the file.
1820 FileUniqueID string `json:"file_unique_id"`
1821 // FileSize file size, if known
1822 //
1823 // optional
1824 FileSize int64 `json:"file_size,omitempty"`
1825 // FilePath file path
1826 //
1827 // optional
1828 FilePath string `json:"file_path,omitempty"`
1829}
1830
1831// Link returns a full path to the download URL for a File.
1832//
1833// It requires the Bot token to create the link.
1834func (f *File) Link(token string) string {
1835 return fmt.Sprintf(FileEndpoint, token, f.FilePath)
1836}
1837
1838// WebAppInfo contains information about a Web App.
1839type WebAppInfo struct {
1840 // URL is the HTTPS URL of a Web App to be opened with additional data as
1841 // specified in Initializing Web Apps.
1842 URL string `json:"url"`
1843}
1844
1845// ReplyKeyboardMarkup represents a custom keyboard with reply options.
1846type ReplyKeyboardMarkup struct {
1847 // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
1848 Keyboard [][]KeyboardButton `json:"keyboard"`
1849 // IsPersistent requests clients to always show the keyboard
1850 // when the regular keyboard is hidden.
1851 // Defaults to false, in which case the custom keyboard can be hidden
1852 // and opened with a keyboard icon.
1853 //
1854 // optional
1855 IsPersistent bool `json:"is_persistent"`
1856 // ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
1857 // (e.g., make the keyboard smaller if there are just two rows of buttons).
1858 // Defaults to false, in which case the custom keyboard
1859 // is always of the same height as the app's standard keyboard.
1860 //
1861 // optional
1862 ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
1863 // OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
1864 // The keyboard will still be available, but clients will automatically display
1865 // the usual letter-keyboard in the chat – the user can press a special button
1866 // in the input field to see the custom keyboard again.
1867 // Defaults to false.
1868 //
1869 // optional
1870 OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
1871 // InputFieldPlaceholder is the placeholder to be shown in the input field when
1872 // the keyboard is active; 1-64 characters.
1873 //
1874 // optional
1875 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
1876 // Selective use this parameter if you want to show the keyboard to specific users only.
1877 // Targets:
1878 // 1) users that are @mentioned in the text of the Message object;
1879 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
1880 //
1881 // Example: A user requests to change the bot's language,
1882 // bot replies to the request with a keyboard to select the new language.
1883 // Other users in the group don't see the keyboard.
1884 //
1885 // optional
1886 Selective bool `json:"selective,omitempty"`
1887}
1888
1889// KeyboardButton represents one button of the reply keyboard. For simple text
1890// buttons String can be used instead of this object to specify text of the
1891// button. Optional fields request_contact, request_location, and request_poll
1892// are mutually exclusive.
1893type KeyboardButton struct {
1894 // Text of the button. If none of the optional fields are used,
1895 // it will be sent as a message when the button is pressed.
1896 Text string `json:"text"`
1897 // RequestUsers if specified, pressing the button will open
1898 // a list of suitable users. Tapping on any user will send
1899 // their identifier to the bot in a "user_shared" service message.
1900 // Available in private chats only.
1901 //
1902 // optional
1903 RequestUsers *KeyboardButtonRequestUsers `json:"request_users,omitempty"`
1904 // RequestChat if specified, pressing the button will open
1905 // a list of suitable chats. Tapping on a chat will send
1906 // its identifier to the bot in a "chat_shared" service message.
1907 // Available in private chats only.
1908 //
1909 // optional
1910 RequestChat *KeyboardButtonRequestChat `json:"request_chat,omitempty"`
1911 // RequestContact if True, the user's phone number will be sent
1912 // as a contact when the button is pressed.
1913 // Available in private chats only.
1914 //
1915 // optional
1916 RequestContact bool `json:"request_contact,omitempty"`
1917 // RequestLocation if True, the user's current location will be sent when
1918 // the button is pressed.
1919 // Available in private chats only.
1920 //
1921 // optional
1922 RequestLocation bool `json:"request_location,omitempty"`
1923 // RequestPoll if specified, the user will be asked to create a poll and send it
1924 // to the bot when the button is pressed. Available in private chats only
1925 //
1926 // optional
1927 RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
1928 // WebApp if specified, the described Web App will be launched when the button
1929 // is pressed. The Web App will be able to send a “web_app_data” service
1930 // message. Available in private chats only.
1931 //
1932 // optional
1933 WebApp *WebAppInfo `json:"web_app,omitempty"`
1934}
1935
1936// KeyboardButtonRequestUsers defines the criteria used to request
1937// a suitable user. The identifier of the selected user will be shared
1938// with the bot when the corresponding button is pressed.
1939type KeyboardButtonRequestUsers struct {
1940 // RequestID is a signed 32-bit identifier of the request.
1941 RequestID int `json:"request_id"`
1942 // UserIsBot pass True to request a bot,
1943 // pass False to request a regular user.
1944 // If not specified, no additional restrictions are applied.
1945 //
1946 // optional
1947 UserIsBot bool `json:"user_is_bot,omitempty"`
1948 // UserIsPremium pass True to request a premium user,
1949 // pass False to request a non-premium user.
1950 // If not specified, no additional restrictions are applied.
1951 //
1952 // optional
1953 UserIsPremium bool `json:"user_is_premium,omitempty"`
1954 // MaxQuantity is the maximum number of users to be selected.
1955 // 1-10. Defaults to 1
1956 //
1957 // optional
1958 MaxQuantity int `json:"max_quantity,omitempty"`
1959}
1960
1961// KeyboardButtonRequestChat defines the criteria used to request
1962// a suitable chat. The identifier of the selected chat will be shared
1963// with the bot when the corresponding button is pressed.
1964type KeyboardButtonRequestChat struct {
1965 // RequestID is a signed 32-bit identifier of the request.
1966 RequestID int `json:"request_id"`
1967 // ChatIsChannel pass True to request a channel chat,
1968 // pass False to request a group or a supergroup chat.
1969 ChatIsChannel bool `json:"chat_is_channel"`
1970 // ChatIsForum pass True to request a forum supergroup,
1971 // pass False to request a non-forum chat.
1972 // If not specified, no additional restrictions are applied.
1973 //
1974 // optional
1975 ChatIsForum bool `json:"chat_is_forum,omitempty"`
1976 // ChatHasUsername pass True to request a supergroup or a channel with a username,
1977 // pass False to request a chat without a username.
1978 // If not specified, no additional restrictions are applied.
1979 //
1980 // optional
1981 ChatHasUsername bool `json:"chat_has_username,omitempty"`
1982 // ChatIsCreated pass True to request a chat owned by the user.
1983 // Otherwise, no additional restrictions are applied.
1984 //
1985 // optional
1986 ChatIsCreated bool `json:"chat_is_created,omitempty"`
1987 // UserAdministratorRights is a JSON-serialized object listing
1988 // the required administrator rights of the user in the chat.
1989 // If not specified, no additional restrictions are applied.
1990 //
1991 // optional
1992 UserAdministratorRights *ChatAdministratorRights `json:"user_administrator_rights,omitempty"`
1993 // BotAdministratorRights is a JSON-serialized object listing
1994 // the required administrator rights of the bot in the chat.
1995 // The rights must be a subset of user_administrator_rights.
1996 // If not specified, no additional restrictions are applied.
1997 //
1998 // optional
1999 BotAdministratorRights *ChatAdministratorRights `json:"bot_administrator_rights,omitempty"`
2000 // BotIsMember pass True to request a chat with the bot as a member.
2001 // Otherwise, no additional restrictions are applied.
2002 //
2003 // optional
2004 BotIsMember bool `json:"bot_is_member,omitempty"`
2005}
2006
2007// KeyboardButtonPollType represents type of poll, which is allowed to
2008// be created and sent when the corresponding button is pressed.
2009type KeyboardButtonPollType struct {
2010 // Type is if quiz is passed, the user will be allowed to create only polls
2011 // in the quiz mode. If regular is passed, only regular polls will be
2012 // allowed. Otherwise, the user will be allowed to create a poll of any type.
2013 Type string `json:"type"`
2014}
2015
2016// ReplyKeyboardRemove Upon receiving a message with this object, Telegram
2017// clients will remove the current custom keyboard and display the default
2018// letter-keyboard. By default, custom keyboards are displayed until a new
2019// keyboard is sent by a bot. An exception is made for one-time keyboards
2020// that are hidden immediately after the user presses a button.
2021type ReplyKeyboardRemove struct {
2022 // RemoveKeyboard requests clients to remove the custom keyboard
2023 // (user will not be able to summon this keyboard;
2024 // if you want to hide the keyboard from sight but keep it accessible,
2025 // use one_time_keyboard in ReplyKeyboardMarkup).
2026 RemoveKeyboard bool `json:"remove_keyboard"`
2027 // Selective use this parameter if you want to remove the keyboard for specific users only.
2028 // Targets:
2029 // 1) users that are @mentioned in the text of the Message object;
2030 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2031 //
2032 // Example: A user votes in a poll, bot returns confirmation message
2033 // in reply to the vote and removes the keyboard for that user,
2034 // while still showing the keyboard with poll options to users who haven't voted yet.
2035 //
2036 // optional
2037 Selective bool `json:"selective,omitempty"`
2038}
2039
2040// InlineKeyboardMarkup represents an inline keyboard that appears right next to
2041// the message it belongs to.
2042type InlineKeyboardMarkup struct {
2043 // InlineKeyboard array of button rows, each represented by an Array of
2044 // InlineKeyboardButton objects
2045 InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
2046}
2047
2048// InlineKeyboardButton represents one button of an inline keyboard. You must
2049// use exactly one of the optional fields.
2050//
2051// Note that some values are references as even an empty string
2052// will change behavior.
2053//
2054// CallbackGame, if set, MUST be first button in first row.
2055type InlineKeyboardButton struct {
2056 // Text label text on the button
2057 Text string `json:"text"`
2058 // URL HTTP or tg:// url to be opened when button is pressed.
2059 //
2060 // optional
2061 URL *string `json:"url,omitempty"`
2062 // LoginURL is an HTTP URL used to automatically authorize the user. Can be
2063 // used as a replacement for the Telegram Login Widget
2064 //
2065 // optional
2066 LoginURL *LoginURL `json:"login_url,omitempty"`
2067 // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
2068 //
2069 // optional
2070 CallbackData *string `json:"callback_data,omitempty"`
2071 // WebApp is the Description of the Web App that will be launched when the user presses the button.
2072 // The Web App will be able to send an arbitrary message on behalf of the user using the method
2073 // answerWebAppQuery. Available only in private chats between a user and the bot.
2074 //
2075 // optional
2076 WebApp *WebAppInfo `json:"web_app,omitempty"`
2077 // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
2078 // open that chat and insert the bot's username and the specified inline query in the input field.
2079 // Can be empty, in which case just the bot's username will be inserted.
2080 //
2081 // This offers an easy way for users to start using your bot
2082 // in inline mode when they are currently in a private chat with it.
2083 // Especially useful when combined with switch_pm… actions – in this case
2084 // the user will be automatically returned to the chat they switched from,
2085 // skipping the chat selection screen.
2086 //
2087 // optional
2088 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
2089 // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
2090 // and the specified inline query in the current chat's input field.
2091 // Can be empty, in which case only the bot's username will be inserted.
2092 //
2093 // This offers a quick way for the user to open your bot in inline mode
2094 // in the same chat – good for selecting something from multiple options.
2095 //
2096 // optional
2097 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
2098 //SwitchInlineQueryChosenChat If set, pressing the button will prompt the user to
2099 //select one of their chats of the specified type, open that chat and insert the bot's
2100 //username and the specified inline query in the input field
2101 //
2102 //optional
2103 SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`
2104 // CallbackGame description of the game that will be launched when the user presses the button.
2105 //
2106 // optional
2107 CallbackGame *CallbackGame `json:"callback_game,omitempty"`
2108 // Pay specify True, to send a Pay button.
2109 //
2110 // NOTE: This type of button must always be the first button in the first row.
2111 //
2112 // optional
2113 Pay bool `json:"pay,omitempty"`
2114}
2115
2116// LoginURL represents a parameter of the inline keyboard button used to
2117// automatically authorize a user. Serves as a great replacement for the
2118// Telegram Login Widget when the user is coming from Telegram. All the user
2119// needs to do is tap/click a button and confirm that they want to log in.
2120type LoginURL struct {
2121 // URL is an HTTP URL to be opened with user authorization data added to the
2122 // query string when the button is pressed. If the user refuses to provide
2123 // authorization data, the original URL without information about the user
2124 // will be opened. The data added is the same as described in Receiving
2125 // authorization data.
2126 //
2127 // NOTE: You must always check the hash of the received data to verify the
2128 // authentication and the integrity of the data as described in Checking
2129 // authorization.
2130 URL string `json:"url"`
2131 // ForwardText is the new text of the button in forwarded messages
2132 //
2133 // optional
2134 ForwardText string `json:"forward_text,omitempty"`
2135 // BotUsername is the username of a bot, which will be used for user
2136 // authorization. See Setting up a bot for more details. If not specified,
2137 // the current bot's username will be assumed. The url's domain must be the
2138 // same as the domain linked with the bot. See Linking your domain to the
2139 // bot for more details.
2140 //
2141 // optional
2142 BotUsername string `json:"bot_username,omitempty"`
2143 // RequestWriteAccess if true requests permission for your bot to send
2144 // messages to the user
2145 //
2146 // optional
2147 RequestWriteAccess bool `json:"request_write_access,omitempty"`
2148}
2149
2150// CallbackQuery represents an incoming callback query from a callback button in
2151// an inline keyboard. If the button that originated the query was attached to a
2152// message sent by the bot, the field message will be present. If the button was
2153// attached to a message sent via the bot (in inline mode), the field
2154// inline_message_id will be present. Exactly one of the fields data or
2155// game_short_name will be present.
2156type CallbackQuery struct {
2157 // ID unique identifier for this query
2158 ID string `json:"id"`
2159 // From sender
2160 From *User `json:"from"`
2161 // Message with the callback button that originated the query.
2162 // Note that message content and message date will not be available if the
2163 // message is too old.
2164 //
2165 // optional
2166 Message *Message `json:"message,omitempty"`
2167 // InlineMessageID identifier of the message sent via the bot in inline
2168 // mode, that originated the query.
2169 //
2170 // optional
2171 InlineMessageID string `json:"inline_message_id,omitempty"`
2172 // ChatInstance global identifier, uniquely corresponding to the chat to
2173 // which the message with the callback button was sent. Useful for high
2174 // scores in games.
2175 ChatInstance string `json:"chat_instance"`
2176 // Data associated with the callback button. Be aware that
2177 // a bad client can send arbitrary data in this field.
2178 //
2179 // optional
2180 Data string `json:"data,omitempty"`
2181 // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
2182 //
2183 // optional
2184 GameShortName string `json:"game_short_name,omitempty"`
2185}
2186
2187// ForceReply when receiving a message with this object, Telegram clients will
2188// display a reply interface to the user (act as if the user has selected the
2189// bot's message and tapped 'Reply'). This can be extremely useful if you want
2190// to create user-friendly step-by-step interfaces without having to sacrifice
2191// privacy mode.
2192type ForceReply struct {
2193 // ForceReply shows reply interface to the user,
2194 // as if they manually selected the bot's message and tapped 'Reply'.
2195 ForceReply bool `json:"force_reply"`
2196 // InputFieldPlaceholder is the placeholder to be shown in the input field when
2197 // the reply is active; 1-64 characters.
2198 //
2199 // optional
2200 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
2201 // Selective use this parameter if you want to force reply from specific users only.
2202 // Targets:
2203 // 1) users that are @mentioned in the text of the Message object;
2204 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2205 //
2206 // optional
2207 Selective bool `json:"selective,omitempty"`
2208}
2209
2210// ChatPhoto represents a chat photo.
2211type ChatPhoto struct {
2212 // SmallFileID is a file identifier of small (160x160) chat photo.
2213 // This file_id can be used only for photo download and
2214 // only for as long as the photo is not changed.
2215 SmallFileID string `json:"small_file_id"`
2216 // SmallFileUniqueID is a unique file identifier of small (160x160) chat
2217 // photo, which is supposed to be the same over time and for different bots.
2218 // Can't be used to download or reuse the file.
2219 SmallFileUniqueID string `json:"small_file_unique_id"`
2220 // BigFileID is a file identifier of big (640x640) chat photo.
2221 // This file_id can be used only for photo download and
2222 // only for as long as the photo is not changed.
2223 BigFileID string `json:"big_file_id"`
2224 // BigFileUniqueID is a file identifier of big (640x640) chat photo, which
2225 // is supposed to be the same over time and for different bots. Can't be
2226 // used to download or reuse the file.
2227 BigFileUniqueID string `json:"big_file_unique_id"`
2228}
2229
2230// ChatInviteLink represents an invite link for a chat.
2231type ChatInviteLink struct {
2232 // InviteLink is the invite link. If the link was created by another chat
2233 // administrator, then the second part of the link will be replaced with “…”.
2234 InviteLink string `json:"invite_link"`
2235 // Creator of the link.
2236 Creator User `json:"creator"`
2237 // CreatesJoinRequest is true if users joining the chat via the link need to
2238 // be approved by chat administrators.
2239 //
2240 // optional
2241 CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
2242 // IsPrimary is true, if the link is primary.
2243 IsPrimary bool `json:"is_primary"`
2244 // IsRevoked is true, if the link is revoked.
2245 IsRevoked bool `json:"is_revoked"`
2246 // Name is the name of the invite link.
2247 //
2248 // optional
2249 Name string `json:"name,omitempty"`
2250 // ExpireDate is the point in time (Unix timestamp) when the link will
2251 // expire or has been expired.
2252 //
2253 // optional
2254 ExpireDate int `json:"expire_date,omitempty"`
2255 // MemberLimit is the maximum number of users that can be members of the
2256 // chat simultaneously after joining the chat via this invite link; 1-99999.
2257 //
2258 // optional
2259 MemberLimit int `json:"member_limit,omitempty"`
2260 // PendingJoinRequestCount is the number of pending join requests created
2261 // using this link.
2262 //
2263 // optional
2264 PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
2265}
2266
2267type ChatAdministratorRights struct {
2268 IsAnonymous bool `json:"is_anonymous"`
2269 CanManageChat bool `json:"can_manage_chat"`
2270 CanDeleteMessages bool `json:"can_delete_messages"`
2271 CanManageVideoChats bool `json:"can_manage_video_chats"`
2272 CanRestrictMembers bool `json:"can_restrict_members"`
2273 CanPromoteMembers bool `json:"can_promote_members"`
2274 CanChangeInfo bool `json:"can_change_info"`
2275 CanInviteUsers bool `json:"can_invite_users"`
2276 CanPostMessages bool `json:"can_post_messages"`
2277 CanEditMessages bool `json:"can_edit_messages"`
2278 CanPinMessages bool `json:"can_pin_messages"`
2279 CanPostStories bool `json:"can_post_stories"`
2280 CanEditStories bool `json:"can_edit_stories"`
2281 CanDeleteStories bool `json:"can_delete_stories"`
2282 CanManageTopics bool `json:"can_manage_topics"`
2283}
2284
2285// ChatMember contains information about one member of a chat.
2286type ChatMember struct {
2287 // User information about the user
2288 User *User `json:"user"`
2289 // Status the member's status in the chat.
2290 // Can be
2291 // “creator”,
2292 // “administrator”,
2293 // “member”,
2294 // “restricted”,
2295 // “left” or
2296 // “kicked”
2297 Status string `json:"status"`
2298 // CustomTitle owner and administrators only. Custom title for this user
2299 //
2300 // optional
2301 CustomTitle string `json:"custom_title,omitempty"`
2302 // IsAnonymous owner and administrators only. True, if the user's presence
2303 // in the chat is hidden
2304 //
2305 // optional
2306 IsAnonymous bool `json:"is_anonymous,omitempty"`
2307 // UntilDate restricted and kicked only.
2308 // Date when restrictions will be lifted for this user;
2309 // unix time.
2310 //
2311 // optional
2312 UntilDate int64 `json:"until_date,omitempty"`
2313 // CanBeEdited administrators only.
2314 // True, if the bot is allowed to edit administrator privileges of that user.
2315 //
2316 // optional
2317 CanBeEdited bool `json:"can_be_edited,omitempty"`
2318 // CanManageChat administrators only.
2319 // True, if the administrator can access the chat event log, chat
2320 // statistics, message statistics in channels, see channel members, see
2321 // anonymous administrators in supergroups and ignore slow mode. Implied by
2322 // any other administrator privilege.
2323 //
2324 // optional
2325 CanManageChat bool `json:"can_manage_chat,omitempty"`
2326 // CanPostMessages administrators only.
2327 // True, if the administrator can post in the channel;
2328 // channels only.
2329 //
2330 // optional
2331 CanPostMessages bool `json:"can_post_messages,omitempty"`
2332 // CanEditMessages administrators only.
2333 // True, if the administrator can edit messages of other users and can pin messages;
2334 // channels only.
2335 //
2336 // optional
2337 CanEditMessages bool `json:"can_edit_messages,omitempty"`
2338 // CanDeleteMessages administrators only.
2339 // True, if the administrator can delete messages of other users.
2340 //
2341 // optional
2342 CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
2343 // CanManageVideoChats administrators only.
2344 // True, if the administrator can manage video chats.
2345 //
2346 // optional
2347 CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
2348 // CanRestrictMembers administrators only.
2349 // True, if the administrator can restrict, ban or unban chat members.
2350 //
2351 // optional
2352 CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
2353 // CanPromoteMembers administrators only.
2354 // True, if the administrator can add new administrators
2355 // with a subset of their own privileges or demote administrators that he has promoted,
2356 // directly or indirectly (promoted by administrators that were appointed by the user).
2357 //
2358 // optional
2359 CanPromoteMembers bool `json:"can_promote_members,omitempty"`
2360 // CanChangeInfo administrators and restricted only.
2361 // True, if the user is allowed to change the chat title, photo and other settings.
2362 //
2363 // optional
2364 CanChangeInfo bool `json:"can_change_info,omitempty"`
2365 // CanInviteUsers administrators and restricted only.
2366 // True, if the user is allowed to invite new users to the chat.
2367 //
2368 // optional
2369 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2370 // CanPinMessages administrators and restricted only.
2371 // True, if the user is allowed to pin messages; groups and supergroups only
2372 //
2373 // optional
2374 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2375 // CanPostStories administrators only.
2376 // True, if the administrator can post stories in the channel; channels only
2377 //
2378 // optional
2379 CanPostStories bool `json:"can_post_stories,omitempty"`
2380 // CanEditStories administrators only.
2381 // True, if the administrator can edit stories posted by other users; channels only
2382 //
2383 // optional
2384 CanEditStories bool `json:"can_edit_stories,omitempty"`
2385 // CanDeleteStories administrators only.
2386 // True, if the administrator can delete stories posted by other users; channels only
2387 //
2388 // optional
2389 CanDeleteStories bool `json:"can_delete_stories,omitempty"`
2390 // CanManageTopics administrators and restricted only.
2391 // True, if the user is allowed to create, rename,
2392 // close, and reopen forum topics; supergroups only
2393 //
2394 // optional
2395 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2396 // IsMember is true, if the user is a member of the chat at the moment of
2397 // the request
2398 IsMember bool `json:"is_member"`
2399 // CanSendMessages
2400 //
2401 // optional
2402 CanSendMessages bool `json:"can_send_messages,omitempty"`
2403 // CanSendAudios restricted only.
2404 // True, if the user is allowed to send audios
2405 //
2406 // optional
2407 CanSendAudios bool
2408 // CanSendDocuments restricted only.
2409 // True, if the user is allowed to send documents
2410 //
2411 // optional
2412 CanSendDocuments bool
2413 // CanSendPhotos is restricted only.
2414 // True, if the user is allowed to send photos
2415 //
2416 // optional
2417 CanSendPhotos bool
2418 // CanSendVideos restricted only.
2419 // True, if the user is allowed to send videos
2420 //
2421 // optional
2422 CanSendVideos bool
2423 // CanSendVideoNotes restricted only.
2424 // True, if the user is allowed to send video notes
2425 //
2426 // optional
2427 CanSendVideoNotes bool
2428 // CanSendVoiceNotes restricted only.
2429 // True, if the user is allowed to send voice notes
2430 //
2431 // optional
2432 CanSendVoiceNotes bool
2433 // CanSendPolls restricted only.
2434 // True, if the user is allowed to send polls
2435 //
2436 // optional
2437 CanSendPolls bool `json:"can_send_polls,omitempty"`
2438 // CanSendOtherMessages restricted only.
2439 // True, if the user is allowed to send audios, documents,
2440 // photos, videos, video notes and voice notes.
2441 //
2442 // optional
2443 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2444 // CanAddWebPagePreviews restricted only.
2445 // True, if the user is allowed to add web page previews to their messages.
2446 //
2447 // optional
2448 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2449}
2450
2451// IsCreator returns if the ChatMember was the creator of the chat.
2452func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
2453
2454// IsAdministrator returns if the ChatMember is a chat administrator.
2455func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
2456
2457// HasLeft returns if the ChatMember left the chat.
2458func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
2459
2460// WasKicked returns if the ChatMember was kicked from the chat.
2461func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
2462
2463// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2464// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2465// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2466func (chat *ChatMember) SetCanSendMediaMessages(b bool) {
2467 chat.CanSendAudios = b
2468 chat.CanSendDocuments = b
2469 chat.CanSendPhotos = b
2470 chat.CanSendVideos = b
2471 chat.CanSendVideoNotes = b
2472 chat.CanSendVoiceNotes = b
2473}
2474
2475// CanSendMediaMessages method to replace field "can_send_media_messages".
2476// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2477// CanSendVideoNotes and CanSendVoiceNotes are true.
2478func (chat *ChatMember) CanSendMediaMessages() bool {
2479 return chat.CanSendAudios && chat.CanSendDocuments &&
2480 chat.CanSendPhotos && chat.CanSendVideos &&
2481 chat.CanSendVideoNotes && chat.CanSendVoiceNotes
2482}
2483
2484// ChatMemberUpdated represents changes in the status of a chat member.
2485type ChatMemberUpdated struct {
2486 // Chat the user belongs to.
2487 Chat Chat `json:"chat"`
2488 // From is the performer of the action, which resulted in the change.
2489 From User `json:"from"`
2490 // Date the change was done in Unix time.
2491 Date int `json:"date"`
2492 // Previous information about the chat member.
2493 OldChatMember ChatMember `json:"old_chat_member"`
2494 // New information about the chat member.
2495 NewChatMember ChatMember `json:"new_chat_member"`
2496 // InviteLink is the link which was used by the user to join the chat;
2497 // for joining by invite link events only.
2498 //
2499 // optional
2500 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2501 // ViaChatFolderInviteLink is True, if the user joined the chat
2502 // via a chat folder invite link
2503 //
2504 // optional
2505 ViaChatFolderInviteLink bool `json:"via_chat_folder_invite_link,omitempty"`
2506}
2507
2508// ChatJoinRequest represents a join request sent to a chat.
2509type ChatJoinRequest struct {
2510 // Chat to which the request was sent.
2511 Chat Chat `json:"chat"`
2512 // User that sent the join request.
2513 From User `json:"from"`
2514 // UserChatID identifier of a private chat with the user who sent the join request.
2515 UserChatID int64 `json:"user_chat_id"`
2516 // Date the request was sent in Unix time.
2517 Date int `json:"date"`
2518 // Bio of the user.
2519 //
2520 // optional
2521 Bio string `json:"bio,omitempty"`
2522 // InviteLink is the link that was used by the user to send the join request.
2523 //
2524 // optional
2525 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2526}
2527
2528// ChatPermissions describes actions that a non-administrator user is
2529// allowed to take in a chat. All fields are optional.
2530type ChatPermissions struct {
2531 // CanSendMessages is true, if the user is allowed to send text messages,
2532 // contacts, locations and venues
2533 //
2534 // optional
2535 CanSendMessages bool `json:"can_send_messages,omitempty"`
2536 // CanSendAudios is true, if the user is allowed to send audios
2537 //
2538 // optional
2539 CanSendAudios bool
2540 // CanSendDocuments is true, if the user is allowed to send documents
2541 //
2542 // optional
2543 CanSendDocuments bool
2544 // CanSendPhotos is true, if the user is allowed to send photos
2545 //
2546 // optional
2547 CanSendPhotos bool
2548 // CanSendVideos is true, if the user is allowed to send videos
2549 //
2550 // optional
2551 CanSendVideos bool
2552 // CanSendVideoNotes is true, if the user is allowed to send video notes
2553 //
2554 // optional
2555 CanSendVideoNotes bool
2556 // CanSendVoiceNotes is true, if the user is allowed to send voice notes
2557 //
2558 // optional
2559 CanSendVoiceNotes bool
2560 // CanSendPolls is true, if the user is allowed to send polls, implies
2561 // can_send_messages
2562 //
2563 // optional
2564 CanSendPolls bool `json:"can_send_polls,omitempty"`
2565 // CanSendOtherMessages is true, if the user is allowed to send animations,
2566 // games, stickers and use inline bots, implies can_send_media_messages
2567 //
2568 // optional
2569 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2570 // CanAddWebPagePreviews is true, if the user is allowed to add web page
2571 // previews to their messages, implies can_send_media_messages
2572 //
2573 // optional
2574 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2575 // CanChangeInfo is true, if the user is allowed to change the chat title,
2576 // photo and other settings. Ignored in public supergroups
2577 //
2578 // optional
2579 CanChangeInfo bool `json:"can_change_info,omitempty"`
2580 // CanInviteUsers is true, if the user is allowed to invite new users to the
2581 // chat
2582 //
2583 // optional
2584 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2585 // CanPinMessages is true, if the user is allowed to pin messages. Ignored
2586 // in public supergroups
2587 //
2588 // optional
2589 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2590 // CanManageTopics is true, if the user is allowed to create forum topics.
2591 // If omitted defaults to the value of can_pin_messages
2592 //
2593 // optional
2594 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2595}
2596
2597// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2598// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2599// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2600func (c *ChatPermissions) SetCanSendMediaMessages(b bool) {
2601 c.CanSendAudios = b
2602 c.CanSendDocuments = b
2603 c.CanSendPhotos = b
2604 c.CanSendVideos = b
2605 c.CanSendVideoNotes = b
2606 c.CanSendVoiceNotes = b
2607}
2608
2609// CanSendMediaMessages method to replace field "can_send_media_messages".
2610// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2611// CanSendVideoNotes and CanSendVoiceNotes are true.
2612func (c *ChatPermissions) CanSendMediaMessages() bool {
2613 return c.CanSendAudios && c.CanSendDocuments &&
2614 c.CanSendPhotos && c.CanSendVideos &&
2615 c.CanSendVideoNotes && c.CanSendVoiceNotes
2616}
2617
2618// ChatLocation represents a location to which a chat is connected.
2619type ChatLocation struct {
2620 // Location is the location to which the supergroup is connected. Can't be a
2621 // live location.
2622 Location Location `json:"location"`
2623 // Address is the location address; 1-64 characters, as defined by the chat
2624 // owner
2625 Address string `json:"address"`
2626}
2627
2628const (
2629 ReactionTypeEmoji = "emoji"
2630 ReactionTypeCustomEmoji = "custom_emoji"
2631)
2632
2633// ReactionType describes the type of a reaction. Currently, it can be one of: "emoji", "custom_emoji"
2634type ReactionType struct {
2635 // Type of the reaction. Can be "emoji", "custom_emoji"
2636 Type string `json:"type"`
2637 // Emoji type "emoji" only. Is a reaction emoji.
2638 Emoji string `json:"emoji"`
2639 // CustomEmoji type "custom_emoji" only. Is a custom emoji identifier.
2640 CustomEmoji string `json:"custom_emoji"`
2641}
2642
2643func (r ReactionType) IsEmoji() bool {
2644 return r.Type == ReactionTypeEmoji
2645}
2646
2647func (r ReactionType) IsCustomEmoji() bool {
2648 return r.Type == ReactionTypeCustomEmoji
2649}
2650
2651// ReactionCount represents a reaction added to a message along with the number of times it was added.
2652type ReactionCount struct {
2653 // Type of the reaction
2654 Type ReactionType `json:"type"`
2655 // TotalCount number of times the reaction was added
2656 TotalCount int `json:"total_count"`
2657}
2658
2659// MessageReactionUpdated represents a change of a reaction on a message performed by a user.
2660type MessageReactionUpdated struct {
2661 // Chat containing the message the user reacted to.
2662 Chat Chat `json:"chat"`
2663 // MessageID unique identifier of the message inside the chat.
2664 MessageID int `json:"message_id"`
2665 // User that changed the reaction, if the user isn't anonymous.
2666 //
2667 // optional
2668 User *User `json:"user"`
2669 // ActorChat the chat on behalf of which the reaction was changed,
2670 // if the user is anonymous.
2671 //
2672 // optional
2673 ActorChat *Chat `json:"actor_chat"`
2674 // Date of the change in Unix time.
2675 Date int64 `json:"date"`
2676 // OldReaction is a previous list of reaction types that were set by the user.
2677 OldReaction []ReactionType `json:"old_reaction"`
2678 // NewReaction is a new list of reaction types that have been set by the user.
2679 NewReaction []ReactionType `json:"new_reaction"`
2680}
2681
2682// MessageReactionCountUpdated represents reaction changes on a message with anonymous reactions.
2683type MessageReactionCountUpdated struct {
2684 // Chat containing the message.
2685 Chat Chat `json:"chat"`
2686 // MessageID unique identifier of the message inside the chat.
2687 MessageID int `json:"message_id"`
2688 // Date of the change in Unix time.
2689 Date int64 `json:"date"`
2690 // Reactions is a list of reactions that are present on the message.
2691 Reactions []ReactionCount `json:"reactions"`
2692}
2693
2694// ForumTopic represents a forum topic.
2695type ForumTopic struct {
2696 // MessageThreadID is the unique identifier of the forum topic
2697 MessageThreadID int `json:"message_thread_id"`
2698 // Name is the name of the topic
2699 Name string `json:"name"`
2700 // IconColor is the color of the topic icon in RGB format
2701 IconColor int `json:"icon_color"`
2702 // IconCustomEmojiID is the unique identifier of the custom emoji
2703 // shown as the topic icon
2704 //
2705 // optional
2706 IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
2707}
2708
2709// BotCommand represents a bot command.
2710type BotCommand struct {
2711 // Command text of the command, 1-32 characters.
2712 // Can contain only lowercase English letters, digits and underscores.
2713 Command string `json:"command"`
2714 // Description of the command, 3-256 characters.
2715 Description string `json:"description"`
2716}
2717
2718// BotCommandScope represents the scope to which bot commands are applied.
2719//
2720// It contains the fields for all types of scopes, different types only support
2721// specific (or no) fields.
2722type BotCommandScope struct {
2723 Type string `json:"type"`
2724 ChatID int64 `json:"chat_id,omitempty"`
2725 UserID int64 `json:"user_id,omitempty"`
2726}
2727
2728// BotName represents the bot's name.
2729type BotName struct {
2730 Name string `json:"name"`
2731}
2732
2733// BotDescription represents the bot's description.
2734type BotDescription struct {
2735 Description string `json:"description"`
2736}
2737
2738// BotShortDescription represents the bot's short description
2739type BotShortDescription struct {
2740 ShortDescription string `json:"short_description"`
2741}
2742
2743// MenuButton describes the bot's menu button in a private chat.
2744type MenuButton struct {
2745 // Type is the type of menu button, must be one of:
2746 // - `commands`
2747 // - `web_app`
2748 // - `default`
2749 Type string `json:"type"`
2750 // Text is the text on the button, for `web_app` type.
2751 Text string `json:"text,omitempty"`
2752 // WebApp is the description of the Web App that will be launched when the
2753 // user presses the button for the `web_app` type.
2754 WebApp *WebAppInfo `json:"web_app,omitempty"`
2755}
2756
2757const (
2758 ChatBoostSourcePremium = "premium"
2759 ChatBoostSourceGiftCode = "gift_code"
2760 ChatBoostSourceGiveaway = "giveaway"
2761)
2762
2763// ChatBoostSource describes the source of a chat boost
2764type ChatBoostSource struct {
2765 // Source of the boost, It can be one of:
2766 // "premium", "gift_code", "giveaway"
2767 Source string `json:"source"`
2768 // For "premium": User that boosted the chat
2769 // For "gift_code": User for which the gift code was created
2770 // Optional for "giveaway": User that won the prize in the giveaway if any
2771 User *User `json:"user,omitempty"`
2772 // GiveawayMessageID "giveaway" only.
2773 // Is an identifier of a message in the chat with the giveaway;
2774 // the message could have been deleted already. May be 0 if the message isn't sent yet.
2775 GiveawayMessageID int `json:"giveaway_message_id,omitempty"`
2776 // IsUnclaimed "giveaway" only.
2777 // True, if the giveaway was completed, but there was no user to win the prize
2778 //
2779 // optional
2780 IsUnclaimed bool `json:"is_unclaimed,omitempty"`
2781}
2782
2783func (c ChatBoostSource) IsPremium() bool {
2784 return c.Source == ChatBoostSourcePremium
2785}
2786
2787func (c ChatBoostSource) IsGiftCode() bool {
2788 return c.Source == ChatBoostSourceGiftCode
2789}
2790
2791func (c ChatBoostSource) IsGiveaway() bool {
2792 return c.Source == ChatBoostSourceGiveaway
2793}
2794
2795// ChatBoost contains information about a chat boost.
2796type ChatBoost struct {
2797 // BoostID is an unique identifier of the boost
2798 BoostID string `json:"boost_id"`
2799 // AddDate is a point in time (Unix timestamp) when the chat was boosted
2800 AddDate int64 `json:"add_date"`
2801 // ExpirationDate is a point in time (Unix timestamp) when the boost will
2802 // automatically expire, unless the booster's Telegram Premium subscription is prolonged
2803 ExpirationDate int64 `json:"expiration_date"`
2804 // Source of the added boost
2805 Source ChatBoostSource `json:"source"`
2806}
2807
2808// ChatBoostUpdated represents a boost added to a chat or changed.
2809type ChatBoostUpdated struct {
2810 // Chat which was boosted
2811 Chat Chat `json:"chat"`
2812 // Boost infomation about the chat boost
2813 Boost ChatBoost `json:"boost"`
2814}
2815
2816// ChatBoostRemoved represents a boost removed from a chat.
2817type ChatBoostRemoved struct {
2818 // Chat which was boosted
2819 Chat Chat `json:"chat"`
2820 // BoostID unique identifier of the boost
2821 BoostID string `json:"boost_id"`
2822 // RemoveDate point in time (Unix timestamp) when the boost was removed
2823 RemoveDate int64 `json:"remove_date"`
2824 // Source of the removed boost
2825 Source ChatBoostSource `json:"source"`
2826}
2827
2828// UserChatBoosts represents a list of boosts added to a chat by a user.
2829type UserChatBoosts struct {
2830 // Boosts is the list of boosts added to the chat by the user
2831 Boosts []ChatBoost `json:"boosts"`
2832}
2833
2834// ResponseParameters are various errors that can be returned in APIResponse.
2835type ResponseParameters struct {
2836 // The group has been migrated to a supergroup with the specified identifier.
2837 //
2838 // optional
2839 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
2840 // In case of exceeding flood control, the number of seconds left to wait
2841 // before the request can be repeated.
2842 //
2843 // optional
2844 RetryAfter int `json:"retry_after,omitempty"`
2845}
2846
2847// BaseInputMedia is a base type for the InputMedia types.
2848type BaseInputMedia struct {
2849 // Type of the result.
2850 Type string `json:"type"`
2851 // Media file to send. Pass a file_id to send a file
2852 // that exists on the Telegram servers (recommended),
2853 // pass an HTTP URL for Telegram to get a file from the Internet,
2854 // or pass “attach://<file_attach_name>” to upload a new one
2855 // using multipart/form-data under <file_attach_name> name.
2856 Media RequestFileData `json:"media"`
2857 // thumb intentionally missing as it is not currently compatible
2858
2859 // Caption of the video to be sent, 0-1024 characters after entities parsing.
2860 //
2861 // optional
2862 Caption string `json:"caption,omitempty"`
2863 // ParseMode mode for parsing entities in the video caption.
2864 // See formatting options for more details
2865 // (https://core.telegram.org/bots/api#formatting-options).
2866 //
2867 // optional
2868 ParseMode string `json:"parse_mode,omitempty"`
2869 // CaptionEntities is a list of special entities that appear in the caption,
2870 // which can be specified instead of parse_mode
2871 //
2872 // optional
2873 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
2874 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
2875 //
2876 // optional
2877 HasSpoiler bool `json:"has_spoiler,omitempty"`
2878}
2879
2880// InputMediaPhoto is a photo to send as part of a media group.
2881type InputMediaPhoto struct {
2882 BaseInputMedia
2883}
2884
2885// InputMediaVideo is a video to send as part of a media group.
2886type InputMediaVideo struct {
2887 BaseInputMedia
2888 // Thumbnail of the file sent; can be ignored if thumbnail generation for
2889 // the file is supported server-side.
2890 //
2891 // optional
2892 Thumb RequestFileData `json:"thumbnail,omitempty"`
2893 // Width video width
2894 //
2895 // optional
2896 Width int `json:"width,omitempty"`
2897 // Height video height
2898 //
2899 // optional
2900 Height int `json:"height,omitempty"`
2901 // Duration video duration
2902 //
2903 // optional
2904 Duration int `json:"duration,omitempty"`
2905 // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
2906 //
2907 // optional
2908 SupportsStreaming bool `json:"supports_streaming,omitempty"`
2909 // HasSpoiler pass True, if the video needs to be covered with a spoiler animation
2910 //
2911 // optional
2912 HasSpoiler bool `json:"has_spoiler,omitempty"`
2913}
2914
2915// InputMediaAnimation is an animation to send as part of a media group.
2916type InputMediaAnimation struct {
2917 BaseInputMedia
2918 // Thumbnail of the file sent; can be ignored if thumbnail generation for
2919 // the file is supported server-side.
2920 //
2921 // optional
2922 Thumb RequestFileData `json:"thumbnail,omitempty"`
2923 // Width video width
2924 //
2925 // optional
2926 Width int `json:"width,omitempty"`
2927 // Height video height
2928 //
2929 // optional
2930 Height int `json:"height,omitempty"`
2931 // Duration video duration
2932 //
2933 // optional
2934 Duration int `json:"duration,omitempty"`
2935 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
2936 //
2937 // optional
2938 HasSpoiler bool `json:"has_spoiler,omitempty"`
2939}
2940
2941// InputMediaAudio is an audio to send as part of a media group.
2942type InputMediaAudio struct {
2943 BaseInputMedia
2944 // Thumbnail of the file sent; can be ignored if thumbnail generation for
2945 // the file is supported server-side.
2946 //
2947 // optional
2948 Thumb RequestFileData `json:"thumbnail,omitempty"`
2949 // Duration of the audio in seconds
2950 //
2951 // optional
2952 Duration int `json:"duration,omitempty"`
2953 // Performer of the audio
2954 //
2955 // optional
2956 Performer string `json:"performer,omitempty"`
2957 // Title of the audio
2958 //
2959 // optional
2960 Title string `json:"title,omitempty"`
2961}
2962
2963// InputMediaDocument is a general file to send as part of a media group.
2964type InputMediaDocument struct {
2965 BaseInputMedia
2966 // Thumbnail of the file sent; can be ignored if thumbnail generation for
2967 // the file is supported server-side.
2968 //
2969 // optional
2970 Thumb RequestFileData `json:"thumbnail,omitempty"`
2971 // DisableContentTypeDetection disables automatic server-side content type
2972 // detection for files uploaded using multipart/form-data. Always true, if
2973 // the document is sent as part of an album
2974 //
2975 // optional
2976 DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
2977}
2978
2979// Constant values for sticker types
2980const (
2981 StickerTypeRegular = "regular"
2982 StickerTypeMask = "mask"
2983 StickerTypeCustomEmoji = "custom_emoji"
2984)
2985
2986// Sticker represents a sticker.
2987type Sticker struct {
2988 // FileID is an identifier for this file, which can be used to download or
2989 // reuse the file
2990 FileID string `json:"file_id"`
2991 // FileUniqueID is a unique identifier for this file,
2992 // which is supposed to be the same over time and for different bots.
2993 // Can't be used to download or reuse the file.
2994 FileUniqueID string `json:"file_unique_id"`
2995 // Type is a type of the sticker, currently one of “regular”,
2996 // “mask”, “custom_emoji”. The type of the sticker is independent
2997 // from its format, which is determined by the fields is_animated and is_video.
2998 Type string `json:"type"`
2999 // Width sticker width
3000 Width int `json:"width"`
3001 // Height sticker height
3002 Height int `json:"height"`
3003 // IsAnimated true, if the sticker is animated
3004 //
3005 // optional
3006 IsAnimated bool `json:"is_animated,omitempty"`
3007 // IsVideo true, if the sticker is a video sticker
3008 //
3009 // optional
3010 IsVideo bool `json:"is_video,omitempty"`
3011 // Thumbnail sticker thumbnail in the .WEBP or .JPG format
3012 //
3013 // optional
3014 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
3015 // Emoji associated with the sticker
3016 //
3017 // optional
3018 Emoji string `json:"emoji,omitempty"`
3019 // SetName of the sticker set to which the sticker belongs
3020 //
3021 // optional
3022 SetName string `json:"set_name,omitempty"`
3023 // PremiumAnimation for premium regular stickers, premium animation for the sticker
3024 //
3025 // optional
3026 PremiumAnimation *File `json:"premium_animation,omitempty"`
3027 // MaskPosition is for mask stickers, the position where the mask should be
3028 // placed
3029 //
3030 // optional
3031 MaskPosition *MaskPosition `json:"mask_position,omitempty"`
3032 // CustomEmojiID for custom emoji stickers, unique identifier of the custom emoji
3033 //
3034 // optional
3035 CustomEmojiID string `json:"custom_emoji_id,omitempty"`
3036 // NeedsRepainting True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places
3037 //
3038 //optional
3039 NeedsRepainting bool `json:"needs_reainting,omitempty"`
3040 // FileSize
3041 //
3042 // optional
3043 FileSize int `json:"file_size,omitempty"`
3044}
3045
3046// IsRegular returns if the Sticker is regular
3047func (s Sticker) IsRegular() bool {
3048 return s.Type == StickerTypeRegular
3049}
3050
3051// IsMask returns if the Sticker is mask
3052func (s Sticker) IsMask() bool {
3053 return s.Type == StickerTypeMask
3054}
3055
3056// IsCustomEmoji returns if the Sticker is custom emoji
3057func (s Sticker) IsCustomEmoji() bool {
3058 return s.Type == StickerTypeCustomEmoji
3059}
3060
3061// StickerSet represents a sticker set.
3062type StickerSet struct {
3063 // Name sticker set name
3064 Name string `json:"name"`
3065 // Title sticker set title
3066 Title string `json:"title"`
3067 // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
3068 StickerType string `json:"sticker_type"`
3069 // IsAnimated true, if the sticker set contains animated stickers
3070 IsAnimated bool `json:"is_animated"`
3071 // IsVideo true, if the sticker set contains video stickers
3072 IsVideo bool `json:"is_video"`
3073 // ContainsMasks true, if the sticker set contains masks
3074 //
3075 // deprecated. Use sticker_type instead
3076 ContainsMasks bool `json:"contains_masks"`
3077 // Stickers list of all set stickers
3078 Stickers []Sticker `json:"stickers"`
3079 // Thumb is the sticker set thumbnail in the .WEBP or .TGS format
3080 Thumbnail *PhotoSize `json:"thumbnail"`
3081}
3082
3083// IsRegular returns if the StickerSet is regular
3084func (s StickerSet) IsRegular() bool {
3085 return s.StickerType == StickerTypeRegular
3086}
3087
3088// IsMask returns if the StickerSet is mask
3089func (s StickerSet) IsMask() bool {
3090 return s.StickerType == StickerTypeMask
3091}
3092
3093// IsCustomEmoji returns if the StickerSet is custom emoji
3094func (s StickerSet) IsCustomEmoji() bool {
3095 return s.StickerType == StickerTypeCustomEmoji
3096}
3097
3098// MaskPosition describes the position on faces where a mask should be placed
3099// by default.
3100type MaskPosition struct {
3101 // The part of the face relative to which the mask should be placed.
3102 // One of “forehead”, “eyes”, “mouth”, or “chin”.
3103 Point string `json:"point"`
3104 // Shift by X-axis measured in widths of the mask scaled to the face size,
3105 // from left to right. For example, choosing -1.0 will place mask just to
3106 // the left of the default mask position.
3107 XShift float64 `json:"x_shift"`
3108 // Shift by Y-axis measured in heights of the mask scaled to the face size,
3109 // from top to bottom. For example, 1.0 will place the mask just below the
3110 // default mask position.
3111 YShift float64 `json:"y_shift"`
3112 // Mask scaling coefficient. For example, 2.0 means double size.
3113 Scale float64 `json:"scale"`
3114}
3115
3116// InputSticker describes a sticker to be added to a sticker set.
3117type InputSticker struct {
3118 // The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL.
3119 Sticker RequestFile `json:"sticker"`
3120 // List of 1-20 emoji associated with the sticker
3121 EmojiList []string `json:"emoji_list"`
3122 // Position where the mask should be placed on faces. For “mask” stickers only.
3123 //
3124 // optional
3125 MaskPosition *MaskPosition `json:"mask_position"`
3126 // List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only.
3127 //
3128 // optional
3129 Keywords []string `json:"keywords"`
3130}
3131
3132// Game represents a game. Use BotFather to create and edit games, their short
3133// names will act as unique identifiers.
3134type Game struct {
3135 // Title of the game
3136 Title string `json:"title"`
3137 // Description of the game
3138 Description string `json:"description"`
3139 // Photo that will be displayed in the game message in chats.
3140 Photo []PhotoSize `json:"photo"`
3141 // Text a brief description of the game or high scores included in the game message.
3142 // Can be automatically edited to include current high scores for the game
3143 // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
3144 //
3145 // optional
3146 Text string `json:"text,omitempty"`
3147 // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
3148 //
3149 // optional
3150 TextEntities []MessageEntity `json:"text_entities,omitempty"`
3151 // Animation is an animation that will be displayed in the game message in chats.
3152 // Upload via BotFather (https://t.me/botfather).
3153 //
3154 // optional
3155 Animation Animation `json:"animation,omitempty"`
3156}
3157
3158// GameHighScore is a user's score and position on the leaderboard.
3159type GameHighScore struct {
3160 // Position in high score table for the game
3161 Position int `json:"position"`
3162 // User user
3163 User User `json:"user"`
3164 // Score score
3165 Score int `json:"score"`
3166}
3167
3168// CallbackGame is for starting a game in an inline keyboard button.
3169type CallbackGame struct{}
3170
3171// SwitchInlineQueryChosenChat represents an inline button that switches the current
3172// user to inline mode in a chosen chat, with an optional default inline query.
3173type SwitchInlineQueryChosenChat struct {
3174 // Query is default inline query to be inserted in the input field.
3175 // If left empty, only the bot's username will be inserted
3176 //
3177 // optional
3178 Query string `json:"query,omitempty"`
3179 // AllowUserChats is True, if private chats with users can be chosen
3180 //
3181 // optional
3182 AllowUserChats bool `json:"allow_user_chats,omitempty"`
3183 // AllowBotChats is True, if private chats with bots can be chosen
3184 //
3185 // optional
3186 AllowBotChats bool `json:"allow_bot_chats,omitempty"`
3187 // AllowGroupChats is True, if group and supergroup chats can be chosen
3188 //
3189 // optional
3190 AllowGroupChats bool `json:"allow_group_chats,omitempty"`
3191 // AllowChannelChats is True, if channel chats can be chosen
3192 //
3193 // optional
3194 AllowChannelChats bool `json:"allow_channel_chats,omitempty"`
3195}
3196
3197// WebhookInfo is information about a currently set webhook.
3198type WebhookInfo struct {
3199 // URL webhook URL, may be empty if webhook is not set up.
3200 URL string `json:"url"`
3201 // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
3202 HasCustomCertificate bool `json:"has_custom_certificate"`
3203 // PendingUpdateCount number of updates awaiting delivery.
3204 PendingUpdateCount int `json:"pending_update_count"`
3205 // IPAddress is the currently used webhook IP address
3206 //
3207 // optional
3208 IPAddress string `json:"ip_address,omitempty"`
3209 // LastErrorDate unix time for the most recent error
3210 // that happened when trying to deliver an update via webhook.
3211 //
3212 // optional
3213 LastErrorDate int `json:"last_error_date,omitempty"`
3214 // LastErrorMessage error message in human-readable format for the most recent error
3215 // that happened when trying to deliver an update via webhook.
3216 //
3217 // optional
3218 LastErrorMessage string `json:"last_error_message,omitempty"`
3219 // LastSynchronizationErrorDate is the unix time of the most recent error that
3220 // happened when trying to synchronize available updates with Telegram datacenters.
3221 LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
3222 // MaxConnections maximum allowed number of simultaneous
3223 // HTTPS connections to the webhook for update delivery.
3224 //
3225 // optional
3226 MaxConnections int `json:"max_connections,omitempty"`
3227 // AllowedUpdates is a list of update types the bot is subscribed to.
3228 // Defaults to all update types
3229 //
3230 // optional
3231 AllowedUpdates []string `json:"allowed_updates,omitempty"`
3232}
3233
3234// IsSet returns true if a webhook is currently set.
3235func (info WebhookInfo) IsSet() bool {
3236 return info.URL != ""
3237}
3238
3239// InlineQuery is a Query from Telegram for an inline request.
3240type InlineQuery struct {
3241 // ID unique identifier for this query
3242 ID string `json:"id"`
3243 // From sender
3244 From *User `json:"from"`
3245 // Query text of the query (up to 256 characters).
3246 Query string `json:"query"`
3247 // Offset of the results to be returned, can be controlled by the bot.
3248 Offset string `json:"offset"`
3249 // Type of the chat, from which the inline query was sent. Can be either
3250 // “sender” for a private chat with the inline query sender, “private”,
3251 // “group”, “supergroup”, or “channel”. The chat type should be always known
3252 // for requests sent from official clients and most third-party clients,
3253 // unless the request was sent from a secret chat
3254 //
3255 // optional
3256 ChatType string `json:"chat_type,omitempty"`
3257 // Location sender location, only for bots that request user location.
3258 //
3259 // optional
3260 Location *Location `json:"location,omitempty"`
3261}
3262
3263// InlineQueryResultCachedAudio is an inline query response with cached audio.
3264type InlineQueryResultCachedAudio struct {
3265 // Type of the result, must be audio
3266 Type string `json:"type"`
3267 // ID unique identifier for this result, 1-64 bytes
3268 ID string `json:"id"`
3269 // AudioID a valid file identifier for the audio file
3270 AudioID string `json:"audio_file_id"`
3271 // Caption 0-1024 characters after entities parsing
3272 //
3273 // optional
3274 Caption string `json:"caption,omitempty"`
3275 // ParseMode mode for parsing entities in the video caption.
3276 // See formatting options for more details
3277 // (https://core.telegram.org/bots/api#formatting-options).
3278 //
3279 // optional
3280 ParseMode string `json:"parse_mode,omitempty"`
3281 // CaptionEntities is a list of special entities that appear in the caption,
3282 // which can be specified instead of parse_mode
3283 //
3284 // optional
3285 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3286 // ReplyMarkup inline keyboard attached to the message
3287 //
3288 // optional
3289 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3290 // InputMessageContent content of the message to be sent instead of the audio
3291 //
3292 // optional
3293 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3294}
3295
3296// InlineQueryResultCachedDocument is an inline query response with cached document.
3297type InlineQueryResultCachedDocument struct {
3298 // Type of the result, must be a document
3299 Type string `json:"type"`
3300 // ID unique identifier for this result, 1-64 bytes
3301 ID string `json:"id"`
3302 // DocumentID a valid file identifier for the file
3303 DocumentID string `json:"document_file_id"`
3304 // Title for the result
3305 //
3306 // optional
3307 Title string `json:"title,omitempty"`
3308 // Caption of the document to be sent, 0-1024 characters after entities parsing
3309 //
3310 // optional
3311 Caption string `json:"caption,omitempty"`
3312 // Description short description of the result
3313 //
3314 // optional
3315 Description string `json:"description,omitempty"`
3316 // ParseMode mode for parsing entities in the video caption.
3317 // // See formatting options for more details
3318 // // (https://core.telegram.org/bots/api#formatting-options).
3319 //
3320 // optional
3321 ParseMode string `json:"parse_mode,omitempty"`
3322 // CaptionEntities is a list of special entities that appear in the caption,
3323 // which can be specified instead of parse_mode
3324 //
3325 // optional
3326 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3327 // ReplyMarkup inline keyboard attached to the message
3328 //
3329 // optional
3330 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3331 // InputMessageContent content of the message to be sent instead of the file
3332 //
3333 // optional
3334 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3335}
3336
3337// InlineQueryResultCachedGIF is an inline query response with cached gif.
3338type InlineQueryResultCachedGIF struct {
3339 // Type of the result, must be gif.
3340 Type string `json:"type"`
3341 // ID unique identifier for this result, 1-64 bytes.
3342 ID string `json:"id"`
3343 // GifID a valid file identifier for the GIF file.
3344 GIFID string `json:"gif_file_id"`
3345 // Title for the result
3346 //
3347 // optional
3348 Title string `json:"title,omitempty"`
3349 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
3350 //
3351 // optional
3352 Caption string `json:"caption,omitempty"`
3353 // ParseMode mode for parsing entities in the caption.
3354 // See formatting options for more details
3355 // (https://core.telegram.org/bots/api#formatting-options).
3356 //
3357 // optional
3358 ParseMode string `json:"parse_mode,omitempty"`
3359 // CaptionEntities is a list of special entities that appear in the caption,
3360 // which can be specified instead of parse_mode
3361 //
3362 // optional
3363 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3364 // ReplyMarkup inline keyboard attached to the message.
3365 //
3366 // optional
3367 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3368 // InputMessageContent content of the message to be sent instead of the GIF animation.
3369 //
3370 // optional
3371 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3372}
3373
3374// InlineQueryResultCachedMPEG4GIF is an inline query response with cached
3375// H.264/MPEG-4 AVC video without sound gif.
3376type InlineQueryResultCachedMPEG4GIF struct {
3377 // Type of the result, must be mpeg4_gif
3378 Type string `json:"type"`
3379 // ID unique identifier for this result, 1-64 bytes
3380 ID string `json:"id"`
3381 // MPEG4FileID a valid file identifier for the MP4 file
3382 MPEG4FileID string `json:"mpeg4_file_id"`
3383 // Title for the result
3384 //
3385 // optional
3386 Title string `json:"title,omitempty"`
3387 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
3388 //
3389 // optional
3390 Caption string `json:"caption,omitempty"`
3391 // ParseMode mode for parsing entities in the caption.
3392 // See formatting options for more details
3393 // (https://core.telegram.org/bots/api#formatting-options).
3394 //
3395 // optional
3396 ParseMode string `json:"parse_mode,omitempty"`
3397 // ParseMode mode for parsing entities in the video caption.
3398 // See formatting options for more details
3399 // (https://core.telegram.org/bots/api#formatting-options).
3400 //
3401 // optional
3402 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3403 // ReplyMarkup inline keyboard attached to the message.
3404 //
3405 // optional
3406 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3407 // InputMessageContent content of the message to be sent instead of the video animation.
3408 //
3409 // optional
3410 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3411}
3412
3413// InlineQueryResultCachedPhoto is an inline query response with cached photo.
3414type InlineQueryResultCachedPhoto struct {
3415 // Type of the result, must be a photo.
3416 Type string `json:"type"`
3417 // ID unique identifier for this result, 1-64 bytes.
3418 ID string `json:"id"`
3419 // PhotoID a valid file identifier of the photo.
3420 PhotoID string `json:"photo_file_id"`
3421 // Title for the result.
3422 //
3423 // optional
3424 Title string `json:"title,omitempty"`
3425 // Description short description of the result.
3426 //
3427 // optional
3428 Description string `json:"description,omitempty"`
3429 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
3430 //
3431 // optional
3432 Caption string `json:"caption,omitempty"`
3433 // ParseMode mode for parsing entities in the photo caption.
3434 // See formatting options for more details
3435 // (https://core.telegram.org/bots/api#formatting-options).
3436 //
3437 // optional
3438 ParseMode string `json:"parse_mode,omitempty"`
3439 // CaptionEntities is a list of special entities that appear in the caption,
3440 // which can be specified instead of parse_mode
3441 //
3442 // optional
3443 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3444 // ReplyMarkup inline keyboard attached to the message.
3445 //
3446 // optional
3447 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3448 // InputMessageContent content of the message to be sent instead of the photo.
3449 //
3450 // optional
3451 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3452}
3453
3454// InlineQueryResultCachedSticker is an inline query response with cached sticker.
3455type InlineQueryResultCachedSticker struct {
3456 // Type of the result, must be a sticker
3457 Type string `json:"type"`
3458 // ID unique identifier for this result, 1-64 bytes
3459 ID string `json:"id"`
3460 // StickerID a valid file identifier of the sticker
3461 StickerID string `json:"sticker_file_id"`
3462 // Title is a title
3463 Title string `json:"title"`
3464 // ReplyMarkup inline keyboard attached to the message
3465 //
3466 // optional
3467 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3468 // InputMessageContent content of the message to be sent instead of the sticker
3469 //
3470 // optional
3471 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3472}
3473
3474// InlineQueryResultCachedVideo is an inline query response with cached video.
3475type InlineQueryResultCachedVideo struct {
3476 // Type of the result, must be video
3477 Type string `json:"type"`
3478 // ID unique identifier for this result, 1-64 bytes
3479 ID string `json:"id"`
3480 // VideoID a valid file identifier for the video file
3481 VideoID string `json:"video_file_id"`
3482 // Title for the result
3483 Title string `json:"title"`
3484 // Description short description of the result
3485 //
3486 // optional
3487 Description string `json:"description,omitempty"`
3488 // Caption of the video to be sent, 0-1024 characters after entities parsing
3489 //
3490 // optional
3491 Caption string `json:"caption,omitempty"`
3492 // ParseMode mode for parsing entities in the video caption.
3493 // See formatting options for more details
3494 // (https://core.telegram.org/bots/api#formatting-options).
3495 //
3496 // optional
3497 ParseMode string `json:"parse_mode,omitempty"`
3498 // CaptionEntities is a list of special entities that appear in the caption,
3499 // which can be specified instead of parse_mode
3500 //
3501 // optional
3502 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3503 // ReplyMarkup inline keyboard attached to the message
3504 //
3505 // optional
3506 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3507 // InputMessageContent content of the message to be sent instead of the video
3508 //
3509 // optional
3510 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3511}
3512
3513// InlineQueryResultCachedVoice is an inline query response with cached voice.
3514type InlineQueryResultCachedVoice struct {
3515 // Type of the result, must be voice
3516 Type string `json:"type"`
3517 // ID unique identifier for this result, 1-64 bytes
3518 ID string `json:"id"`
3519 // VoiceID a valid file identifier for the voice message
3520 VoiceID string `json:"voice_file_id"`
3521 // Title voice message title
3522 Title string `json:"title"`
3523 // Caption 0-1024 characters after entities parsing
3524 //
3525 // optional
3526 Caption string `json:"caption,omitempty"`
3527 // ParseMode mode for parsing entities in the video caption.
3528 // See formatting options for more details
3529 // (https://core.telegram.org/bots/api#formatting-options).
3530 //
3531 // optional
3532 ParseMode string `json:"parse_mode,omitempty"`
3533 // CaptionEntities is a list of special entities that appear in the caption,
3534 // which can be specified instead of parse_mode
3535 //
3536 // optional
3537 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3538 // ReplyMarkup inline keyboard attached to the message
3539 //
3540 // optional
3541 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3542 // InputMessageContent content of the message to be sent instead of the voice message
3543 //
3544 // optional
3545 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3546}
3547
3548// InlineQueryResultArticle represents a link to an article or web page.
3549type InlineQueryResultArticle struct {
3550 // Type of the result, must be article.
3551 Type string `json:"type"`
3552 // ID unique identifier for this result, 1-64 Bytes.
3553 ID string `json:"id"`
3554 // Title of the result
3555 Title string `json:"title"`
3556 // InputMessageContent content of the message to be sent.
3557 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3558 // ReplyMarkup Inline keyboard attached to the message.
3559 //
3560 // optional
3561 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3562 // URL of the result.
3563 //
3564 // optional
3565 URL string `json:"url,omitempty"`
3566 // HideURL pass True, if you don't want the URL to be shown in the message.
3567 //
3568 // optional
3569 HideURL bool `json:"hide_url,omitempty"`
3570 // Description short description of the result.
3571 //
3572 // optional
3573 Description string `json:"description,omitempty"`
3574 // ThumbURL url of the thumbnail for the result
3575 //
3576 // optional
3577 ThumbURL string `json:"thumbnail_url,omitempty"`
3578 // ThumbWidth thumbnail width
3579 //
3580 // optional
3581 ThumbWidth int `json:"thumbnail_width,omitempty"`
3582 // ThumbHeight thumbnail height
3583 //
3584 // optional
3585 ThumbHeight int `json:"thumbnail_height,omitempty"`
3586}
3587
3588// InlineQueryResultAudio is an inline query response audio.
3589type InlineQueryResultAudio struct {
3590 // Type of the result, must be audio
3591 Type string `json:"type"`
3592 // ID unique identifier for this result, 1-64 bytes
3593 ID string `json:"id"`
3594 // URL a valid url for the audio file
3595 URL string `json:"audio_url"`
3596 // Title is a title
3597 Title string `json:"title"`
3598 // Caption 0-1024 characters after entities parsing
3599 //
3600 // optional
3601 Caption string `json:"caption,omitempty"`
3602 // ParseMode mode for parsing entities in the video caption.
3603 // See formatting options for more details
3604 // (https://core.telegram.org/bots/api#formatting-options).
3605 //
3606 // optional
3607 ParseMode string `json:"parse_mode,omitempty"`
3608 // CaptionEntities is a list of special entities that appear in the caption,
3609 // which can be specified instead of parse_mode
3610 //
3611 // optional
3612 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3613 // Performer is a performer
3614 //
3615 // optional
3616 Performer string `json:"performer,omitempty"`
3617 // Duration audio duration in seconds
3618 //
3619 // optional
3620 Duration int `json:"audio_duration,omitempty"`
3621 // ReplyMarkup inline keyboard attached to the message
3622 //
3623 // optional
3624 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3625 // InputMessageContent content of the message to be sent instead of the audio
3626 //
3627 // optional
3628 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3629}
3630
3631// InlineQueryResultContact is an inline query response contact.
3632type InlineQueryResultContact struct {
3633 Type string `json:"type"` // required
3634 ID string `json:"id"` // required
3635 PhoneNumber string `json:"phone_number"` // required
3636 FirstName string `json:"first_name"` // required
3637 LastName string `json:"last_name"`
3638 VCard string `json:"vcard"`
3639 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3640 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3641 ThumbURL string `json:"thumbnail_url"`
3642 ThumbWidth int `json:"thumbnail_width"`
3643 ThumbHeight int `json:"thumbnail_height"`
3644}
3645
3646// InlineQueryResultGame is an inline query response game.
3647type InlineQueryResultGame struct {
3648 // Type of the result, must be game
3649 Type string `json:"type"`
3650 // ID unique identifier for this result, 1-64 bytes
3651 ID string `json:"id"`
3652 // GameShortName short name of the game
3653 GameShortName string `json:"game_short_name"`
3654 // ReplyMarkup inline keyboard attached to the message
3655 //
3656 // optional
3657 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3658}
3659
3660// InlineQueryResultDocument is an inline query response document.
3661type InlineQueryResultDocument struct {
3662 // Type of the result, must be a document
3663 Type string `json:"type"`
3664 // ID unique identifier for this result, 1-64 bytes
3665 ID string `json:"id"`
3666 // Title for the result
3667 Title string `json:"title"`
3668 // Caption of the document to be sent, 0-1024 characters after entities parsing
3669 //
3670 // optional
3671 Caption string `json:"caption,omitempty"`
3672 // URL a valid url for the file
3673 URL string `json:"document_url"`
3674 // MimeType of the content of the file, either “application/pdf” or “application/zip”
3675 MimeType string `json:"mime_type"`
3676 // Description short description of the result
3677 //
3678 // optional
3679 Description string `json:"description,omitempty"`
3680 // ReplyMarkup inline keyboard attached to the message
3681 //
3682 // optional
3683 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3684 // InputMessageContent content of the message to be sent instead of the file
3685 //
3686 // optional
3687 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3688 // ThumbURL url of the thumbnail (jpeg only) for the file
3689 //
3690 // optional
3691 ThumbURL string `json:"thumbnail_url,omitempty"`
3692 // ThumbWidth thumbnail width
3693 //
3694 // optional
3695 ThumbWidth int `json:"thumbnail_width,omitempty"`
3696 // ThumbHeight thumbnail height
3697 //
3698 // optional
3699 ThumbHeight int `json:"thumbnail_height,omitempty"`
3700}
3701
3702// InlineQueryResultGIF is an inline query response GIF.
3703type InlineQueryResultGIF struct {
3704 // Type of the result, must be gif.
3705 Type string `json:"type"`
3706 // ID unique identifier for this result, 1-64 bytes.
3707 ID string `json:"id"`
3708 // URL a valid URL for the GIF file. File size must not exceed 1MB.
3709 URL string `json:"gif_url"`
3710 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
3711 ThumbURL string `json:"thumbnail_url"`
3712 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
3713 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
3714 // Width of the GIF
3715 //
3716 // optional
3717 Width int `json:"gif_width,omitempty"`
3718 // Height of the GIF
3719 //
3720 // optional
3721 Height int `json:"gif_height,omitempty"`
3722 // Duration of the GIF
3723 //
3724 // optional
3725 Duration int `json:"gif_duration,omitempty"`
3726 // Title for the result
3727 //
3728 // optional
3729 Title string `json:"title,omitempty"`
3730 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
3731 //
3732 // optional
3733 Caption string `json:"caption,omitempty"`
3734 // ParseMode mode for parsing entities in the video caption.
3735 // See formatting options for more details
3736 // (https://core.telegram.org/bots/api#formatting-options).
3737 //
3738 // optional
3739 ParseMode string `json:"parse_mode,omitempty"`
3740 // CaptionEntities is a list of special entities that appear in the caption,
3741 // which can be specified instead of parse_mode
3742 //
3743 // optional
3744 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3745 // ReplyMarkup inline keyboard attached to the message
3746 //
3747 // optional
3748 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3749 // InputMessageContent content of the message to be sent instead of the GIF animation.
3750 //
3751 // optional
3752 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3753}
3754
3755// InlineQueryResultLocation is an inline query response location.
3756type InlineQueryResultLocation struct {
3757 // Type of the result, must be location
3758 Type string `json:"type"`
3759 // ID unique identifier for this result, 1-64 Bytes
3760 ID string `json:"id"`
3761 // Latitude of the location in degrees
3762 Latitude float64 `json:"latitude"`
3763 // Longitude of the location in degrees
3764 Longitude float64 `json:"longitude"`
3765 // Title of the location
3766 Title string `json:"title"`
3767 // HorizontalAccuracy is the radius of uncertainty for the location,
3768 // measured in meters; 0-1500
3769 //
3770 // optional
3771 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
3772 // LivePeriod is the period in seconds for which the location can be
3773 // updated, should be between 60 and 86400.
3774 //
3775 // optional
3776 LivePeriod int `json:"live_period,omitempty"`
3777 // Heading is for live locations, a direction in which the user is moving,
3778 // in degrees. Must be between 1 and 360 if specified.
3779 //
3780 // optional
3781 Heading int `json:"heading,omitempty"`
3782 // ProximityAlertRadius is for live locations, a maximum distance for
3783 // proximity alerts about approaching another chat member, in meters. Must
3784 // be between 1 and 100000 if specified.
3785 //
3786 // optional
3787 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
3788 // ReplyMarkup inline keyboard attached to the message
3789 //
3790 // optional
3791 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3792 // InputMessageContent content of the message to be sent instead of the location
3793 //
3794 // optional
3795 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3796 // ThumbURL url of the thumbnail for the result
3797 //
3798 // optional
3799 ThumbURL string `json:"thumbnail_url,omitempty"`
3800 // ThumbWidth thumbnail width
3801 //
3802 // optional
3803 ThumbWidth int `json:"thumbnail_width,omitempty"`
3804 // ThumbHeight thumbnail height
3805 //
3806 // optional
3807 ThumbHeight int `json:"thumbnail_height,omitempty"`
3808}
3809
3810// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
3811type InlineQueryResultMPEG4GIF struct {
3812 // Type of the result, must be mpeg4_gif
3813 Type string `json:"type"`
3814 // ID unique identifier for this result, 1-64 bytes
3815 ID string `json:"id"`
3816 // URL a valid URL for the MP4 file. File size must not exceed 1MB
3817 URL string `json:"mpeg4_url"`
3818 // Width video width
3819 //
3820 // optional
3821 Width int `json:"mpeg4_width,omitempty"`
3822 // Height vVideo height
3823 //
3824 // optional
3825 Height int `json:"mpeg4_height,omitempty"`
3826 // Duration video duration
3827 //
3828 // optional
3829 Duration int `json:"mpeg4_duration,omitempty"`
3830 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
3831 ThumbURL string `json:"thumbnail_url"`
3832 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
3833 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
3834 // Title for the result
3835 //
3836 // optional
3837 Title string `json:"title,omitempty"`
3838 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
3839 //
3840 // optional
3841 Caption string `json:"caption,omitempty"`
3842 // ParseMode mode for parsing entities in the video caption.
3843 // See formatting options for more details
3844 // (https://core.telegram.org/bots/api#formatting-options).
3845 //
3846 // optional
3847 ParseMode string `json:"parse_mode,omitempty"`
3848 // CaptionEntities is a list of special entities that appear in the caption,
3849 // which can be specified instead of parse_mode
3850 //
3851 // optional
3852 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3853 // ReplyMarkup inline keyboard attached to the message
3854 //
3855 // optional
3856 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3857 // InputMessageContent content of the message to be sent instead of the video animation
3858 //
3859 // optional
3860 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3861}
3862
3863// InlineQueryResultPhoto is an inline query response photo.
3864type InlineQueryResultPhoto struct {
3865 // Type of the result, must be article.
3866 Type string `json:"type"`
3867 // ID unique identifier for this result, 1-64 Bytes.
3868 ID string `json:"id"`
3869 // URL a valid URL of the photo. Photo must be in jpeg format.
3870 // Photo size must not exceed 5MB.
3871 URL string `json:"photo_url"`
3872 // MimeType
3873 MimeType string `json:"mime_type"`
3874 // Width of the photo
3875 //
3876 // optional
3877 Width int `json:"photo_width,omitempty"`
3878 // Height of the photo
3879 //
3880 // optional
3881 Height int `json:"photo_height,omitempty"`
3882 // ThumbURL url of the thumbnail for the photo.
3883 //
3884 // optional
3885 ThumbURL string `json:"thumbnail_url,omitempty"`
3886 // Title for the result
3887 //
3888 // optional
3889 Title string `json:"title,omitempty"`
3890 // Description short description of the result
3891 //
3892 // optional
3893 Description string `json:"description,omitempty"`
3894 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
3895 //
3896 // optional
3897 Caption string `json:"caption,omitempty"`
3898 // ParseMode mode for parsing entities in the photo caption.
3899 // See formatting options for more details
3900 // (https://core.telegram.org/bots/api#formatting-options).
3901 //
3902 // optional
3903 ParseMode string `json:"parse_mode,omitempty"`
3904 // ReplyMarkup inline keyboard attached to the message.
3905 //
3906 // optional
3907 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3908 // CaptionEntities is a list of special entities that appear in the caption,
3909 // which can be specified instead of parse_mode
3910 //
3911 // optional
3912 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3913 // InputMessageContent content of the message to be sent instead of the photo.
3914 //
3915 // optional
3916 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3917}
3918
3919// InlineQueryResultVenue is an inline query response venue.
3920type InlineQueryResultVenue struct {
3921 // Type of the result, must be venue
3922 Type string `json:"type"`
3923 // ID unique identifier for this result, 1-64 Bytes
3924 ID string `json:"id"`
3925 // Latitude of the venue location in degrees
3926 Latitude float64 `json:"latitude"`
3927 // Longitude of the venue location in degrees
3928 Longitude float64 `json:"longitude"`
3929 // Title of the venue
3930 Title string `json:"title"`
3931 // Address of the venue
3932 Address string `json:"address"`
3933 // FoursquareID foursquare identifier of the venue if known
3934 //
3935 // optional
3936 FoursquareID string `json:"foursquare_id,omitempty"`
3937 // FoursquareType foursquare type of the venue, if known.
3938 // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
3939 //
3940 // optional
3941 FoursquareType string `json:"foursquare_type,omitempty"`
3942 // GooglePlaceID is the Google Places identifier of the venue
3943 //
3944 // optional
3945 GooglePlaceID string `json:"google_place_id,omitempty"`
3946 // GooglePlaceType is the Google Places type of the venue
3947 //
3948 // optional
3949 GooglePlaceType string `json:"google_place_type,omitempty"`
3950 // ReplyMarkup inline keyboard attached to the message
3951 //
3952 // optional
3953 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3954 // InputMessageContent content of the message to be sent instead of the venue
3955 //
3956 // optional
3957 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3958 // ThumbURL url of the thumbnail for the result
3959 //
3960 // optional
3961 ThumbURL string `json:"thumbnail_url,omitempty"`
3962 // ThumbWidth thumbnail width
3963 //
3964 // optional
3965 ThumbWidth int `json:"thumbnail_width,omitempty"`
3966 // ThumbHeight thumbnail height
3967 //
3968 // optional
3969 ThumbHeight int `json:"thumbnail_height,omitempty"`
3970}
3971
3972// InlineQueryResultVideo is an inline query response video.
3973type InlineQueryResultVideo struct {
3974 // Type of the result, must be video
3975 Type string `json:"type"`
3976 // ID unique identifier for this result, 1-64 bytes
3977 ID string `json:"id"`
3978 // URL a valid url for the embedded video player or video file
3979 URL string `json:"video_url"`
3980 // MimeType of the content of video url, “text/html” or “video/mp4”
3981 MimeType string `json:"mime_type"`
3982 //
3983 // ThumbURL url of the thumbnail (jpeg only) for the video
3984 // optional
3985 ThumbURL string `json:"thumbnail_url,omitempty"`
3986 // Title for the result
3987 Title string `json:"title"`
3988 // Caption of the video to be sent, 0-1024 characters after entities parsing
3989 //
3990 // optional
3991 Caption string `json:"caption,omitempty"`
3992 // Width video width
3993 //
3994 // optional
3995 Width int `json:"video_width,omitempty"`
3996 // Height video height
3997 //
3998 // optional
3999 Height int `json:"video_height,omitempty"`
4000 // Duration video duration in seconds
4001 //
4002 // optional
4003 Duration int `json:"video_duration,omitempty"`
4004 // Description short description of the result
4005 //
4006 // optional
4007 Description string `json:"description,omitempty"`
4008 // ReplyMarkup inline keyboard attached to the message
4009 //
4010 // optional
4011 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4012 // InputMessageContent content of the message to be sent instead of the video.
4013 // This field is required if InlineQueryResultVideo is used to send
4014 // an HTML-page as a result (e.g., a YouTube video).
4015 //
4016 // optional
4017 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4018}
4019
4020// InlineQueryResultVoice is an inline query response voice.
4021type InlineQueryResultVoice struct {
4022 // Type of the result, must be voice
4023 Type string `json:"type"`
4024 // ID unique identifier for this result, 1-64 bytes
4025 ID string `json:"id"`
4026 // URL a valid URL for the voice recording
4027 URL string `json:"voice_url"`
4028 // Title recording title
4029 Title string `json:"title"`
4030 // Caption 0-1024 characters after entities parsing
4031 //
4032 // optional
4033 Caption string `json:"caption,omitempty"`
4034 // ParseMode mode for parsing entities in the video caption.
4035 // See formatting options for more details
4036 // (https://core.telegram.org/bots/api#formatting-options).
4037 //
4038 // optional
4039 ParseMode string `json:"parse_mode,omitempty"`
4040 // CaptionEntities is a list of special entities that appear in the caption,
4041 // which can be specified instead of parse_mode
4042 //
4043 // optional
4044 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4045 // Duration recording duration in seconds
4046 //
4047 // optional
4048 Duration int `json:"voice_duration,omitempty"`
4049 // ReplyMarkup inline keyboard attached to the message
4050 //
4051 // optional
4052 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4053 // InputMessageContent content of the message to be sent instead of the voice recording
4054 //
4055 // optional
4056 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4057}
4058
4059// ChosenInlineResult is an inline query result chosen by a User
4060type ChosenInlineResult struct {
4061 // ResultID the unique identifier for the result that was chosen
4062 ResultID string `json:"result_id"`
4063 // From the user that chose the result
4064 From *User `json:"from"`
4065 // Location sender location, only for bots that require user location
4066 //
4067 // optional
4068 Location *Location `json:"location,omitempty"`
4069 // InlineMessageID identifier of the sent inline message.
4070 // Available only if there is an inline keyboard attached to the message.
4071 // Will be also received in callback queries and can be used to edit the message.
4072 //
4073 // optional
4074 InlineMessageID string `json:"inline_message_id,omitempty"`
4075 // Query the query that was used to obtain the result
4076 Query string `json:"query"`
4077}
4078
4079// SentWebAppMessage contains information about an inline message sent by a Web App
4080// on behalf of a user.
4081type SentWebAppMessage struct {
4082 // Identifier of the sent inline message. Available only if there is an inline
4083 // keyboard attached to the message.
4084 //
4085 // optional
4086 InlineMessageID string `json:"inline_message_id,omitempty"`
4087}
4088
4089// InputTextMessageContent contains text for displaying
4090// as an inline query result.
4091type InputTextMessageContent struct {
4092 // Text of the message to be sent, 1-4096 characters
4093 Text string `json:"message_text"`
4094 // ParseMode mode for parsing entities in the message text.
4095 // See formatting options for more details
4096 // (https://core.telegram.org/bots/api#formatting-options).
4097 //
4098 // optional
4099 ParseMode string `json:"parse_mode,omitempty"`
4100 // Entities is a list of special entities that appear in message text, which
4101 // can be specified instead of parse_mode
4102 //
4103 // optional
4104 Entities []MessageEntity `json:"entities,omitempty"`
4105 // LinkPreviewOptions used for link preview generation for the original message
4106 //
4107 // Optional
4108 LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
4109}
4110
4111// InputLocationMessageContent contains a location for displaying
4112// as an inline query result.
4113type InputLocationMessageContent struct {
4114 // Latitude of the location in degrees
4115 Latitude float64 `json:"latitude"`
4116 // Longitude of the location in degrees
4117 Longitude float64 `json:"longitude"`
4118 // HorizontalAccuracy is the radius of uncertainty for the location,
4119 // measured in meters; 0-1500
4120 //
4121 // optional
4122 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
4123 // LivePeriod is the period in seconds for which the location can be
4124 // updated, should be between 60 and 86400
4125 //
4126 // optional
4127 LivePeriod int `json:"live_period,omitempty"`
4128 // Heading is for live locations, a direction in which the user is moving,
4129 // in degrees. Must be between 1 and 360 if specified.
4130 //
4131 // optional
4132 Heading int `json:"heading,omitempty"`
4133 // ProximityAlertRadius is for live locations, a maximum distance for
4134 // proximity alerts about approaching another chat member, in meters. Must
4135 // be between 1 and 100000 if specified.
4136 //
4137 // optional
4138 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
4139}
4140
4141// InputVenueMessageContent contains a venue for displaying
4142// as an inline query result.
4143type InputVenueMessageContent struct {
4144 // Latitude of the venue in degrees
4145 Latitude float64 `json:"latitude"`
4146 // Longitude of the venue in degrees
4147 Longitude float64 `json:"longitude"`
4148 // Title name of the venue
4149 Title string `json:"title"`
4150 // Address of the venue
4151 Address string `json:"address"`
4152 // FoursquareID foursquare identifier of the venue, if known
4153 //
4154 // optional
4155 FoursquareID string `json:"foursquare_id,omitempty"`
4156 // FoursquareType Foursquare type of the venue, if known
4157 //
4158 // optional
4159 FoursquareType string `json:"foursquare_type,omitempty"`
4160 // GooglePlaceID is the Google Places identifier of the venue
4161 //
4162 // optional
4163 GooglePlaceID string `json:"google_place_id,omitempty"`
4164 // GooglePlaceType is the Google Places type of the venue
4165 //
4166 // optional
4167 GooglePlaceType string `json:"google_place_type,omitempty"`
4168}
4169
4170// InputContactMessageContent contains a contact for displaying
4171// as an inline query result.
4172type InputContactMessageContent struct {
4173 // PhoneNumber contact's phone number
4174 PhoneNumber string `json:"phone_number"`
4175 // FirstName contact's first name
4176 FirstName string `json:"first_name"`
4177 // LastName contact's last name
4178 //
4179 // optional
4180 LastName string `json:"last_name,omitempty"`
4181 // Additional data about the contact in the form of a vCard
4182 //
4183 // optional
4184 VCard string `json:"vcard,omitempty"`
4185}
4186
4187// InputInvoiceMessageContent represents the content of an invoice message to be
4188// sent as the result of an inline query.
4189type InputInvoiceMessageContent struct {
4190 // Product name, 1-32 characters
4191 Title string `json:"title"`
4192 // Product description, 1-255 characters
4193 Description string `json:"description"`
4194 // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
4195 // the user, use for your internal processes.
4196 Payload string `json:"payload"`
4197 // Payment provider token, obtained via Botfather
4198 ProviderToken string `json:"provider_token"`
4199 // Three-letter ISO 4217 currency code
4200 Currency string `json:"currency"`
4201 // Price breakdown, a JSON-serialized list of components (e.g. product
4202 // price, tax, discount, delivery cost, delivery tax, bonus, etc.)
4203 Prices []LabeledPrice `json:"prices"`
4204 // The maximum accepted amount for tips in the smallest units of the
4205 // currency (integer, not float/double).
4206 //
4207 // optional
4208 MaxTipAmount int `json:"max_tip_amount,omitempty"`
4209 // An array of suggested amounts of tip in the smallest units of the
4210 // currency (integer, not float/double). At most 4 suggested tip amounts can
4211 // be specified. The suggested tip amounts must be positive, passed in a
4212 // strictly increased order and must not exceed max_tip_amount.
4213 //
4214 // optional
4215 SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
4216 // A JSON-serialized object for data about the invoice, which will be shared
4217 // with the payment provider. A detailed description of the required fields
4218 // should be provided by the payment provider.
4219 //
4220 // optional
4221 ProviderData string `json:"provider_data,omitempty"`
4222 // URL of the product photo for the invoice. Can be a photo of the goods or
4223 // a marketing image for a service. People like it better when they see what
4224 // they are paying for.
4225 //
4226 // optional
4227 PhotoURL string `json:"photo_url,omitempty"`
4228 // Photo size
4229 //
4230 // optional
4231 PhotoSize int `json:"photo_size,omitempty"`
4232 // Photo width
4233 //
4234 // optional
4235 PhotoWidth int `json:"photo_width,omitempty"`
4236 // Photo height
4237 //
4238 // optional
4239 PhotoHeight int `json:"photo_height,omitempty"`
4240 // Pass True, if you require the user's full name to complete the order
4241 //
4242 // optional
4243 NeedName bool `json:"need_name,omitempty"`
4244 // Pass True, if you require the user's phone number to complete the order
4245 //
4246 // optional
4247 NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
4248 // Pass True, if you require the user's email address to complete the order
4249 //
4250 // optional
4251 NeedEmail bool `json:"need_email,omitempty"`
4252 // Pass True, if you require the user's shipping address to complete the order
4253 //
4254 // optional
4255 NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
4256 // Pass True, if user's phone number should be sent to provider
4257 //
4258 // optional
4259 SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
4260 // Pass True, if user's email address should be sent to provider
4261 //
4262 // optional
4263 SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
4264 // Pass True, if the final price depends on the shipping method
4265 //
4266 // optional
4267 IsFlexible bool `json:"is_flexible,omitempty"`
4268}
4269
4270// LabeledPrice represents a portion of the price for goods or services.
4271type LabeledPrice struct {
4272 // Label portion label
4273 Label string `json:"label"`
4274 // Amount price of the product in the smallest units of the currency (integer, not float/double).
4275 // For example, for a price of US$ 1.45 pass amount = 145.
4276 // See the exp parameter in currencies.json
4277 // (https://core.telegram.org/bots/payments/currencies.json),
4278 // it shows the number of digits past the decimal point
4279 // for each currency (2 for the majority of currencies).
4280 Amount int `json:"amount"`
4281}
4282
4283// Invoice contains basic information about an invoice.
4284type Invoice struct {
4285 // Title product name
4286 Title string `json:"title"`
4287 // Description product description
4288 Description string `json:"description"`
4289 // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
4290 StartParameter string `json:"start_parameter"`
4291 // Currency three-letter ISO 4217 currency code
4292 // (see https://core.telegram.org/bots/payments#supported-currencies)
4293 Currency string `json:"currency"`
4294 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4295 // For example, for a price of US$ 1.45 pass amount = 145.
4296 // See the exp parameter in currencies.json
4297 // (https://core.telegram.org/bots/payments/currencies.json),
4298 // it shows the number of digits past the decimal point
4299 // for each currency (2 for the majority of currencies).
4300 TotalAmount int `json:"total_amount"`
4301}
4302
4303// ShippingAddress represents a shipping address.
4304type ShippingAddress struct {
4305 // CountryCode ISO 3166-1 alpha-2 country code
4306 CountryCode string `json:"country_code"`
4307 // State if applicable
4308 State string `json:"state"`
4309 // City city
4310 City string `json:"city"`
4311 // StreetLine1 first line for the address
4312 StreetLine1 string `json:"street_line1"`
4313 // StreetLine2 second line for the address
4314 StreetLine2 string `json:"street_line2"`
4315 // PostCode address post code
4316 PostCode string `json:"post_code"`
4317}
4318
4319// OrderInfo represents information about an order.
4320type OrderInfo struct {
4321 // Name user name
4322 //
4323 // optional
4324 Name string `json:"name,omitempty"`
4325 // PhoneNumber user's phone number
4326 //
4327 // optional
4328 PhoneNumber string `json:"phone_number,omitempty"`
4329 // Email user email
4330 //
4331 // optional
4332 Email string `json:"email,omitempty"`
4333 // ShippingAddress user shipping address
4334 //
4335 // optional
4336 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
4337}
4338
4339// ShippingOption represents one shipping option.
4340type ShippingOption struct {
4341 // ID shipping option identifier
4342 ID string `json:"id"`
4343 // Title option title
4344 Title string `json:"title"`
4345 // Prices list of price portions
4346 Prices []LabeledPrice `json:"prices"`
4347}
4348
4349// SuccessfulPayment contains basic information about a successful payment.
4350type SuccessfulPayment struct {
4351 // Currency three-letter ISO 4217 currency code
4352 // (see https://core.telegram.org/bots/payments#supported-currencies)
4353 Currency string `json:"currency"`
4354 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4355 // For example, for a price of US$ 1.45 pass amount = 145.
4356 // See the exp parameter in currencies.json,
4357 // (https://core.telegram.org/bots/payments/currencies.json)
4358 // it shows the number of digits past the decimal point
4359 // for each currency (2 for the majority of currencies).
4360 TotalAmount int `json:"total_amount"`
4361 // InvoicePayload bot specified invoice payload
4362 InvoicePayload string `json:"invoice_payload"`
4363 // ShippingOptionID identifier of the shipping option chosen by the user
4364 //
4365 // optional
4366 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4367 // OrderInfo order info provided by the user
4368 //
4369 // optional
4370 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4371 // TelegramPaymentChargeID telegram payment identifier
4372 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
4373 // ProviderPaymentChargeID provider payment identifier
4374 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
4375}
4376
4377// ShippingQuery contains information about an incoming shipping query.
4378type ShippingQuery struct {
4379 // ID unique query identifier
4380 ID string `json:"id"`
4381 // From user who sent the query
4382 From *User `json:"from"`
4383 // InvoicePayload bot specified invoice payload
4384 InvoicePayload string `json:"invoice_payload"`
4385 // ShippingAddress user specified shipping address
4386 ShippingAddress *ShippingAddress `json:"shipping_address"`
4387}
4388
4389// PreCheckoutQuery contains information about an incoming pre-checkout query.
4390type PreCheckoutQuery struct {
4391 // ID unique query identifier
4392 ID string `json:"id"`
4393 // From user who sent the query
4394 From *User `json:"from"`
4395 // Currency three-letter ISO 4217 currency code
4396 // // (see https://core.telegram.org/bots/payments#supported-currencies)
4397 Currency string `json:"currency"`
4398 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4399 // // For example, for a price of US$ 1.45 pass amount = 145.
4400 // // See the exp parameter in currencies.json,
4401 // // (https://core.telegram.org/bots/payments/currencies.json)
4402 // // it shows the number of digits past the decimal point
4403 // // for each currency (2 for the majority of currencies).
4404 TotalAmount int `json:"total_amount"`
4405 // InvoicePayload bot specified invoice payload
4406 InvoicePayload string `json:"invoice_payload"`
4407 // ShippingOptionID identifier of the shipping option chosen by the user
4408 //
4409 // optional
4410 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4411 // OrderInfo order info provided by the user
4412 //
4413 // optional
4414 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4415}