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