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