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