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