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