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