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