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