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,omitempty"`
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,omitempty"`
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,omitempty"`
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,omitempty"`
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 // BackgroundFillSolid only.
1737 // The color of the background fill in the RGB24 format
1738 Color int `json:"color"`
1739 // BackgroundFillGradient only.
1740 // Top color of the gradient in the RGB24 format
1741 TopColor int `json:"top_color"`
1742 // BackgroundFillGradient only.
1743 // Bottom color of the gradient in the RGB24 format
1744 BottomColor int `json:"bottom_color"`
1745 // BackgroundFillGradient only.
1746 // Clockwise rotation angle of the background fill in degrees; 0-359
1747 RotationAngle int `json:"rotation_angle"`
1748 // BackgroundFillFreeformGradient only.
1749 // A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
1750 Colors []int `json:"colors"`
1751}
1752
1753// BackgroundType describes the type of a background. Currently, it can be one of:
1754// - BackgroundTypeFill
1755// - BackgroundTypeWallpaper
1756// - BackgroundTypePattern
1757// - BackgroundTypeChatTheme
1758type BackgroundType struct {
1759 // Type of the background.
1760 // Currently, it can be one of:
1761 // - fill
1762 // - wallpaper
1763 // - pattern
1764 // - chat_theme
1765 Type string `json:"type"`
1766 // BackgroundTypeFill and BackgroundTypePattern only.
1767 // The background fill or fill that is combined with the pattern
1768 Fill BackgroundFill `json:"fill"`
1769 // BackgroundTypeFill and BackgroundTypeWallpaper only.
1770 // Dimming of the background in dark themes, as a percentage; 0-100
1771 DarkThemeDimming int `json:"dark_theme_dimming"`
1772 // BackgroundTypeWallpaper and BackgroundTypePattern only.
1773 // Document with the wallpaper / pattern
1774 Document Document `json:"document"`
1775 // BackgroundTypeWallpaper only.
1776 // True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
1777 //
1778 // optional
1779 IsBlurred bool `json:"is_blurred,omitempty"`
1780 // BackgroundTypeWallpaper and BackgroundTypePattern only.
1781 // True, if the background moves slightly when the device is tilted
1782 //
1783 // optional
1784 IsMoving bool `json:"is_moving,omitempty"`
1785 // BackgroundTypePattern only.
1786 // Intensity of the pattern when it is shown above the filled background; 0-100
1787 Intensity int `json:"intensity"`
1788 // BackgroundTypePattern only.
1789 // True, if the background fill must be applied only to the pattern itself.
1790 // All other pixels are black in this case. For dark themes only
1791 //
1792 // optional
1793 IsInverted bool `json:"is_inverted,omitempty"`
1794 // BackgroundTypeChatTheme only.
1795 // Name of the chat theme, which is usually an emoji
1796 ThemeName string `json:"theme_name"`
1797}
1798
1799// ChatBackground represents a chat background.
1800type ChatBackground struct {
1801 // Type of the background
1802 Type BackgroundType `json:"type"`
1803}
1804
1805// ForumTopicCreated represents a service message about a new forum topic
1806// created in the chat.
1807type ForumTopicCreated struct {
1808 // Name is the name of topic
1809 Name string `json:"name"`
1810 // IconColor is the color of the topic icon in RGB format
1811 IconColor int `json:"icon_color"`
1812 // IconCustomEmojiID is the unique identifier of the custom emoji
1813 // shown as the topic icon
1814 //
1815 // optional
1816 IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
1817}
1818
1819// ForumTopicClosed represents a service message about a forum topic
1820// closed in the chat. Currently holds no information.
1821type ForumTopicClosed struct {
1822}
1823
1824// ForumTopicEdited object represents a service message about an edited forum topic.
1825type ForumTopicEdited struct {
1826 // Name is the new name of the topic, if it was edited
1827 //
1828 // optional
1829 Name string `json:"name,omitempty"`
1830 // IconCustomEmojiID is the new identifier of the custom emoji
1831 // shown as the topic icon, if it was edited;
1832 // an empty string if the icon was removed
1833 //
1834 // optional
1835 IconCustomEmojiID *string `json:"icon_custom_emoji_id,omitempty"`
1836}
1837
1838// ForumTopicReopened represents a service message about a forum topic
1839// reopened in the chat. Currently holds no information.
1840type ForumTopicReopened struct {
1841}
1842
1843// GeneralForumTopicHidden represents a service message about General forum topic
1844// hidden in the chat. Currently holds no information.
1845type GeneralForumTopicHidden struct {
1846}
1847
1848// GeneralForumTopicUnhidden represents a service message about General forum topic
1849// unhidden in the chat. Currently holds no information.
1850type GeneralForumTopicUnhidden struct {
1851}
1852
1853// SharedUser contains information about a user that was
1854// shared with the bot using a KeyboardButtonRequestUsers button.
1855type SharedUser struct {
1856 // UserID is the identifier of the shared user.
1857 UserID int64 `json:"user_id"`
1858 // FirstName of the user, if the name was requested by the bot.
1859 //
1860 // optional
1861 FirstName *string `json:"first_name,omitempty"`
1862 // LastName of the user, if the name was requested by the bot.
1863 //
1864 // optional
1865 LastName *string `json:"last_name,omitempty"`
1866 // Username of the user, if the username was requested by the bot.
1867 //
1868 // optional
1869 UserName *string `json:"username,omitempty"`
1870 // Photo is array of available sizes of the chat photo,
1871 // if the photo was requested by the bot
1872 //
1873 // optional
1874 Photo []PhotoSize `json:"photo,omitempty"`
1875}
1876
1877// UsersShared object contains information about the user whose identifier
1878// was shared with the bot using a KeyboardButtonRequestUser button.
1879type UsersShared struct {
1880 // RequestID is an indentifier of the request.
1881 RequestID int `json:"request_id"`
1882 // Users shared with the bot.
1883 Users []SharedUser `json:"users"`
1884}
1885
1886// ChatShared contains information about the chat whose identifier
1887// was shared with the bot using a KeyboardButtonRequestChat button.
1888type ChatShared struct {
1889 // RequestID is an indentifier of the request.
1890 RequestID int `json:"request_id"`
1891 // ChatID is an identifier of the shared chat.
1892 ChatID int64 `json:"chat_id"`
1893 // Title of the chat, if the title was requested by the bot.
1894 //
1895 // optional
1896 Title *string `json:"title,omitempty"`
1897 // UserName of the chat, if the username was requested by
1898 // the bot and available.
1899 //
1900 // optional
1901 UserName *string `json:"username,omitempty"`
1902 // Photo is array of available sizes of the chat photo,
1903 // if the photo was requested by the bot
1904 //
1905 // optional
1906 Photo []PhotoSize `json:"photo,omitempty"`
1907}
1908
1909// WriteAccessAllowed represents a service message about a user allowing a bot
1910// to write messages after adding the bot to the attachment menu or launching
1911// a Web App from a link.
1912type WriteAccessAllowed struct {
1913 // FromRequest is true, if the access was granted after
1914 // the user accepted an explicit request from a Web App
1915 // sent by the method requestWriteAccess.
1916 //
1917 // Optional
1918 FromRequest bool `json:"from_request,omitempty"`
1919 // Name of the Web App which was launched from a link
1920 //
1921 // Optional
1922 WebAppName string `json:"web_app_name,omitempty"`
1923 // FromAttachmentMenu is true, if the access was granted when
1924 // the bot was added to the attachment or side menu
1925 //
1926 // Optional
1927 FromAttachmentMenu bool `json:"from_attachment_menu,omitempty"`
1928}
1929
1930// VideoChatScheduled represents a service message about a voice chat scheduled
1931// in the chat.
1932type VideoChatScheduled struct {
1933 // Point in time (Unix timestamp) when the voice chat is supposed to be
1934 // started by a chat administrator
1935 StartDate int `json:"start_date"`
1936}
1937
1938// Time converts the scheduled start date into a Time.
1939func (m *VideoChatScheduled) Time() time.Time {
1940 return time.Unix(int64(m.StartDate), 0)
1941}
1942
1943// VideoChatStarted represents a service message about a voice chat started in
1944// the chat.
1945type VideoChatStarted struct{}
1946
1947// VideoChatEnded represents a service message about a voice chat ended in the
1948// chat.
1949type VideoChatEnded struct {
1950 // Voice chat duration; in seconds.
1951 Duration int `json:"duration"`
1952}
1953
1954// VideoChatParticipantsInvited represents a service message about new members
1955// invited to a voice chat.
1956type VideoChatParticipantsInvited struct {
1957 // New members that were invited to the voice chat.
1958 //
1959 // optional
1960 Users []User `json:"users,omitempty"`
1961}
1962
1963// This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
1964type GiveawayCreated struct{}
1965
1966// Giveaway represents a message about a scheduled giveaway.
1967type Giveaway struct {
1968 // Chats is the list of chats which the user must join to participate in the giveaway
1969 Chats []Chat `json:"chats"`
1970 // WinnersSelectionDate is point in time (Unix timestamp) when
1971 // winners of the giveaway will be selected
1972 WinnersSelectionDate int64 `json:"winners_selection_date"`
1973 // WinnerCount is the number of users which are supposed
1974 // to be selected as winners of the giveaway
1975 WinnerCount int `json:"winner_count"`
1976 // OnlyNewMembers True, if only users who join the chats after
1977 // the giveaway started should be eligible to win
1978 //
1979 // optional
1980 OnlyNewMembers bool `json:"only_new_members,omitempty"`
1981 // HasPublicWinners True, if the list of giveaway winners will be visible to everyone
1982 //
1983 // optional
1984 HasPublicWinners bool `json:"has_public_winners,omitempty"`
1985 // PrizeDescription is description of additional giveaway prize
1986 //
1987 // optional
1988 PrizeDescription string `json:"prize_description,omitempty"`
1989 // CountryCodes is a list of two-letter ISO 3166-1 alpha-2 country codes
1990 // indicating the countries from which eligible users for the giveaway must come.
1991 // If empty, then all users can participate in the giveaway.
1992 //
1993 // optional
1994 CountryCodes []string `json:"country_codes,omitempty"`
1995 // PremiumSubscriptionMonthCount the number of months the Telegram Premium
1996 // subscription won from the giveaway will be active for
1997 //
1998 // optional
1999 PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
2000}
2001
2002// Giveaway represents a message about a scheduled giveaway.
2003type GiveawayWinners struct {
2004 // Chat that created the giveaway
2005 Chat Chat `json:"chat"`
2006 // GiveawayMessageID is the identifier of the messsage with the giveaway in the chat
2007 GiveawayMessageID int `json:"giveaway_message_id"`
2008 // WinnersSelectionDate is point in time (Unix timestamp) when
2009 // winners of the giveaway will be selected
2010 WinnersSelectionDate int64 `json:"winners_selection_date"`
2011 // WinnerCount is the number of users which are supposed
2012 // to be selected as winners of the giveaway
2013 WinnerCount int `json:"winner_count"`
2014 // Winners is a list of up to 100 winners of the giveaway
2015 Winners []User `json:"winners"`
2016 // AdditionalChatCount is the number of other chats
2017 // the user had to join in order to be eligible for the giveaway
2018 //
2019 // optional
2020 AdditionalChatCount int `json:"additional_chat_count,omitempty"`
2021 // PremiumSubscriptionMonthCount the number of months the Telegram Premium
2022 // subscription won from the giveaway will be active for
2023 //
2024 // optional
2025 PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
2026 // UnclaimedPrizeCount is the number of undistributed prizes
2027 //
2028 // optional
2029 UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
2030 // OnlyNewMembers True, if only users who join the chats after
2031 // the giveaway started should be eligible to win
2032 //
2033 // optional
2034 OnlyNewMembers bool `json:"only_new_members,omitempty"`
2035 // WasRefunded True, if the giveaway was canceled because the payment for it was refunded
2036 //
2037 // optional
2038 WasRefunded bool `json:"was_refunded,omitempty"`
2039 // PrizeDescription is description of additional giveaway prize
2040 //
2041 // optional
2042 PrizeDescription string `json:"prize_description,omitempty"`
2043}
2044
2045// This object represents a service message about the completion of a giveaway without public winners.
2046type GiveawayCompleted struct {
2047 // Number of winners in the giveaway
2048 WinnerCount int `json:"winner_count"`
2049 // Number of undistributed prizes
2050 //
2051 // optional
2052 UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
2053 // Message with the giveaway that was completed, if it wasn't deleted
2054 //
2055 // optional
2056 GiveawayMessage *Message `json:"giveaway_message,omitempty"`
2057}
2058
2059// LinkPreviewOptions describes the options used for link preview generation.
2060type LinkPreviewOptions struct {
2061 // IsDisabled True, if the link preview is disabled
2062 //
2063 // optional
2064 IsDisabled bool `json:"is_disabled,omitempty"`
2065 // URL to use for the link preview. If empty,
2066 // then the first URL found in the message text will be used
2067 //
2068 // optional
2069 URL string `json:"url,omitempty"`
2070 // PreferSmallMedia True, if the media in the link preview is suppposed
2071 // to be shrunk; ignored if the URL isn't explicitly specified
2072 // or media size change isn't supported for the preview
2073 //
2074 // optional
2075 PreferSmallMedia bool `json:"prefer_small_media,omitempty"`
2076 // PreferLargeMedia True, if the media in the link preview is suppposed
2077 // to be enlarged; ignored if the URL isn't explicitly specified
2078 // or media size change isn't supported for the preview
2079 //
2080 // optional
2081 PreferLargeMedia bool `json:"prefer_large_media,omitempty"`
2082 // ShowAboveText True, if the link preview must be shown above the message text;
2083 // otherwise, the link preview will be shown below the message text
2084 //
2085 // optional
2086 ShowAboveText bool `json:"show_above_text,omitempty"`
2087}
2088
2089// UserProfilePhotos contains a set of user profile photos.
2090type UserProfilePhotos struct {
2091 // TotalCount total number of profile pictures the target user has
2092 TotalCount int `json:"total_count"`
2093 // Photos requested profile pictures (in up to 4 sizes each)
2094 Photos [][]PhotoSize `json:"photos"`
2095}
2096
2097// File contains information about a file to download from Telegram.
2098type File struct {
2099 // FileID identifier for this file, which can be used to download or reuse
2100 // the file
2101 FileID string `json:"file_id"`
2102 // FileUniqueID is the unique identifier for this file, which is supposed to
2103 // be the same over time and for different bots. Can't be used to download
2104 // or reuse the file.
2105 FileUniqueID string `json:"file_unique_id"`
2106 // FileSize file size, if known
2107 //
2108 // optional
2109 FileSize int64 `json:"file_size,omitempty"`
2110 // FilePath file path
2111 //
2112 // optional
2113 FilePath string `json:"file_path,omitempty"`
2114}
2115
2116// Link returns a full path to the download URL for a File.
2117//
2118// It requires the Bot token to create the link.
2119func (f *File) Link(token string) string {
2120 return fmt.Sprintf(FileEndpoint, token, f.FilePath)
2121}
2122
2123// WebAppInfo contains information about a Web App.
2124type WebAppInfo struct {
2125 // URL is the HTTPS URL of a Web App to be opened with additional data as
2126 // specified in Initializing Web Apps.
2127 URL string `json:"url"`
2128}
2129
2130// ReplyKeyboardMarkup represents a custom keyboard with reply options.
2131type ReplyKeyboardMarkup struct {
2132 // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
2133 Keyboard [][]KeyboardButton `json:"keyboard"`
2134 // IsPersistent requests clients to always show the keyboard
2135 // when the regular keyboard is hidden.
2136 // Defaults to false, in which case the custom keyboard can be hidden
2137 // and opened with a keyboard icon.
2138 //
2139 // optional
2140 IsPersistent bool `json:"is_persistent"`
2141 // ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
2142 // (e.g., make the keyboard smaller if there are just two rows of buttons).
2143 // Defaults to false, in which case the custom keyboard
2144 // is always of the same height as the app's standard keyboard.
2145 //
2146 // optional
2147 ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
2148 // OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
2149 // The keyboard will still be available, but clients will automatically display
2150 // the usual letter-keyboard in the chat – the user can press a special button
2151 // in the input field to see the custom keyboard again.
2152 // Defaults to false.
2153 //
2154 // optional
2155 OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
2156 // InputFieldPlaceholder is the placeholder to be shown in the input field when
2157 // the keyboard is active; 1-64 characters.
2158 //
2159 // optional
2160 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
2161 // Selective use this parameter if you want to show the keyboard to specific users only.
2162 // Targets:
2163 // 1) users that are @mentioned in the text of the Message object;
2164 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2165 //
2166 // Example: A user requests to change the bot's language,
2167 // bot replies to the request with a keyboard to select the new language.
2168 // Other users in the group don't see the keyboard.
2169 //
2170 // optional
2171 Selective bool `json:"selective,omitempty"`
2172}
2173
2174// KeyboardButton represents one button of the reply keyboard. For simple text
2175// buttons String can be used instead of this object to specify text of the
2176// button. Optional fields request_contact, request_location, and request_poll
2177// are mutually exclusive.
2178type KeyboardButton struct {
2179 // Text of the button. If none of the optional fields are used,
2180 // it will be sent as a message when the button is pressed.
2181 Text string `json:"text"`
2182 // RequestUsers if specified, pressing the button will open
2183 // a list of suitable users. Tapping on any user will send
2184 // their identifier to the bot in a "user_shared" service message.
2185 // Available in private chats only.
2186 //
2187 // optional
2188 RequestUsers *KeyboardButtonRequestUsers `json:"request_users,omitempty"`
2189 // RequestChat if specified, pressing the button will open
2190 // a list of suitable chats. Tapping on a chat will send
2191 // its identifier to the bot in a "chat_shared" service message.
2192 // Available in private chats only.
2193 //
2194 // optional
2195 RequestChat *KeyboardButtonRequestChat `json:"request_chat,omitempty"`
2196 // RequestContact if True, the user's phone number will be sent
2197 // as a contact when the button is pressed.
2198 // Available in private chats only.
2199 //
2200 // optional
2201 RequestContact bool `json:"request_contact,omitempty"`
2202 // RequestLocation if True, the user's current location will be sent when
2203 // the button is pressed.
2204 // Available in private chats only.
2205 //
2206 // optional
2207 RequestLocation bool `json:"request_location,omitempty"`
2208 // RequestPoll if specified, the user will be asked to create a poll and send it
2209 // to the bot when the button is pressed. Available in private chats only
2210 //
2211 // optional
2212 RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
2213 // WebApp if specified, the described Web App will be launched when the button
2214 // is pressed. The Web App will be able to send a “web_app_data” service
2215 // message. Available in private chats only.
2216 //
2217 // optional
2218 WebApp *WebAppInfo `json:"web_app,omitempty"`
2219}
2220
2221// KeyboardButtonRequestUsers defines the criteria used to request
2222// a suitable user. The identifier of the selected user will be shared
2223// with the bot when the corresponding button is pressed.
2224type KeyboardButtonRequestUsers struct {
2225 // RequestID is a signed 32-bit identifier of the request.
2226 RequestID int `json:"request_id"`
2227 // UserIsBot pass True to request a bot,
2228 // pass False to request a regular user.
2229 // If not specified, no additional restrictions are applied.
2230 //
2231 // optional
2232 UserIsBot *bool `json:"user_is_bot,omitempty"`
2233 // UserIsPremium pass True to request a premium user,
2234 // pass False to request a non-premium user.
2235 // If not specified, no additional restrictions are applied.
2236 //
2237 // optional
2238 UserIsPremium *bool `json:"user_is_premium,omitempty"`
2239 // MaxQuantity is the maximum number of users to be selected.
2240 // 1-10. Defaults to 1
2241 //
2242 // optional
2243 MaxQuantity int `json:"max_quantity,omitempty"`
2244 // RequestName pass True to request the users' first and last names
2245 //
2246 // optional
2247 RequestName bool `json:"request_name,omitempty"`
2248 // RequestUsername pass True to request the users' usernames
2249 //
2250 // optional
2251 RequestUsername bool `json:"request_username,omitempty"`
2252 // RequestPhoto pass True to request the users' photos
2253 //
2254 // optional
2255 RequestPhoto bool `json:"request_photo,omitempty"`
2256}
2257
2258// KeyboardButtonRequestChat defines the criteria used to request
2259// a suitable chat. The identifier of the selected chat will be shared
2260// with the bot when the corresponding button is pressed.
2261type KeyboardButtonRequestChat struct {
2262 // RequestID is a signed 32-bit identifier of the request.
2263 RequestID int `json:"request_id"`
2264 // ChatIsChannel pass True to request a channel chat,
2265 // pass False to request a group or a supergroup chat.
2266 ChatIsChannel bool `json:"chat_is_channel"`
2267 // ChatIsForum pass True to request a forum supergroup,
2268 // pass False to request a non-forum chat.
2269 // If not specified, no additional restrictions are applied.
2270 //
2271 // optional
2272 ChatIsForum bool `json:"chat_is_forum,omitempty"`
2273 // ChatHasUsername pass True to request a supergroup or a channel with a username,
2274 // pass False to request a chat without a username.
2275 // If not specified, no additional restrictions are applied.
2276 //
2277 // optional
2278 ChatHasUsername bool `json:"chat_has_username,omitempty"`
2279 // ChatIsCreated pass True to request a chat owned by the user.
2280 // Otherwise, no additional restrictions are applied.
2281 //
2282 // optional
2283 ChatIsCreated bool `json:"chat_is_created,omitempty"`
2284 // UserAdministratorRights is a JSON-serialized object listing
2285 // the required administrator rights of the user in the chat.
2286 // If not specified, no additional restrictions are applied.
2287 //
2288 // optional
2289 UserAdministratorRights *ChatAdministratorRights `json:"user_administrator_rights,omitempty"`
2290 // BotAdministratorRights is a JSON-serialized object listing
2291 // the required administrator rights of the bot in the chat.
2292 // The rights must be a subset of user_administrator_rights.
2293 // If not specified, no additional restrictions are applied.
2294 //
2295 // optional
2296 BotAdministratorRights *ChatAdministratorRights `json:"bot_administrator_rights,omitempty"`
2297 // BotIsMember pass True to request a chat with the bot as a member.
2298 // Otherwise, no additional restrictions are applied.
2299 //
2300 // optional
2301 BotIsMember bool `json:"bot_is_member,omitempty"`
2302 // RequestTitle pass True to request the chat's title
2303 //
2304 // optional
2305 RequestTitle bool `json:"request_title,omitempty"`
2306 // RequestUsername pass True to request the chat's username
2307 //
2308 // optional
2309 RequestUsername bool `json:"request_username,omitempty"`
2310 // RequestPhoto pass True to request the chat's photo
2311 //
2312 // optional
2313 RequestPhoto bool `json:"request_photo,omitempty"`
2314}
2315
2316// KeyboardButtonPollType represents type of poll, which is allowed to
2317// be created and sent when the corresponding button is pressed.
2318type KeyboardButtonPollType struct {
2319 // Type is if quiz is passed, the user will be allowed to create only polls
2320 // in the quiz mode. If regular is passed, only regular polls will be
2321 // allowed. Otherwise, the user will be allowed to create a poll of any type.
2322 Type string `json:"type"`
2323}
2324
2325// ReplyKeyboardRemove Upon receiving a message with this object, Telegram
2326// clients will remove the current custom keyboard and display the default
2327// letter-keyboard. By default, custom keyboards are displayed until a new
2328// keyboard is sent by a bot. An exception is made for one-time keyboards
2329// that are hidden immediately after the user presses a button.
2330type ReplyKeyboardRemove struct {
2331 // RemoveKeyboard requests clients to remove the custom keyboard
2332 // (user will not be able to summon this keyboard;
2333 // if you want to hide the keyboard from sight but keep it accessible,
2334 // use one_time_keyboard in ReplyKeyboardMarkup).
2335 RemoveKeyboard bool `json:"remove_keyboard"`
2336 // Selective use this parameter if you want to remove the keyboard for specific users only.
2337 // Targets:
2338 // 1) users that are @mentioned in the text of the Message object;
2339 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2340 //
2341 // Example: A user votes in a poll, bot returns confirmation message
2342 // in reply to the vote and removes the keyboard for that user,
2343 // while still showing the keyboard with poll options to users who haven't voted yet.
2344 //
2345 // optional
2346 Selective bool `json:"selective,omitempty"`
2347}
2348
2349// InlineKeyboardMarkup represents an inline keyboard that appears right next to
2350// the message it belongs to.
2351type InlineKeyboardMarkup struct {
2352 // InlineKeyboard array of button rows, each represented by an Array of
2353 // InlineKeyboardButton objects
2354 InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
2355}
2356
2357// InlineKeyboardButton represents one button of an inline keyboard. You must
2358// use exactly one of the optional fields.
2359//
2360// Note that some values are references as even an empty string
2361// will change behavior.
2362//
2363// CallbackGame, if set, MUST be first button in first row.
2364type InlineKeyboardButton struct {
2365 // Text label text on the button
2366 Text string `json:"text"`
2367 // URL HTTP or tg:// url to be opened when button is pressed.
2368 //
2369 // optional
2370 URL *string `json:"url,omitempty"`
2371 // LoginURL is an HTTP URL used to automatically authorize the user. Can be
2372 // used as a replacement for the Telegram Login Widget
2373 //
2374 // optional
2375 LoginURL *LoginURL `json:"login_url,omitempty"`
2376 // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
2377 //
2378 // optional
2379 CallbackData *string `json:"callback_data,omitempty"`
2380 // WebApp is the Description of the Web App that will be launched when the user presses the button.
2381 // The Web App will be able to send an arbitrary message on behalf of the user using the method
2382 // answerWebAppQuery. Available only in private chats between a user and the bot.
2383 //
2384 // optional
2385 WebApp *WebAppInfo `json:"web_app,omitempty"`
2386 // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
2387 // open that chat and insert the bot's username and the specified inline query in the input field.
2388 // Can be empty, in which case just the bot's username will be inserted.
2389 //
2390 // This offers an easy way for users to start using your bot
2391 // in inline mode when they are currently in a private chat with it.
2392 // Especially useful when combined with switch_pm… actions – in this case
2393 // the user will be automatically returned to the chat they switched from,
2394 // skipping the chat selection screen.
2395 //
2396 // optional
2397 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
2398 // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
2399 // and the specified inline query in the current chat's input field.
2400 // Can be empty, in which case only the bot's username will be inserted.
2401 //
2402 // This offers a quick way for the user to open your bot in inline mode
2403 // in the same chat – good for selecting something from multiple options.
2404 //
2405 // optional
2406 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
2407 //SwitchInlineQueryChosenChat If set, pressing the button will prompt the user to
2408 //select one of their chats of the specified type, open that chat and insert the bot's
2409 //username and the specified inline query in the input field
2410 //
2411 //optional
2412 SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`
2413 // CallbackGame description of the game that will be launched when the user presses the button.
2414 //
2415 // optional
2416 CallbackGame *CallbackGame `json:"callback_game,omitempty"`
2417 // Pay specify True, to send a Pay button.
2418 //
2419 // NOTE: This type of button must always be the first button in the first row.
2420 //
2421 // optional
2422 Pay bool `json:"pay,omitempty"`
2423}
2424
2425// LoginURL represents a parameter of the inline keyboard button used to
2426// automatically authorize a user. Serves as a great replacement for the
2427// Telegram Login Widget when the user is coming from Telegram. All the user
2428// needs to do is tap/click a button and confirm that they want to log in.
2429type LoginURL struct {
2430 // URL is an HTTP URL to be opened with user authorization data added to the
2431 // query string when the button is pressed. If the user refuses to provide
2432 // authorization data, the original URL without information about the user
2433 // will be opened. The data added is the same as described in Receiving
2434 // authorization data.
2435 //
2436 // NOTE: You must always check the hash of the received data to verify the
2437 // authentication and the integrity of the data as described in Checking
2438 // authorization.
2439 URL string `json:"url"`
2440 // ForwardText is the new text of the button in forwarded messages
2441 //
2442 // optional
2443 ForwardText string `json:"forward_text,omitempty"`
2444 // BotUsername is the username of a bot, which will be used for user
2445 // authorization. See Setting up a bot for more details. If not specified,
2446 // the current bot's username will be assumed. The url's domain must be the
2447 // same as the domain linked with the bot. See Linking your domain to the
2448 // bot for more details.
2449 //
2450 // optional
2451 BotUsername string `json:"bot_username,omitempty"`
2452 // RequestWriteAccess if true requests permission for your bot to send
2453 // messages to the user
2454 //
2455 // optional
2456 RequestWriteAccess bool `json:"request_write_access,omitempty"`
2457}
2458
2459// CallbackQuery represents an incoming callback query from a callback button in
2460// an inline keyboard. If the button that originated the query was attached to a
2461// message sent by the bot, the field message will be present. If the button was
2462// attached to a message sent via the bot (in inline mode), the field
2463// inline_message_id will be present. Exactly one of the fields data or
2464// game_short_name will be present.
2465type CallbackQuery struct {
2466 // ID unique identifier for this query
2467 ID string `json:"id"`
2468 // From sender
2469 From *User `json:"from"`
2470 // Message sent by the bot with the callback button that originated the query
2471 //
2472 // optional
2473 Message *Message `json:"message,omitempty"`
2474 // InlineMessageID identifier of the message sent via the bot in inline
2475 // mode, that originated the query.
2476 //
2477 // optional
2478 InlineMessageID string `json:"inline_message_id,omitempty"`
2479 // ChatInstance global identifier, uniquely corresponding to the chat to
2480 // which the message with the callback button was sent. Useful for high
2481 // scores in games.
2482 ChatInstance string `json:"chat_instance"`
2483 // Data associated with the callback button. Be aware that
2484 // a bad client can send arbitrary data in this field.
2485 //
2486 // optional
2487 Data string `json:"data,omitempty"`
2488 // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
2489 //
2490 // optional
2491 GameShortName string `json:"game_short_name,omitempty"`
2492}
2493
2494// IsInaccessibleMessage method that shows whether message is inaccessible
2495func (c CallbackQuery) IsInaccessibleMessage() bool {
2496 return c.Message != nil && c.Message.Date == 0
2497}
2498
2499func (c CallbackQuery) GetInaccessibleMessage() InaccessibleMessage {
2500 if c.Message == nil {
2501 return InaccessibleMessage{}
2502 }
2503 return InaccessibleMessage{
2504 Chat: c.Message.Chat,
2505 MessageID: c.Message.MessageID,
2506 }
2507}
2508
2509// ForceReply when receiving a message with this object, Telegram clients will
2510// display a reply interface to the user (act as if the user has selected the
2511// bot's message and tapped 'Reply'). This can be extremely useful if you want
2512// to create user-friendly step-by-step interfaces without having to sacrifice
2513// privacy mode.
2514type ForceReply struct {
2515 // ForceReply shows reply interface to the user,
2516 // as if they manually selected the bot's message and tapped 'Reply'.
2517 ForceReply bool `json:"force_reply"`
2518 // InputFieldPlaceholder is the placeholder to be shown in the input field when
2519 // the reply is active; 1-64 characters.
2520 //
2521 // optional
2522 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
2523 // Selective use this parameter if you want to force reply from specific users only.
2524 // Targets:
2525 // 1) users that are @mentioned in the text of the Message object;
2526 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2527 //
2528 // optional
2529 Selective bool `json:"selective,omitempty"`
2530}
2531
2532// ChatPhoto represents a chat photo.
2533type ChatPhoto struct {
2534 // SmallFileID is a file identifier of small (160x160) chat photo.
2535 // This file_id can be used only for photo download and
2536 // only for as long as the photo is not changed.
2537 SmallFileID string `json:"small_file_id"`
2538 // SmallFileUniqueID is a unique file identifier of small (160x160) chat
2539 // photo, which is supposed to be the same over time and for different bots.
2540 // Can't be used to download or reuse the file.
2541 SmallFileUniqueID string `json:"small_file_unique_id"`
2542 // BigFileID is a file identifier of big (640x640) chat photo.
2543 // This file_id can be used only for photo download and
2544 // only for as long as the photo is not changed.
2545 BigFileID string `json:"big_file_id"`
2546 // BigFileUniqueID is a file identifier of big (640x640) chat photo, which
2547 // is supposed to be the same over time and for different bots. Can't be
2548 // used to download or reuse the file.
2549 BigFileUniqueID string `json:"big_file_unique_id"`
2550}
2551
2552// ChatInviteLink represents an invite link for a chat.
2553type ChatInviteLink struct {
2554 // InviteLink is the invite link. If the link was created by another chat
2555 // administrator, then the second part of the link will be replaced with “…”.
2556 InviteLink string `json:"invite_link"`
2557 // Creator of the link.
2558 Creator User `json:"creator"`
2559 // CreatesJoinRequest is true if users joining the chat via the link need to
2560 // be approved by chat administrators.
2561 //
2562 // optional
2563 CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
2564 // IsPrimary is true, if the link is primary.
2565 IsPrimary bool `json:"is_primary"`
2566 // IsRevoked is true, if the link is revoked.
2567 IsRevoked bool `json:"is_revoked"`
2568 // Name is the name of the invite link.
2569 //
2570 // optional
2571 Name string `json:"name,omitempty"`
2572 // ExpireDate is the point in time (Unix timestamp) when the link will
2573 // expire or has been expired.
2574 //
2575 // optional
2576 ExpireDate int `json:"expire_date,omitempty"`
2577 // MemberLimit is the maximum number of users that can be members of the
2578 // chat simultaneously after joining the chat via this invite link; 1-99999.
2579 //
2580 // optional
2581 MemberLimit int `json:"member_limit,omitempty"`
2582 // PendingJoinRequestCount is the number of pending join requests created
2583 // using this link.
2584 //
2585 // optional
2586 PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
2587}
2588
2589type ChatAdministratorRights struct {
2590 IsAnonymous bool `json:"is_anonymous"`
2591 CanManageChat bool `json:"can_manage_chat"`
2592 CanDeleteMessages bool `json:"can_delete_messages"`
2593 CanManageVideoChats bool `json:"can_manage_video_chats"`
2594 CanRestrictMembers bool `json:"can_restrict_members"`
2595 CanPromoteMembers bool `json:"can_promote_members"`
2596 CanChangeInfo bool `json:"can_change_info"`
2597 CanInviteUsers bool `json:"can_invite_users"`
2598 CanPostMessages bool `json:"can_post_messages"`
2599 CanEditMessages bool `json:"can_edit_messages"`
2600 CanPinMessages bool `json:"can_pin_messages"`
2601 CanPostStories bool `json:"can_post_stories"`
2602 CanEditStories bool `json:"can_edit_stories"`
2603 CanDeleteStories bool `json:"can_delete_stories"`
2604 CanManageTopics bool `json:"can_manage_topics"`
2605}
2606
2607// ChatMember contains information about one member of a chat.
2608type ChatMember struct {
2609 // User information about the user
2610 User *User `json:"user"`
2611 // Status the member's status in the chat.
2612 // Can be
2613 // “creator”,
2614 // “administrator”,
2615 // “member”,
2616 // “restricted”,
2617 // “left” or
2618 // “kicked”
2619 Status string `json:"status"`
2620 // CustomTitle owner and administrators only. Custom title for this user
2621 //
2622 // optional
2623 CustomTitle string `json:"custom_title,omitempty"`
2624 // IsAnonymous owner and administrators only. True, if the user's presence
2625 // in the chat is hidden
2626 //
2627 // optional
2628 IsAnonymous bool `json:"is_anonymous,omitempty"`
2629 // UntilDate restricted and kicked only.
2630 // Date when restrictions will be lifted for this user;
2631 // unix time.
2632 //
2633 // optional
2634 UntilDate int64 `json:"until_date,omitempty"`
2635 // CanBeEdited administrators only.
2636 // True, if the bot is allowed to edit administrator privileges of that user.
2637 //
2638 // optional
2639 CanBeEdited bool `json:"can_be_edited,omitempty"`
2640 // CanManageChat administrators only.
2641 // True, if the administrator can access the chat event log, chat
2642 // statistics, message statistics in channels, see channel members, see
2643 // anonymous administrators in supergroups and ignore slow mode. Implied by
2644 // any other administrator privilege.
2645 //
2646 // optional
2647 CanManageChat bool `json:"can_manage_chat,omitempty"`
2648 // CanPostMessages administrators only.
2649 // True, if the administrator can post in the channel;
2650 // channels only.
2651 //
2652 // optional
2653 CanPostMessages bool `json:"can_post_messages,omitempty"`
2654 // CanEditMessages administrators only.
2655 // True, if the administrator can edit messages of other users and can pin messages;
2656 // channels only.
2657 //
2658 // optional
2659 CanEditMessages bool `json:"can_edit_messages,omitempty"`
2660 // CanDeleteMessages administrators only.
2661 // True, if the administrator can delete messages of other users.
2662 //
2663 // optional
2664 CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
2665 // CanManageVideoChats administrators only.
2666 // True, if the administrator can manage video chats.
2667 //
2668 // optional
2669 CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
2670 // CanRestrictMembers administrators only.
2671 // True, if the administrator can restrict, ban or unban chat members.
2672 //
2673 // optional
2674 CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
2675 // CanPromoteMembers administrators only.
2676 // True, if the administrator can add new administrators
2677 // with a subset of their own privileges or demote administrators that he has promoted,
2678 // directly or indirectly (promoted by administrators that were appointed by the user).
2679 //
2680 // optional
2681 CanPromoteMembers bool `json:"can_promote_members,omitempty"`
2682 // CanChangeInfo administrators and restricted only.
2683 // True, if the user is allowed to change the chat title, photo and other settings.
2684 //
2685 // optional
2686 CanChangeInfo bool `json:"can_change_info,omitempty"`
2687 // CanInviteUsers administrators and restricted only.
2688 // True, if the user is allowed to invite new users to the chat.
2689 //
2690 // optional
2691 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2692 // CanPinMessages administrators and restricted only.
2693 // True, if the user is allowed to pin messages; groups and supergroups only
2694 //
2695 // optional
2696 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2697 // CanPostStories administrators only.
2698 // True, if the administrator can post stories in the channel; channels only
2699 //
2700 // optional
2701 CanPostStories bool `json:"can_post_stories,omitempty"`
2702 // CanEditStories administrators only.
2703 // True, if the administrator can edit stories posted by other users; channels only
2704 //
2705 // optional
2706 CanEditStories bool `json:"can_edit_stories,omitempty"`
2707 // CanDeleteStories administrators only.
2708 // True, if the administrator can delete stories posted by other users; channels only
2709 //
2710 // optional
2711 CanDeleteStories bool `json:"can_delete_stories,omitempty"`
2712 // CanManageTopics administrators and restricted only.
2713 // True, if the user is allowed to create, rename,
2714 // close, and reopen forum topics; supergroups only
2715 //
2716 // optional
2717 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2718 // IsMember is true, if the user is a member of the chat at the moment of
2719 // the request
2720 IsMember bool `json:"is_member"`
2721 // CanSendMessages
2722 //
2723 // optional
2724 CanSendMessages bool `json:"can_send_messages,omitempty"`
2725 // CanSendAudios restricted only.
2726 // True, if the user is allowed to send audios
2727 //
2728 // optional
2729 CanSendAudios bool `json:"can_send_audios,omitempty"`
2730 // CanSendDocuments restricted only.
2731 // True, if the user is allowed to send documents
2732 //
2733 // optional
2734 CanSendDocuments bool `json:"can_send_documents,omitempty"`
2735 // CanSendPhotos is restricted only.
2736 // True, if the user is allowed to send photos
2737 //
2738 // optional
2739 CanSendPhotos bool `json:"can_send_photos,omitempty"`
2740 // CanSendVideos restricted only.
2741 // True, if the user is allowed to send videos
2742 //
2743 // optional
2744 CanSendVideos bool `json:"can_send_videos,omitempty"`
2745 // CanSendVideoNotes restricted only.
2746 // True, if the user is allowed to send video notes
2747 //
2748 // optional
2749 CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"`
2750 // CanSendVoiceNotes restricted only.
2751 // True, if the user is allowed to send voice notes
2752 //
2753 // optional
2754 CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"`
2755 // CanSendPolls restricted only.
2756 // True, if the user is allowed to send polls
2757 //
2758 // optional
2759 CanSendPolls bool `json:"can_send_polls,omitempty"`
2760 // CanSendOtherMessages restricted only.
2761 // True, if the user is allowed to send audios, documents,
2762 // photos, videos, video notes and voice notes.
2763 //
2764 // optional
2765 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2766 // CanAddWebPagePreviews restricted only.
2767 // True, if the user is allowed to add web page previews to their messages.
2768 //
2769 // optional
2770 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2771}
2772
2773// IsCreator returns if the ChatMember was the creator of the chat.
2774func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
2775
2776// IsAdministrator returns if the ChatMember is a chat administrator.
2777func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
2778
2779// HasLeft returns if the ChatMember left the chat.
2780func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
2781
2782// WasKicked returns if the ChatMember was kicked from the chat.
2783func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
2784
2785// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2786// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2787// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2788func (chat *ChatMember) SetCanSendMediaMessages(b bool) {
2789 chat.CanSendAudios = b
2790 chat.CanSendDocuments = b
2791 chat.CanSendPhotos = b
2792 chat.CanSendVideos = b
2793 chat.CanSendVideoNotes = b
2794 chat.CanSendVoiceNotes = b
2795}
2796
2797// CanSendMediaMessages method to replace field "can_send_media_messages".
2798// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2799// CanSendVideoNotes and CanSendVoiceNotes are true.
2800func (chat *ChatMember) CanSendMediaMessages() bool {
2801 return chat.CanSendAudios && chat.CanSendDocuments &&
2802 chat.CanSendPhotos && chat.CanSendVideos &&
2803 chat.CanSendVideoNotes && chat.CanSendVoiceNotes
2804}
2805
2806// ChatMemberUpdated represents changes in the status of a chat member.
2807type ChatMemberUpdated struct {
2808 // Chat the user belongs to.
2809 Chat Chat `json:"chat"`
2810 // From is the performer of the action, which resulted in the change.
2811 From User `json:"from"`
2812 // Date the change was done in Unix time.
2813 Date int `json:"date"`
2814 // Previous information about the chat member.
2815 OldChatMember ChatMember `json:"old_chat_member"`
2816 // New information about the chat member.
2817 NewChatMember ChatMember `json:"new_chat_member"`
2818 // InviteLink is the link which was used by the user to join the chat;
2819 // for joining by invite link events only.
2820 //
2821 // optional
2822 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2823 // ViaJoinRequest is true, if the user joined the chat
2824 // after sending a direct join request
2825 // and being approved by an administrator
2826 //
2827 // optional
2828 ViaJoinRequest bool `json:"via_join_request,omitempty"`
2829 // ViaChatFolderInviteLink is True, if the user joined the chat
2830 // via a chat folder invite link
2831 //
2832 // optional
2833 ViaChatFolderInviteLink bool `json:"via_chat_folder_invite_link,omitempty"`
2834}
2835
2836// ChatJoinRequest represents a join request sent to a chat.
2837type ChatJoinRequest struct {
2838 // Chat to which the request was sent.
2839 Chat Chat `json:"chat"`
2840 // User that sent the join request.
2841 From User `json:"from"`
2842 // UserChatID identifier of a private chat with the user who sent the join request.
2843 UserChatID int64 `json:"user_chat_id"`
2844 // Date the request was sent in Unix time.
2845 Date int `json:"date"`
2846 // Bio of the user.
2847 //
2848 // optional
2849 Bio string `json:"bio,omitempty"`
2850 // InviteLink is the link that was used by the user to send the join request.
2851 //
2852 // optional
2853 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2854}
2855
2856// ChatPermissions describes actions that a non-administrator user is
2857// allowed to take in a chat. All fields are optional.
2858type ChatPermissions struct {
2859 // CanSendMessages is true, if the user is allowed to send text messages,
2860 // contacts, locations and venues
2861 //
2862 // optional
2863 CanSendMessages bool `json:"can_send_messages,omitempty"`
2864 // CanSendAudios is true, if the user is allowed to send audios
2865 //
2866 // optional
2867 CanSendAudios bool `json:"can_send_audios,omitempty"`
2868 // CanSendDocuments is true, if the user is allowed to send documents
2869 //
2870 // optional
2871 CanSendDocuments bool `json:"can_send_documents,omitempty"`
2872 // CanSendPhotos is true, if the user is allowed to send photos
2873 //
2874 // optional
2875 CanSendPhotos bool `json:"can_send_photos,omitempty"`
2876 // CanSendVideos is true, if the user is allowed to send videos
2877 //
2878 // optional
2879 CanSendVideos bool `json:"can_send_videos,omitempty"`
2880 // CanSendVideoNotes is true, if the user is allowed to send video notes
2881 //
2882 // optional
2883 CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"`
2884 // CanSendVoiceNotes is true, if the user is allowed to send voice notes
2885 //
2886 // optional
2887 CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"`
2888 // CanSendPolls is true, if the user is allowed to send polls, implies
2889 // can_send_messages
2890 //
2891 // optional
2892 CanSendPolls bool `json:"can_send_polls,omitempty"`
2893 // CanSendOtherMessages is true, if the user is allowed to send animations,
2894 // games, stickers and use inline bots, implies can_send_media_messages
2895 //
2896 // optional
2897 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2898 // CanAddWebPagePreviews is true, if the user is allowed to add web page
2899 // previews to their messages, implies can_send_media_messages
2900 //
2901 // optional
2902 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2903 // CanChangeInfo is true, if the user is allowed to change the chat title,
2904 // photo and other settings. Ignored in public supergroups
2905 //
2906 // optional
2907 CanChangeInfo bool `json:"can_change_info,omitempty"`
2908 // CanInviteUsers is true, if the user is allowed to invite new users to the
2909 // chat
2910 //
2911 // optional
2912 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2913 // CanPinMessages is true, if the user is allowed to pin messages. Ignored
2914 // in public supergroups
2915 //
2916 // optional
2917 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2918 // CanManageTopics is true, if the user is allowed to create forum topics.
2919 // If omitted defaults to the value of can_pin_messages
2920 //
2921 // optional
2922 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2923}
2924
2925// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2926// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2927// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2928func (c *ChatPermissions) SetCanSendMediaMessages(b bool) {
2929 c.CanSendAudios = b
2930 c.CanSendDocuments = b
2931 c.CanSendPhotos = b
2932 c.CanSendVideos = b
2933 c.CanSendVideoNotes = b
2934 c.CanSendVoiceNotes = b
2935}
2936
2937// CanSendMediaMessages method to replace field "can_send_media_messages".
2938// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2939// CanSendVideoNotes and CanSendVoiceNotes are true.
2940func (c *ChatPermissions) CanSendMediaMessages() bool {
2941 return c.CanSendAudios && c.CanSendDocuments &&
2942 c.CanSendPhotos && c.CanSendVideos &&
2943 c.CanSendVideoNotes && c.CanSendVoiceNotes
2944}
2945
2946// Birthdate represents a user's birthdate
2947type Birthdate struct {
2948 // Day of the user's birth; 1-31
2949 Day int `json:"day"`
2950 // Month of the user's birth; 1-12
2951 Month int `json:"month"`
2952 // Year of the user's birth
2953 //
2954 // optional
2955 Year *int `json:"year,omitempty"`
2956}
2957
2958// BusinessIntro represents a basic information about your business
2959type BusinessIntro struct {
2960 // Title text of the business intro
2961 //
2962 // optional
2963 Title *string `json:"title,omitempty"`
2964 // Message text of the business intro
2965 //
2966 // optional
2967 Message *string `json:"message,omitempty"`
2968 // Sticker of the business intro
2969 //
2970 // optional
2971 Sticker *Sticker `json:"sticker,omitempty"`
2972}
2973
2974// BusinessLocation represents a business geodata
2975type BusinessLocation struct {
2976 // Address of the business
2977 Address string `json:"address"`
2978 // Location of the business
2979 //
2980 // optional
2981 Location *Location `json:"location,omitempty"`
2982}
2983
2984// BusinessOpeningHoursInterval represents a business working interval
2985type BusinessOpeningHoursInterval struct {
2986 // OpeningMinute is the minute's sequence number in a week, starting on Monday,
2987 // marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60
2988 OpeningMinute int `json:"opening_minute"`
2989 // ClosingMinute is the minute's sequence number in a week, starting on Monday,
2990 // marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60
2991 ClosingMinute int `json:"closing_minute"`
2992}
2993
2994// BusinessOpeningHours represents a set of business working intervals
2995type BusinessOpeningHours struct {
2996 // TimeZoneName is the unique name of the time zone
2997 // for which the opening hours are defined
2998 TimeZoneName string `json:"time_zone_name"`
2999 // OpeningHours is the list of time intervals describing
3000 // business opening hours
3001 OpeningHours []BusinessOpeningHoursInterval `json:"opening_hours"`
3002}
3003
3004// ChatLocation represents a location to which a chat is connected.
3005type ChatLocation struct {
3006 // Location is the location to which the supergroup is connected. Can't be a
3007 // live location.
3008 Location Location `json:"location"`
3009 // Address is the location address; 1-64 characters, as defined by the chat
3010 // owner
3011 Address string `json:"address"`
3012}
3013
3014const (
3015 ReactionTypeEmoji = "emoji"
3016 ReactionTypeCustomEmoji = "custom_emoji"
3017)
3018
3019// ReactionType describes the type of a reaction. Currently, it can be one of: "emoji", "custom_emoji"
3020type ReactionType struct {
3021 // Type of the reaction. Can be "emoji", "custom_emoji"
3022 Type string `json:"type"`
3023 // Emoji type "emoji" only. Is a reaction emoji.
3024 Emoji string `json:"emoji"`
3025 // CustomEmoji type "custom_emoji" only. Is a custom emoji identifier.
3026 CustomEmoji string `json:"custom_emoji"`
3027}
3028
3029func (r ReactionType) IsEmoji() bool {
3030 return r.Type == ReactionTypeEmoji
3031}
3032
3033func (r ReactionType) IsCustomEmoji() bool {
3034 return r.Type == ReactionTypeCustomEmoji
3035}
3036
3037// ReactionCount represents a reaction added to a message along with the number of times it was added.
3038type ReactionCount struct {
3039 // Type of the reaction
3040 Type ReactionType `json:"type"`
3041 // TotalCount number of times the reaction was added
3042 TotalCount int `json:"total_count"`
3043}
3044
3045// MessageReactionUpdated represents a change of a reaction on a message performed by a user.
3046type MessageReactionUpdated struct {
3047 // Chat containing the message the user reacted to.
3048 Chat Chat `json:"chat"`
3049 // MessageID unique identifier of the message inside the chat.
3050 MessageID int `json:"message_id"`
3051 // User that changed the reaction, if the user isn't anonymous.
3052 //
3053 // optional
3054 User *User `json:"user"`
3055 // ActorChat the chat on behalf of which the reaction was changed,
3056 // if the user is anonymous.
3057 //
3058 // optional
3059 ActorChat *Chat `json:"actor_chat"`
3060 // Date of the change in Unix time.
3061 Date int64 `json:"date"`
3062 // OldReaction is a previous list of reaction types that were set by the user.
3063 OldReaction []ReactionType `json:"old_reaction"`
3064 // NewReaction is a new list of reaction types that have been set by the user.
3065 NewReaction []ReactionType `json:"new_reaction"`
3066}
3067
3068// MessageReactionCountUpdated represents reaction changes on a message with anonymous reactions.
3069type MessageReactionCountUpdated struct {
3070 // Chat containing the message.
3071 Chat Chat `json:"chat"`
3072 // MessageID unique identifier of the message inside the chat.
3073 MessageID int `json:"message_id"`
3074 // Date of the change in Unix time.
3075 Date int64 `json:"date"`
3076 // Reactions is a list of reactions that are present on the message.
3077 Reactions []ReactionCount `json:"reactions"`
3078}
3079
3080// ForumTopic represents a forum topic.
3081type ForumTopic struct {
3082 // MessageThreadID is the unique identifier of the forum topic
3083 MessageThreadID int `json:"message_thread_id"`
3084 // Name is the name of the topic
3085 Name string `json:"name"`
3086 // IconColor is the color of the topic icon in RGB format
3087 IconColor int `json:"icon_color"`
3088 // IconCustomEmojiID is the unique identifier of the custom emoji
3089 // shown as the topic icon
3090 //
3091 // optional
3092 IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
3093}
3094
3095// BotCommand represents a bot command.
3096type BotCommand struct {
3097 // Command text of the command, 1-32 characters.
3098 // Can contain only lowercase English letters, digits and underscores.
3099 Command string `json:"command"`
3100 // Description of the command, 3-256 characters.
3101 Description string `json:"description"`
3102}
3103
3104// BotCommandScope represents the scope to which bot commands are applied.
3105//
3106// It contains the fields for all types of scopes, different types only support
3107// specific (or no) fields.
3108type BotCommandScope struct {
3109 Type string `json:"type"`
3110 ChatID int64 `json:"chat_id,omitempty"`
3111 UserID int64 `json:"user_id,omitempty"`
3112}
3113
3114// BotName represents the bot's name.
3115type BotName struct {
3116 Name string `json:"name"`
3117}
3118
3119// BotDescription represents the bot's description.
3120type BotDescription struct {
3121 Description string `json:"description"`
3122}
3123
3124// BotShortDescription represents the bot's short description
3125type BotShortDescription struct {
3126 ShortDescription string `json:"short_description"`
3127}
3128
3129// MenuButton describes the bot's menu button in a private chat.
3130type MenuButton struct {
3131 // Type is the type of menu button, must be one of:
3132 // - `commands`
3133 // - `web_app`
3134 // - `default`
3135 Type string `json:"type"`
3136 // Text is the text on the button, for `web_app` type.
3137 Text string `json:"text,omitempty"`
3138 // WebApp is the description of the Web App that will be launched when the
3139 // user presses the button for the `web_app` type.
3140 WebApp *WebAppInfo `json:"web_app,omitempty"`
3141}
3142
3143const (
3144 ChatBoostSourcePremium = "premium"
3145 ChatBoostSourceGiftCode = "gift_code"
3146 ChatBoostSourceGiveaway = "giveaway"
3147)
3148
3149// ChatBoostSource describes the source of a chat boost
3150type ChatBoostSource struct {
3151 // Source of the boost, It can be one of:
3152 // "premium", "gift_code", "giveaway"
3153 Source string `json:"source"`
3154 // For "premium": User that boosted the chat
3155 // For "gift_code": User for which the gift code was created
3156 // Optional for "giveaway": User that won the prize in the giveaway if any
3157 User *User `json:"user,omitempty"`
3158 // GiveawayMessageID "giveaway" only.
3159 // Is an identifier of a message in the chat with the giveaway;
3160 // the message could have been deleted already. May be 0 if the message isn't sent yet.
3161 GiveawayMessageID int `json:"giveaway_message_id,omitempty"`
3162 // IsUnclaimed "giveaway" only.
3163 // True, if the giveaway was completed, but there was no user to win the prize
3164 //
3165 // optional
3166 IsUnclaimed bool `json:"is_unclaimed,omitempty"`
3167}
3168
3169func (c ChatBoostSource) IsPremium() bool {
3170 return c.Source == ChatBoostSourcePremium
3171}
3172
3173func (c ChatBoostSource) IsGiftCode() bool {
3174 return c.Source == ChatBoostSourceGiftCode
3175}
3176
3177func (c ChatBoostSource) IsGiveaway() bool {
3178 return c.Source == ChatBoostSourceGiveaway
3179}
3180
3181// ChatBoost contains information about a chat boost.
3182type ChatBoost struct {
3183 // BoostID is an unique identifier of the boost
3184 BoostID string `json:"boost_id"`
3185 // AddDate is a point in time (Unix timestamp) when the chat was boosted
3186 AddDate int64 `json:"add_date"`
3187 // ExpirationDate is a point in time (Unix timestamp) when the boost will
3188 // automatically expire, unless the booster's Telegram Premium subscription is prolonged
3189 ExpirationDate int64 `json:"expiration_date"`
3190 // Source of the added boost
3191 Source ChatBoostSource `json:"source"`
3192}
3193
3194// ChatBoostUpdated represents a boost added to a chat or changed.
3195type ChatBoostUpdated struct {
3196 // Chat which was boosted
3197 Chat Chat `json:"chat"`
3198 // Boost infomation about the chat boost
3199 Boost ChatBoost `json:"boost"`
3200}
3201
3202// ChatBoostRemoved represents a boost removed from a chat.
3203type ChatBoostRemoved struct {
3204 // Chat which was boosted
3205 Chat Chat `json:"chat"`
3206 // BoostID unique identifier of the boost
3207 BoostID string `json:"boost_id"`
3208 // RemoveDate point in time (Unix timestamp) when the boost was removed
3209 RemoveDate int64 `json:"remove_date"`
3210 // Source of the removed boost
3211 Source ChatBoostSource `json:"source"`
3212}
3213
3214// UserChatBoosts represents a list of boosts added to a chat by a user.
3215type UserChatBoosts struct {
3216 // Boosts is the list of boosts added to the chat by the user
3217 Boosts []ChatBoost `json:"boosts"`
3218}
3219
3220// BusinessConnection describes the connection of the bot with a business account.
3221type BusinessConnection struct {
3222 // ID is an unique identifier of the business connection
3223 ID string `json:"id"`
3224 // User is a business account user that created the business connection
3225 User User `json:"user"`
3226 // UserChatID identifier of a private chat with the user who
3227 // created the business connection.
3228 UserChatID int64 `json:"user_chat_id"`
3229 // Date the connection was established in Unix time
3230 Date int64 `json:"date"`
3231 // CanReply is True, if the bot can act on behalf of the
3232 // business account in chats that were active in the last 24 hours
3233 CanReply bool `json:"can_reply"`
3234 // IsEnabled is True, if the connection is active
3235 IsEnabled bool `json:"is_enabled"`
3236}
3237
3238// BusinessMessagesDeleted is received when messages are deleted
3239// from a connected business account.
3240type BusinessMessagesDeleted struct {
3241 // BusinessConnectionID is an unique identifier
3242 // of the business connection
3243 BusinessConnectionID string `json:"business_connection_id"`
3244 // Chat is the information about a chat in the business account.
3245 // The bot may not have access to the chat or the corresponding user.
3246 Chat Chat `json:"chat"`
3247 // MessageIDs is a JSON-serialized list of identifiers of deleted messages
3248 // in the chat of the business account
3249 MessageIDs []int `json:"message_ids"`
3250}
3251
3252// ResponseParameters are various errors that can be returned in APIResponse.
3253type ResponseParameters struct {
3254 // The group has been migrated to a supergroup with the specified identifier.
3255 //
3256 // optional
3257 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
3258 // In case of exceeding flood control, the number of seconds left to wait
3259 // before the request can be repeated.
3260 //
3261 // optional
3262 RetryAfter int `json:"retry_after,omitempty"`
3263}
3264
3265// BaseInputMedia is a base type for the InputMedia types.
3266type BaseInputMedia struct {
3267 // Type of the result.
3268 Type string `json:"type"`
3269 // Media file to send. Pass a file_id to send a file
3270 // that exists on the Telegram servers (recommended),
3271 // pass an HTTP URL for Telegram to get a file from the Internet,
3272 // or pass “attach://<file_attach_name>” to upload a new one
3273 // using multipart/form-data under <file_attach_name> name.
3274 Media RequestFileData `json:"media"`
3275 // thumb intentionally missing as it is not currently compatible
3276
3277 // Caption of the video to be sent, 0-1024 characters after entities parsing.
3278 //
3279 // optional
3280 Caption string `json:"caption,omitempty"`
3281 // ParseMode mode for parsing entities in the video caption.
3282 // See formatting options for more details
3283 // (https://core.telegram.org/bots/api#formatting-options).
3284 //
3285 // optional
3286 ParseMode string `json:"parse_mode,omitempty"`
3287 // CaptionEntities is a list of special entities that appear in the caption,
3288 // which can be specified instead of parse_mode
3289 //
3290 // optional
3291 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3292 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
3293 //
3294 // optional
3295 HasSpoiler bool `json:"has_spoiler,omitempty"`
3296}
3297
3298// InputMediaPhoto is a photo to send as part of a media group.
3299type InputMediaPhoto struct {
3300 BaseInputMedia
3301}
3302
3303// InputMediaVideo is a video to send as part of a media group.
3304type InputMediaVideo struct {
3305 BaseInputMedia
3306 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3307 // the file is supported server-side.
3308 //
3309 // optional
3310 Thumb RequestFileData `json:"thumbnail,omitempty"`
3311 // Width video width
3312 //
3313 // optional
3314 Width int `json:"width,omitempty"`
3315 // Height video height
3316 //
3317 // optional
3318 Height int `json:"height,omitempty"`
3319 // Duration video duration
3320 //
3321 // optional
3322 Duration int `json:"duration,omitempty"`
3323 // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
3324 //
3325 // optional
3326 SupportsStreaming bool `json:"supports_streaming,omitempty"`
3327 // HasSpoiler pass True, if the video needs to be covered with a spoiler animation
3328 //
3329 // optional
3330 HasSpoiler bool `json:"has_spoiler,omitempty"`
3331}
3332
3333// InputMediaAnimation is an animation to send as part of a media group.
3334type InputMediaAnimation struct {
3335 BaseInputMedia
3336 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3337 // the file is supported server-side.
3338 //
3339 // optional
3340 Thumb RequestFileData `json:"thumbnail,omitempty"`
3341 // Width video width
3342 //
3343 // optional
3344 Width int `json:"width,omitempty"`
3345 // Height video height
3346 //
3347 // optional
3348 Height int `json:"height,omitempty"`
3349 // Duration video duration
3350 //
3351 // optional
3352 Duration int `json:"duration,omitempty"`
3353 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
3354 //
3355 // optional
3356 HasSpoiler bool `json:"has_spoiler,omitempty"`
3357}
3358
3359// InputMediaAudio is an audio to send as part of a media group.
3360type InputMediaAudio struct {
3361 BaseInputMedia
3362 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3363 // the file is supported server-side.
3364 //
3365 // optional
3366 Thumb RequestFileData `json:"thumbnail,omitempty"`
3367 // Duration of the audio in seconds
3368 //
3369 // optional
3370 Duration int `json:"duration,omitempty"`
3371 // Performer of the audio
3372 //
3373 // optional
3374 Performer string `json:"performer,omitempty"`
3375 // Title of the audio
3376 //
3377 // optional
3378 Title string `json:"title,omitempty"`
3379}
3380
3381// InputMediaDocument is a general file to send as part of a media group.
3382type InputMediaDocument struct {
3383 BaseInputMedia
3384 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3385 // the file is supported server-side.
3386 //
3387 // optional
3388 Thumb RequestFileData `json:"thumbnail,omitempty"`
3389 // DisableContentTypeDetection disables automatic server-side content type
3390 // detection for files uploaded using multipart/form-data. Always true, if
3391 // the document is sent as part of an album
3392 //
3393 // optional
3394 DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
3395}
3396
3397// Constant values for sticker types
3398const (
3399 StickerTypeRegular = "regular"
3400 StickerTypeMask = "mask"
3401 StickerTypeCustomEmoji = "custom_emoji"
3402)
3403
3404// Sticker represents a sticker.
3405type Sticker struct {
3406 // FileID is an identifier for this file, which can be used to download or
3407 // reuse the file
3408 FileID string `json:"file_id"`
3409 // FileUniqueID is a unique identifier for this file,
3410 // which is supposed to be the same over time and for different bots.
3411 // Can't be used to download or reuse the file.
3412 FileUniqueID string `json:"file_unique_id"`
3413 // Type is a type of the sticker, currently one of “regular”,
3414 // “mask”, “custom_emoji”. The type of the sticker is independent
3415 // from its format, which is determined by the fields is_animated and is_video.
3416 Type string `json:"type"`
3417 // Width sticker width
3418 Width int `json:"width"`
3419 // Height sticker height
3420 Height int `json:"height"`
3421 // IsAnimated true, if the sticker is animated
3422 //
3423 // optional
3424 IsAnimated bool `json:"is_animated,omitempty"`
3425 // IsVideo true, if the sticker is a video sticker
3426 //
3427 // optional
3428 IsVideo bool `json:"is_video,omitempty"`
3429 // Thumbnail sticker thumbnail in the .WEBP or .JPG format
3430 //
3431 // optional
3432 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
3433 // Emoji associated with the sticker
3434 //
3435 // optional
3436 Emoji string `json:"emoji,omitempty"`
3437 // SetName of the sticker set to which the sticker belongs
3438 //
3439 // optional
3440 SetName string `json:"set_name,omitempty"`
3441 // PremiumAnimation for premium regular stickers, premium animation for the sticker
3442 //
3443 // optional
3444 PremiumAnimation *File `json:"premium_animation,omitempty"`
3445 // MaskPosition is for mask stickers, the position where the mask should be
3446 // placed
3447 //
3448 // optional
3449 MaskPosition *MaskPosition `json:"mask_position,omitempty"`
3450 // CustomEmojiID for custom emoji stickers, unique identifier of the custom emoji
3451 //
3452 // optional
3453 CustomEmojiID string `json:"custom_emoji_id,omitempty"`
3454 // 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
3455 //
3456 //optional
3457 NeedsRepainting bool `json:"needs_reainting,omitempty"`
3458 // FileSize
3459 //
3460 // optional
3461 FileSize int `json:"file_size,omitempty"`
3462}
3463
3464// IsRegular returns if the Sticker is regular
3465func (s Sticker) IsRegular() bool {
3466 return s.Type == StickerTypeRegular
3467}
3468
3469// IsMask returns if the Sticker is mask
3470func (s Sticker) IsMask() bool {
3471 return s.Type == StickerTypeMask
3472}
3473
3474// IsCustomEmoji returns if the Sticker is custom emoji
3475func (s Sticker) IsCustomEmoji() bool {
3476 return s.Type == StickerTypeCustomEmoji
3477}
3478
3479// StickerSet represents a sticker set.
3480type StickerSet struct {
3481 // Name sticker set name
3482 Name string `json:"name"`
3483 // Title sticker set title
3484 Title string `json:"title"`
3485 // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
3486 StickerType string `json:"sticker_type"`
3487 // ContainsMasks true, if the sticker set contains masks
3488 //
3489 // deprecated. Use sticker_type instead
3490 ContainsMasks bool `json:"contains_masks"`
3491 // Stickers list of all set stickers
3492 Stickers []Sticker `json:"stickers"`
3493 // Thumb is the sticker set thumbnail in the .WEBP or .TGS format
3494 Thumbnail *PhotoSize `json:"thumbnail"`
3495}
3496
3497// IsRegular returns if the StickerSet is regular
3498func (s StickerSet) IsRegular() bool {
3499 return s.StickerType == StickerTypeRegular
3500}
3501
3502// IsMask returns if the StickerSet is mask
3503func (s StickerSet) IsMask() bool {
3504 return s.StickerType == StickerTypeMask
3505}
3506
3507// IsCustomEmoji returns if the StickerSet is custom emoji
3508func (s StickerSet) IsCustomEmoji() bool {
3509 return s.StickerType == StickerTypeCustomEmoji
3510}
3511
3512// MaskPosition describes the position on faces where a mask should be placed
3513// by default.
3514type MaskPosition struct {
3515 // The part of the face relative to which the mask should be placed.
3516 // One of “forehead”, “eyes”, “mouth”, or “chin”.
3517 Point string `json:"point"`
3518 // Shift by X-axis measured in widths of the mask scaled to the face size,
3519 // from left to right. For example, choosing -1.0 will place mask just to
3520 // the left of the default mask position.
3521 XShift float64 `json:"x_shift"`
3522 // Shift by Y-axis measured in heights of the mask scaled to the face size,
3523 // from top to bottom. For example, 1.0 will place the mask just below the
3524 // default mask position.
3525 YShift float64 `json:"y_shift"`
3526 // Mask scaling coefficient. For example, 2.0 means double size.
3527 Scale float64 `json:"scale"`
3528}
3529
3530// InputSticker describes a sticker to be added to a sticker set.
3531type InputSticker struct {
3532 // 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.
3533 Sticker RequestFile `json:"sticker"`
3534 // Format of the added sticker, must be one of “static” for a
3535 // .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video
3536 Format string `json:"format"`
3537 // List of 1-20 emoji associated with the sticker
3538 EmojiList []string `json:"emoji_list"`
3539 // Position where the mask should be placed on faces. For “mask” stickers only.
3540 //
3541 // optional
3542 MaskPosition *MaskPosition `json:"mask_position"`
3543 // List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only.
3544 //
3545 // optional
3546 Keywords []string `json:"keywords"`
3547}
3548
3549// Game represents a game. Use BotFather to create and edit games, their short
3550// names will act as unique identifiers.
3551type Game struct {
3552 // Title of the game
3553 Title string `json:"title"`
3554 // Description of the game
3555 Description string `json:"description"`
3556 // Photo that will be displayed in the game message in chats.
3557 Photo []PhotoSize `json:"photo"`
3558 // Text a brief description of the game or high scores included in the game message.
3559 // Can be automatically edited to include current high scores for the game
3560 // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
3561 //
3562 // optional
3563 Text string `json:"text,omitempty"`
3564 // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
3565 //
3566 // optional
3567 TextEntities []MessageEntity `json:"text_entities,omitempty"`
3568 // Animation is an animation that will be displayed in the game message in chats.
3569 // Upload via BotFather (https://t.me/botfather).
3570 //
3571 // optional
3572 Animation Animation `json:"animation,omitempty"`
3573}
3574
3575// GameHighScore is a user's score and position on the leaderboard.
3576type GameHighScore struct {
3577 // Position in high score table for the game
3578 Position int `json:"position"`
3579 // User user
3580 User User `json:"user"`
3581 // Score score
3582 Score int `json:"score"`
3583}
3584
3585// CallbackGame is for starting a game in an inline keyboard button.
3586type CallbackGame struct{}
3587
3588// SwitchInlineQueryChosenChat represents an inline button that switches the current
3589// user to inline mode in a chosen chat, with an optional default inline query.
3590type SwitchInlineQueryChosenChat struct {
3591 // Query is default inline query to be inserted in the input field.
3592 // If left empty, only the bot's username will be inserted
3593 //
3594 // optional
3595 Query string `json:"query,omitempty"`
3596 // AllowUserChats is True, if private chats with users can be chosen
3597 //
3598 // optional
3599 AllowUserChats bool `json:"allow_user_chats,omitempty"`
3600 // AllowBotChats is True, if private chats with bots can be chosen
3601 //
3602 // optional
3603 AllowBotChats bool `json:"allow_bot_chats,omitempty"`
3604 // AllowGroupChats is True, if group and supergroup chats can be chosen
3605 //
3606 // optional
3607 AllowGroupChats bool `json:"allow_group_chats,omitempty"`
3608 // AllowChannelChats is True, if channel chats can be chosen
3609 //
3610 // optional
3611 AllowChannelChats bool `json:"allow_channel_chats,omitempty"`
3612}
3613
3614// WebhookInfo is information about a currently set webhook.
3615type WebhookInfo struct {
3616 // URL webhook URL, may be empty if webhook is not set up.
3617 URL string `json:"url"`
3618 // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
3619 HasCustomCertificate bool `json:"has_custom_certificate"`
3620 // PendingUpdateCount number of updates awaiting delivery.
3621 PendingUpdateCount int `json:"pending_update_count"`
3622 // IPAddress is the currently used webhook IP address
3623 //
3624 // optional
3625 IPAddress string `json:"ip_address,omitempty"`
3626 // LastErrorDate unix time for the most recent error
3627 // that happened when trying to deliver an update via webhook.
3628 //
3629 // optional
3630 LastErrorDate int `json:"last_error_date,omitempty"`
3631 // LastErrorMessage error message in human-readable format for the most recent error
3632 // that happened when trying to deliver an update via webhook.
3633 //
3634 // optional
3635 LastErrorMessage string `json:"last_error_message,omitempty"`
3636 // LastSynchronizationErrorDate is the unix time of the most recent error that
3637 // happened when trying to synchronize available updates with Telegram datacenters.
3638 LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
3639 // MaxConnections maximum allowed number of simultaneous
3640 // HTTPS connections to the webhook for update delivery.
3641 //
3642 // optional
3643 MaxConnections int `json:"max_connections,omitempty"`
3644 // AllowedUpdates is a list of update types the bot is subscribed to.
3645 // Defaults to all update types
3646 //
3647 // optional
3648 AllowedUpdates []string `json:"allowed_updates,omitempty"`
3649}
3650
3651// IsSet returns true if a webhook is currently set.
3652func (info WebhookInfo) IsSet() bool {
3653 return info.URL != ""
3654}
3655
3656// InlineQuery is a Query from Telegram for an inline request.
3657type InlineQuery struct {
3658 // ID unique identifier for this query
3659 ID string `json:"id"`
3660 // From sender
3661 From *User `json:"from"`
3662 // Query text of the query (up to 256 characters).
3663 Query string `json:"query"`
3664 // Offset of the results to be returned, can be controlled by the bot.
3665 Offset string `json:"offset"`
3666 // Type of the chat, from which the inline query was sent. Can be either
3667 // “sender” for a private chat with the inline query sender, “private”,
3668 // “group”, “supergroup”, or “channel”. The chat type should be always known
3669 // for requests sent from official clients and most third-party clients,
3670 // unless the request was sent from a secret chat
3671 //
3672 // optional
3673 ChatType string `json:"chat_type,omitempty"`
3674 // Location sender location, only for bots that request user location.
3675 //
3676 // optional
3677 Location *Location `json:"location,omitempty"`
3678}
3679
3680// InlineQueryResultCachedAudio is an inline query response with cached audio.
3681type InlineQueryResultCachedAudio struct {
3682 // Type of the result, must be audio
3683 Type string `json:"type"`
3684 // ID unique identifier for this result, 1-64 bytes
3685 ID string `json:"id"`
3686 // AudioID a valid file identifier for the audio file
3687 AudioID string `json:"audio_file_id"`
3688 // Caption 0-1024 characters after entities parsing
3689 //
3690 // optional
3691 Caption string `json:"caption,omitempty"`
3692 // ParseMode mode for parsing entities in the video caption.
3693 // See formatting options for more details
3694 // (https://core.telegram.org/bots/api#formatting-options).
3695 //
3696 // optional
3697 ParseMode string `json:"parse_mode,omitempty"`
3698 // CaptionEntities is a list of special entities that appear in the caption,
3699 // which can be specified instead of parse_mode
3700 //
3701 // optional
3702 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3703 // ReplyMarkup inline keyboard attached to the message
3704 //
3705 // optional
3706 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3707 // InputMessageContent content of the message to be sent instead of the audio
3708 //
3709 // optional
3710 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3711}
3712
3713// InlineQueryResultCachedDocument is an inline query response with cached document.
3714type InlineQueryResultCachedDocument struct {
3715 // Type of the result, must be a document
3716 Type string `json:"type"`
3717 // ID unique identifier for this result, 1-64 bytes
3718 ID string `json:"id"`
3719 // DocumentID a valid file identifier for the file
3720 DocumentID string `json:"document_file_id"`
3721 // Title for the result
3722 //
3723 // optional
3724 Title string `json:"title,omitempty"`
3725 // Caption of the document to be sent, 0-1024 characters after entities parsing
3726 //
3727 // optional
3728 Caption string `json:"caption,omitempty"`
3729 // Description short description of the result
3730 //
3731 // optional
3732 Description string `json:"description,omitempty"`
3733 // ParseMode mode for parsing entities in the video caption.
3734 // // See formatting options for more details
3735 // // (https://core.telegram.org/bots/api#formatting-options).
3736 //
3737 // optional
3738 ParseMode string `json:"parse_mode,omitempty"`
3739 // CaptionEntities is a list of special entities that appear in the caption,
3740 // which can be specified instead of parse_mode
3741 //
3742 // optional
3743 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3744 // ReplyMarkup inline keyboard attached to the message
3745 //
3746 // optional
3747 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3748 // InputMessageContent content of the message to be sent instead of the file
3749 //
3750 // optional
3751 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3752}
3753
3754// InlineQueryResultCachedGIF is an inline query response with cached gif.
3755type InlineQueryResultCachedGIF struct {
3756 // Type of the result, must be gif.
3757 Type string `json:"type"`
3758 // ID unique identifier for this result, 1-64 bytes.
3759 ID string `json:"id"`
3760 // GifID a valid file identifier for the GIF file.
3761 GIFID string `json:"gif_file_id"`
3762 // Title for the result
3763 //
3764 // optional
3765 Title string `json:"title,omitempty"`
3766 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
3767 //
3768 // optional
3769 Caption string `json:"caption,omitempty"`
3770 // ParseMode mode for parsing entities in the caption.
3771 // See formatting options for more details
3772 // (https://core.telegram.org/bots/api#formatting-options).
3773 //
3774 // optional
3775 ParseMode string `json:"parse_mode,omitempty"`
3776 // CaptionEntities is a list of special entities that appear in the caption,
3777 // which can be specified instead of parse_mode
3778 //
3779 // optional
3780 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3781 // ReplyMarkup inline keyboard attached to the message.
3782 //
3783 // optional
3784 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3785 // InputMessageContent content of the message to be sent instead of the GIF animation.
3786 //
3787 // optional
3788 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3789}
3790
3791// InlineQueryResultCachedMPEG4GIF is an inline query response with cached
3792// H.264/MPEG-4 AVC video without sound gif.
3793type InlineQueryResultCachedMPEG4GIF struct {
3794 // Type of the result, must be mpeg4_gif
3795 Type string `json:"type"`
3796 // ID unique identifier for this result, 1-64 bytes
3797 ID string `json:"id"`
3798 // MPEG4FileID a valid file identifier for the MP4 file
3799 MPEG4FileID string `json:"mpeg4_file_id"`
3800 // Title for the result
3801 //
3802 // optional
3803 Title string `json:"title,omitempty"`
3804 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
3805 //
3806 // optional
3807 Caption string `json:"caption,omitempty"`
3808 // ParseMode mode for parsing entities in the caption.
3809 // See formatting options for more details
3810 // (https://core.telegram.org/bots/api#formatting-options).
3811 //
3812 // optional
3813 ParseMode string `json:"parse_mode,omitempty"`
3814 // ParseMode mode for parsing entities in the video caption.
3815 // See formatting options for more details
3816 // (https://core.telegram.org/bots/api#formatting-options).
3817 //
3818 // optional
3819 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3820 // ReplyMarkup inline keyboard attached to the message.
3821 //
3822 // optional
3823 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3824 // InputMessageContent content of the message to be sent instead of the video animation.
3825 //
3826 // optional
3827 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3828}
3829
3830// InlineQueryResultCachedPhoto is an inline query response with cached photo.
3831type InlineQueryResultCachedPhoto struct {
3832 // Type of the result, must be a photo.
3833 Type string `json:"type"`
3834 // ID unique identifier for this result, 1-64 bytes.
3835 ID string `json:"id"`
3836 // PhotoID a valid file identifier of the photo.
3837 PhotoID string `json:"photo_file_id"`
3838 // Title for the result.
3839 //
3840 // optional
3841 Title string `json:"title,omitempty"`
3842 // Description short description of the result.
3843 //
3844 // optional
3845 Description string `json:"description,omitempty"`
3846 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
3847 //
3848 // optional
3849 Caption string `json:"caption,omitempty"`
3850 // ParseMode mode for parsing entities in the photo caption.
3851 // See formatting options for more details
3852 // (https://core.telegram.org/bots/api#formatting-options).
3853 //
3854 // optional
3855 ParseMode string `json:"parse_mode,omitempty"`
3856 // CaptionEntities is a list of special entities that appear in the caption,
3857 // which can be specified instead of parse_mode
3858 //
3859 // optional
3860 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3861 // ReplyMarkup inline keyboard attached to the message.
3862 //
3863 // optional
3864 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3865 // InputMessageContent content of the message to be sent instead of the photo.
3866 //
3867 // optional
3868 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3869}
3870
3871// InlineQueryResultCachedSticker is an inline query response with cached sticker.
3872type InlineQueryResultCachedSticker struct {
3873 // Type of the result, must be a sticker
3874 Type string `json:"type"`
3875 // ID unique identifier for this result, 1-64 bytes
3876 ID string `json:"id"`
3877 // StickerID a valid file identifier of the sticker
3878 StickerID string `json:"sticker_file_id"`
3879 // Title is a title
3880 Title string `json:"title"`
3881 // ReplyMarkup inline keyboard attached to the message
3882 //
3883 // optional
3884 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3885 // InputMessageContent content of the message to be sent instead of the sticker
3886 //
3887 // optional
3888 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3889}
3890
3891// InlineQueryResultCachedVideo is an inline query response with cached video.
3892type InlineQueryResultCachedVideo struct {
3893 // Type of the result, must be video
3894 Type string `json:"type"`
3895 // ID unique identifier for this result, 1-64 bytes
3896 ID string `json:"id"`
3897 // VideoID a valid file identifier for the video file
3898 VideoID string `json:"video_file_id"`
3899 // Title for the result
3900 Title string `json:"title"`
3901 // Description short description of the result
3902 //
3903 // optional
3904 Description string `json:"description,omitempty"`
3905 // Caption of the video to be sent, 0-1024 characters after entities parsing
3906 //
3907 // optional
3908 Caption string `json:"caption,omitempty"`
3909 // ParseMode mode for parsing entities in the video caption.
3910 // See formatting options for more details
3911 // (https://core.telegram.org/bots/api#formatting-options).
3912 //
3913 // optional
3914 ParseMode string `json:"parse_mode,omitempty"`
3915 // CaptionEntities is a list of special entities that appear in the caption,
3916 // which can be specified instead of parse_mode
3917 //
3918 // optional
3919 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3920 // ReplyMarkup inline keyboard attached to the message
3921 //
3922 // optional
3923 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3924 // InputMessageContent content of the message to be sent instead of the video
3925 //
3926 // optional
3927 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3928}
3929
3930// InlineQueryResultCachedVoice is an inline query response with cached voice.
3931type InlineQueryResultCachedVoice struct {
3932 // Type of the result, must be voice
3933 Type string `json:"type"`
3934 // ID unique identifier for this result, 1-64 bytes
3935 ID string `json:"id"`
3936 // VoiceID a valid file identifier for the voice message
3937 VoiceID string `json:"voice_file_id"`
3938 // Title voice message title
3939 Title string `json:"title"`
3940 // Caption 0-1024 characters after entities parsing
3941 //
3942 // optional
3943 Caption string `json:"caption,omitempty"`
3944 // ParseMode mode for parsing entities in the video caption.
3945 // See formatting options for more details
3946 // (https://core.telegram.org/bots/api#formatting-options).
3947 //
3948 // optional
3949 ParseMode string `json:"parse_mode,omitempty"`
3950 // CaptionEntities is a list of special entities that appear in the caption,
3951 // which can be specified instead of parse_mode
3952 //
3953 // optional
3954 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3955 // ReplyMarkup inline keyboard attached to the message
3956 //
3957 // optional
3958 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3959 // InputMessageContent content of the message to be sent instead of the voice message
3960 //
3961 // optional
3962 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3963}
3964
3965// InlineQueryResultArticle represents a link to an article or web page.
3966type InlineQueryResultArticle struct {
3967 // Type of the result, must be article.
3968 Type string `json:"type"`
3969 // ID unique identifier for this result, 1-64 Bytes.
3970 ID string `json:"id"`
3971 // Title of the result
3972 Title string `json:"title"`
3973 // InputMessageContent content of the message to be sent.
3974 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3975 // ReplyMarkup Inline keyboard attached to the message.
3976 //
3977 // optional
3978 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3979 // URL of the result.
3980 //
3981 // optional
3982 URL string `json:"url,omitempty"`
3983 // HideURL pass True, if you don't want the URL to be shown in the message.
3984 //
3985 // optional
3986 HideURL bool `json:"hide_url,omitempty"`
3987 // Description short description of the result.
3988 //
3989 // optional
3990 Description string `json:"description,omitempty"`
3991 // ThumbURL url of the thumbnail for the result
3992 //
3993 // optional
3994 ThumbURL string `json:"thumbnail_url,omitempty"`
3995 // ThumbWidth thumbnail width
3996 //
3997 // optional
3998 ThumbWidth int `json:"thumbnail_width,omitempty"`
3999 // ThumbHeight thumbnail height
4000 //
4001 // optional
4002 ThumbHeight int `json:"thumbnail_height,omitempty"`
4003}
4004
4005// InlineQueryResultAudio is an inline query response audio.
4006type InlineQueryResultAudio struct {
4007 // Type of the result, must be audio
4008 Type string `json:"type"`
4009 // ID unique identifier for this result, 1-64 bytes
4010 ID string `json:"id"`
4011 // URL a valid url for the audio file
4012 URL string `json:"audio_url"`
4013 // Title is a title
4014 Title string `json:"title"`
4015 // Caption 0-1024 characters after entities parsing
4016 //
4017 // optional
4018 Caption string `json:"caption,omitempty"`
4019 // ParseMode mode for parsing entities in the video caption.
4020 // See formatting options for more details
4021 // (https://core.telegram.org/bots/api#formatting-options).
4022 //
4023 // optional
4024 ParseMode string `json:"parse_mode,omitempty"`
4025 // CaptionEntities is a list of special entities that appear in the caption,
4026 // which can be specified instead of parse_mode
4027 //
4028 // optional
4029 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4030 // Performer is a performer
4031 //
4032 // optional
4033 Performer string `json:"performer,omitempty"`
4034 // Duration audio duration in seconds
4035 //
4036 // optional
4037 Duration int `json:"audio_duration,omitempty"`
4038 // ReplyMarkup inline keyboard attached to the message
4039 //
4040 // optional
4041 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4042 // InputMessageContent content of the message to be sent instead of the audio
4043 //
4044 // optional
4045 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4046}
4047
4048// InlineQueryResultContact is an inline query response contact.
4049type InlineQueryResultContact struct {
4050 Type string `json:"type"` // required
4051 ID string `json:"id"` // required
4052 PhoneNumber string `json:"phone_number"` // required
4053 FirstName string `json:"first_name"` // required
4054 LastName string `json:"last_name"`
4055 VCard string `json:"vcard"`
4056 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4057 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4058 ThumbURL string `json:"thumbnail_url"`
4059 ThumbWidth int `json:"thumbnail_width"`
4060 ThumbHeight int `json:"thumbnail_height"`
4061}
4062
4063// InlineQueryResultGame is an inline query response game.
4064type InlineQueryResultGame struct {
4065 // Type of the result, must be game
4066 Type string `json:"type"`
4067 // ID unique identifier for this result, 1-64 bytes
4068 ID string `json:"id"`
4069 // GameShortName short name of the game
4070 GameShortName string `json:"game_short_name"`
4071 // ReplyMarkup inline keyboard attached to the message
4072 //
4073 // optional
4074 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4075}
4076
4077// InlineQueryResultDocument is an inline query response document.
4078type InlineQueryResultDocument struct {
4079 // Type of the result, must be a document
4080 Type string `json:"type"`
4081 // ID unique identifier for this result, 1-64 bytes
4082 ID string `json:"id"`
4083 // Title for the result
4084 Title string `json:"title"`
4085 // Caption of the document to be sent, 0-1024 characters after entities parsing
4086 //
4087 // optional
4088 Caption string `json:"caption,omitempty"`
4089 // URL a valid url for the file
4090 URL string `json:"document_url"`
4091 // MimeType of the content of the file, either “application/pdf” or “application/zip”
4092 MimeType string `json:"mime_type"`
4093 // Description short description of the result
4094 //
4095 // optional
4096 Description string `json:"description,omitempty"`
4097 // ReplyMarkup inline keyboard attached to the message
4098 //
4099 // optional
4100 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4101 // InputMessageContent content of the message to be sent instead of the file
4102 //
4103 // optional
4104 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4105 // ThumbURL url of the thumbnail (jpeg only) for the file
4106 //
4107 // optional
4108 ThumbURL string `json:"thumbnail_url,omitempty"`
4109 // ThumbWidth thumbnail width
4110 //
4111 // optional
4112 ThumbWidth int `json:"thumbnail_width,omitempty"`
4113 // ThumbHeight thumbnail height
4114 //
4115 // optional
4116 ThumbHeight int `json:"thumbnail_height,omitempty"`
4117}
4118
4119// InlineQueryResultGIF is an inline query response GIF.
4120type InlineQueryResultGIF struct {
4121 // Type of the result, must be gif.
4122 Type string `json:"type"`
4123 // ID unique identifier for this result, 1-64 bytes.
4124 ID string `json:"id"`
4125 // URL a valid URL for the GIF file. File size must not exceed 1MB.
4126 URL string `json:"gif_url"`
4127 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
4128 ThumbURL string `json:"thumbnail_url"`
4129 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
4130 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
4131 // Width of the GIF
4132 //
4133 // optional
4134 Width int `json:"gif_width,omitempty"`
4135 // Height of the GIF
4136 //
4137 // optional
4138 Height int `json:"gif_height,omitempty"`
4139 // Duration of the GIF
4140 //
4141 // optional
4142 Duration int `json:"gif_duration,omitempty"`
4143 // Title for the result
4144 //
4145 // optional
4146 Title string `json:"title,omitempty"`
4147 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
4148 //
4149 // optional
4150 Caption string `json:"caption,omitempty"`
4151 // ParseMode mode for parsing entities in the video caption.
4152 // See formatting options for more details
4153 // (https://core.telegram.org/bots/api#formatting-options).
4154 //
4155 // optional
4156 ParseMode string `json:"parse_mode,omitempty"`
4157 // CaptionEntities is a list of special entities that appear in the caption,
4158 // which can be specified instead of parse_mode
4159 //
4160 // optional
4161 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4162 // ReplyMarkup inline keyboard attached to the message
4163 //
4164 // optional
4165 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4166 // InputMessageContent content of the message to be sent instead of the GIF animation.
4167 //
4168 // optional
4169 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4170}
4171
4172// InlineQueryResultLocation is an inline query response location.
4173type InlineQueryResultLocation struct {
4174 // Type of the result, must be location
4175 Type string `json:"type"`
4176 // ID unique identifier for this result, 1-64 Bytes
4177 ID string `json:"id"`
4178 // Latitude of the location in degrees
4179 Latitude float64 `json:"latitude"`
4180 // Longitude of the location in degrees
4181 Longitude float64 `json:"longitude"`
4182 // Title of the location
4183 Title string `json:"title"`
4184 // HorizontalAccuracy is the radius of uncertainty for the location,
4185 // measured in meters; 0-1500
4186 //
4187 // optional
4188 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
4189 // LivePeriod is the period in seconds for which the location can be
4190 // updated, should be between 60 and 86400.
4191 //
4192 // optional
4193 LivePeriod int `json:"live_period,omitempty"`
4194 // Heading is for live locations, a direction in which the user is moving,
4195 // in degrees. Must be between 1 and 360 if specified.
4196 //
4197 // optional
4198 Heading int `json:"heading,omitempty"`
4199 // ProximityAlertRadius is for live locations, a maximum distance for
4200 // proximity alerts about approaching another chat member, in meters. Must
4201 // be between 1 and 100000 if specified.
4202 //
4203 // optional
4204 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
4205 // ReplyMarkup inline keyboard attached to the message
4206 //
4207 // optional
4208 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4209 // InputMessageContent content of the message to be sent instead of the location
4210 //
4211 // optional
4212 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4213 // ThumbURL url of the thumbnail for the result
4214 //
4215 // optional
4216 ThumbURL string `json:"thumbnail_url,omitempty"`
4217 // ThumbWidth thumbnail width
4218 //
4219 // optional
4220 ThumbWidth int `json:"thumbnail_width,omitempty"`
4221 // ThumbHeight thumbnail height
4222 //
4223 // optional
4224 ThumbHeight int `json:"thumbnail_height,omitempty"`
4225}
4226
4227// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
4228type InlineQueryResultMPEG4GIF struct {
4229 // Type of the result, must be mpeg4_gif
4230 Type string `json:"type"`
4231 // ID unique identifier for this result, 1-64 bytes
4232 ID string `json:"id"`
4233 // URL a valid URL for the MP4 file. File size must not exceed 1MB
4234 URL string `json:"mpeg4_url"`
4235 // Width video width
4236 //
4237 // optional
4238 Width int `json:"mpeg4_width,omitempty"`
4239 // Height vVideo height
4240 //
4241 // optional
4242 Height int `json:"mpeg4_height,omitempty"`
4243 // Duration video duration
4244 //
4245 // optional
4246 Duration int `json:"mpeg4_duration,omitempty"`
4247 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
4248 ThumbURL string `json:"thumbnail_url"`
4249 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
4250 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
4251 // Title for the result
4252 //
4253 // optional
4254 Title string `json:"title,omitempty"`
4255 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
4256 //
4257 // optional
4258 Caption string `json:"caption,omitempty"`
4259 // ParseMode mode for parsing entities in the video caption.
4260 // See formatting options for more details
4261 // (https://core.telegram.org/bots/api#formatting-options).
4262 //
4263 // optional
4264 ParseMode string `json:"parse_mode,omitempty"`
4265 // CaptionEntities is a list of special entities that appear in the caption,
4266 // which can be specified instead of parse_mode
4267 //
4268 // optional
4269 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4270 // ReplyMarkup inline keyboard attached to the message
4271 //
4272 // optional
4273 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4274 // InputMessageContent content of the message to be sent instead of the video animation
4275 //
4276 // optional
4277 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4278}
4279
4280// InlineQueryResultPhoto is an inline query response photo.
4281type InlineQueryResultPhoto struct {
4282 // Type of the result, must be article.
4283 Type string `json:"type"`
4284 // ID unique identifier for this result, 1-64 Bytes.
4285 ID string `json:"id"`
4286 // URL a valid URL of the photo. Photo must be in jpeg format.
4287 // Photo size must not exceed 5MB.
4288 URL string `json:"photo_url"`
4289 // MimeType
4290 MimeType string `json:"mime_type"`
4291 // Width of the photo
4292 //
4293 // optional
4294 Width int `json:"photo_width,omitempty"`
4295 // Height of the photo
4296 //
4297 // optional
4298 Height int `json:"photo_height,omitempty"`
4299 // ThumbURL url of the thumbnail for the photo.
4300 //
4301 // optional
4302 ThumbURL string `json:"thumbnail_url,omitempty"`
4303 // Title for the result
4304 //
4305 // optional
4306 Title string `json:"title,omitempty"`
4307 // Description short description of the result
4308 //
4309 // optional
4310 Description string `json:"description,omitempty"`
4311 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
4312 //
4313 // optional
4314 Caption string `json:"caption,omitempty"`
4315 // ParseMode mode for parsing entities in the photo caption.
4316 // See formatting options for more details
4317 // (https://core.telegram.org/bots/api#formatting-options).
4318 //
4319 // optional
4320 ParseMode string `json:"parse_mode,omitempty"`
4321 // ReplyMarkup inline keyboard attached to the message.
4322 //
4323 // optional
4324 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4325 // CaptionEntities is a list of special entities that appear in the caption,
4326 // which can be specified instead of parse_mode
4327 //
4328 // optional
4329 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4330 // InputMessageContent content of the message to be sent instead of the photo.
4331 //
4332 // optional
4333 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4334}
4335
4336// InlineQueryResultVenue is an inline query response venue.
4337type InlineQueryResultVenue struct {
4338 // Type of the result, must be venue
4339 Type string `json:"type"`
4340 // ID unique identifier for this result, 1-64 Bytes
4341 ID string `json:"id"`
4342 // Latitude of the venue location in degrees
4343 Latitude float64 `json:"latitude"`
4344 // Longitude of the venue location in degrees
4345 Longitude float64 `json:"longitude"`
4346 // Title of the venue
4347 Title string `json:"title"`
4348 // Address of the venue
4349 Address string `json:"address"`
4350 // FoursquareID foursquare identifier of the venue if known
4351 //
4352 // optional
4353 FoursquareID string `json:"foursquare_id,omitempty"`
4354 // FoursquareType foursquare type of the venue, if known.
4355 // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
4356 //
4357 // optional
4358 FoursquareType string `json:"foursquare_type,omitempty"`
4359 // GooglePlaceID is the Google Places identifier of the venue
4360 //
4361 // optional
4362 GooglePlaceID string `json:"google_place_id,omitempty"`
4363 // GooglePlaceType is the Google Places type of the venue
4364 //
4365 // optional
4366 GooglePlaceType string `json:"google_place_type,omitempty"`
4367 // ReplyMarkup inline keyboard attached to the message
4368 //
4369 // optional
4370 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4371 // InputMessageContent content of the message to be sent instead of the venue
4372 //
4373 // optional
4374 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4375 // ThumbURL url of the thumbnail for the result
4376 //
4377 // optional
4378 ThumbURL string `json:"thumbnail_url,omitempty"`
4379 // ThumbWidth thumbnail width
4380 //
4381 // optional
4382 ThumbWidth int `json:"thumbnail_width,omitempty"`
4383 // ThumbHeight thumbnail height
4384 //
4385 // optional
4386 ThumbHeight int `json:"thumbnail_height,omitempty"`
4387}
4388
4389// InlineQueryResultVideo is an inline query response video.
4390type InlineQueryResultVideo struct {
4391 // Type of the result, must be video
4392 Type string `json:"type"`
4393 // ID unique identifier for this result, 1-64 bytes
4394 ID string `json:"id"`
4395 // URL a valid url for the embedded video player or video file
4396 URL string `json:"video_url"`
4397 // MimeType of the content of video url, “text/html” or “video/mp4”
4398 MimeType string `json:"mime_type"`
4399 //
4400 // ThumbURL url of the thumbnail (jpeg only) for the video
4401 // optional
4402 ThumbURL string `json:"thumbnail_url,omitempty"`
4403 // Title for the result
4404 Title string `json:"title"`
4405 // Caption of the video to be sent, 0-1024 characters after entities parsing
4406 //
4407 // optional
4408 Caption string `json:"caption,omitempty"`
4409 // Width video width
4410 //
4411 // optional
4412 Width int `json:"video_width,omitempty"`
4413 // Height video height
4414 //
4415 // optional
4416 Height int `json:"video_height,omitempty"`
4417 // Duration video duration in seconds
4418 //
4419 // optional
4420 Duration int `json:"video_duration,omitempty"`
4421 // Description short description of the result
4422 //
4423 // optional
4424 Description string `json:"description,omitempty"`
4425 // ReplyMarkup inline keyboard attached to the message
4426 //
4427 // optional
4428 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4429 // InputMessageContent content of the message to be sent instead of the video.
4430 // This field is required if InlineQueryResultVideo is used to send
4431 // an HTML-page as a result (e.g., a YouTube video).
4432 //
4433 // optional
4434 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4435}
4436
4437// InlineQueryResultVoice is an inline query response voice.
4438type InlineQueryResultVoice struct {
4439 // Type of the result, must be voice
4440 Type string `json:"type"`
4441 // ID unique identifier for this result, 1-64 bytes
4442 ID string `json:"id"`
4443 // URL a valid URL for the voice recording
4444 URL string `json:"voice_url"`
4445 // Title recording title
4446 Title string `json:"title"`
4447 // Caption 0-1024 characters after entities parsing
4448 //
4449 // optional
4450 Caption string `json:"caption,omitempty"`
4451 // ParseMode mode for parsing entities in the video caption.
4452 // See formatting options for more details
4453 // (https://core.telegram.org/bots/api#formatting-options).
4454 //
4455 // optional
4456 ParseMode string `json:"parse_mode,omitempty"`
4457 // CaptionEntities is a list of special entities that appear in the caption,
4458 // which can be specified instead of parse_mode
4459 //
4460 // optional
4461 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4462 // Duration recording duration in seconds
4463 //
4464 // optional
4465 Duration int `json:"voice_duration,omitempty"`
4466 // ReplyMarkup inline keyboard attached to the message
4467 //
4468 // optional
4469 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4470 // InputMessageContent content of the message to be sent instead of the voice recording
4471 //
4472 // optional
4473 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4474}
4475
4476// ChosenInlineResult is an inline query result chosen by a User
4477type ChosenInlineResult struct {
4478 // ResultID the unique identifier for the result that was chosen
4479 ResultID string `json:"result_id"`
4480 // From the user that chose the result
4481 From *User `json:"from"`
4482 // Location sender location, only for bots that require user location
4483 //
4484 // optional
4485 Location *Location `json:"location,omitempty"`
4486 // InlineMessageID identifier of the sent inline message.
4487 // Available only if there is an inline keyboard attached to the message.
4488 // Will be also received in callback queries and can be used to edit the message.
4489 //
4490 // optional
4491 InlineMessageID string `json:"inline_message_id,omitempty"`
4492 // Query the query that was used to obtain the result
4493 Query string `json:"query"`
4494}
4495
4496// SentWebAppMessage contains information about an inline message sent by a Web App
4497// on behalf of a user.
4498type SentWebAppMessage struct {
4499 // Identifier of the sent inline message. Available only if there is an inline
4500 // keyboard attached to the message.
4501 //
4502 // optional
4503 InlineMessageID string `json:"inline_message_id,omitempty"`
4504}
4505
4506// InputTextMessageContent contains text for displaying
4507// as an inline query result.
4508type InputTextMessageContent struct {
4509 // Text of the message to be sent, 1-4096 characters
4510 Text string `json:"message_text"`
4511 // ParseMode mode for parsing entities in the message text.
4512 // See formatting options for more details
4513 // (https://core.telegram.org/bots/api#formatting-options).
4514 //
4515 // optional
4516 ParseMode string `json:"parse_mode,omitempty"`
4517 // Entities is a list of special entities that appear in message text, which
4518 // can be specified instead of parse_mode
4519 //
4520 // optional
4521 Entities []MessageEntity `json:"entities,omitempty"`
4522 // LinkPreviewOptions used for link preview generation for the original message
4523 //
4524 // Optional
4525 LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
4526}
4527
4528// InputLocationMessageContent contains a location for displaying
4529// as an inline query result.
4530type InputLocationMessageContent struct {
4531 // Latitude of the location in degrees
4532 Latitude float64 `json:"latitude"`
4533 // Longitude of the location in degrees
4534 Longitude float64 `json:"longitude"`
4535 // HorizontalAccuracy is the radius of uncertainty for the location,
4536 // measured in meters; 0-1500
4537 //
4538 // optional
4539 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
4540 // LivePeriod is the period in seconds for which the location can be
4541 // updated, should be between 60 and 86400
4542 //
4543 // optional
4544 LivePeriod int `json:"live_period,omitempty"`
4545 // Heading is for live locations, a direction in which the user is moving,
4546 // in degrees. Must be between 1 and 360 if specified.
4547 //
4548 // optional
4549 Heading int `json:"heading,omitempty"`
4550 // ProximityAlertRadius is for live locations, a maximum distance for
4551 // proximity alerts about approaching another chat member, in meters. Must
4552 // be between 1 and 100000 if specified.
4553 //
4554 // optional
4555 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
4556}
4557
4558// InputVenueMessageContent contains a venue for displaying
4559// as an inline query result.
4560type InputVenueMessageContent struct {
4561 // Latitude of the venue in degrees
4562 Latitude float64 `json:"latitude"`
4563 // Longitude of the venue in degrees
4564 Longitude float64 `json:"longitude"`
4565 // Title name of the venue
4566 Title string `json:"title"`
4567 // Address of the venue
4568 Address string `json:"address"`
4569 // FoursquareID foursquare identifier of the venue, if known
4570 //
4571 // optional
4572 FoursquareID string `json:"foursquare_id,omitempty"`
4573 // FoursquareType Foursquare type of the venue, if known
4574 //
4575 // optional
4576 FoursquareType string `json:"foursquare_type,omitempty"`
4577 // GooglePlaceID is the Google Places identifier of the venue
4578 //
4579 // optional
4580 GooglePlaceID string `json:"google_place_id,omitempty"`
4581 // GooglePlaceType is the Google Places type of the venue
4582 //
4583 // optional
4584 GooglePlaceType string `json:"google_place_type,omitempty"`
4585}
4586
4587// InputContactMessageContent contains a contact for displaying
4588// as an inline query result.
4589type InputContactMessageContent struct {
4590 // PhoneNumber contact's phone number
4591 PhoneNumber string `json:"phone_number"`
4592 // FirstName contact's first name
4593 FirstName string `json:"first_name"`
4594 // LastName contact's last name
4595 //
4596 // optional
4597 LastName string `json:"last_name,omitempty"`
4598 // Additional data about the contact in the form of a vCard
4599 //
4600 // optional
4601 VCard string `json:"vcard,omitempty"`
4602}
4603
4604// InputInvoiceMessageContent represents the content of an invoice message to be
4605// sent as the result of an inline query.
4606type InputInvoiceMessageContent struct {
4607 // Product name, 1-32 characters
4608 Title string `json:"title"`
4609 // Product description, 1-255 characters
4610 Description string `json:"description"`
4611 // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
4612 // the user, use for your internal processes.
4613 Payload string `json:"payload"`
4614 // Payment provider token, obtained via Botfather
4615 ProviderToken string `json:"provider_token"`
4616 // Three-letter ISO 4217 currency code
4617 Currency string `json:"currency"`
4618 // Price breakdown, a JSON-serialized list of components (e.g. product
4619 // price, tax, discount, delivery cost, delivery tax, bonus, etc.)
4620 Prices []LabeledPrice `json:"prices"`
4621 // The maximum accepted amount for tips in the smallest units of the
4622 // currency (integer, not float/double).
4623 //
4624 // optional
4625 MaxTipAmount int `json:"max_tip_amount,omitempty"`
4626 // An array of suggested amounts of tip in the smallest units of the
4627 // currency (integer, not float/double). At most 4 suggested tip amounts can
4628 // be specified. The suggested tip amounts must be positive, passed in a
4629 // strictly increased order and must not exceed max_tip_amount.
4630 //
4631 // optional
4632 SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
4633 // A JSON-serialized object for data about the invoice, which will be shared
4634 // with the payment provider. A detailed description of the required fields
4635 // should be provided by the payment provider.
4636 //
4637 // optional
4638 ProviderData string `json:"provider_data,omitempty"`
4639 // URL of the product photo for the invoice. Can be a photo of the goods or
4640 // a marketing image for a service. People like it better when they see what
4641 // they are paying for.
4642 //
4643 // optional
4644 PhotoURL string `json:"photo_url,omitempty"`
4645 // Photo size
4646 //
4647 // optional
4648 PhotoSize int `json:"photo_size,omitempty"`
4649 // Photo width
4650 //
4651 // optional
4652 PhotoWidth int `json:"photo_width,omitempty"`
4653 // Photo height
4654 //
4655 // optional
4656 PhotoHeight int `json:"photo_height,omitempty"`
4657 // Pass True, if you require the user's full name to complete the order
4658 //
4659 // optional
4660 NeedName bool `json:"need_name,omitempty"`
4661 // Pass True, if you require the user's phone number to complete the order
4662 //
4663 // optional
4664 NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
4665 // Pass True, if you require the user's email address to complete the order
4666 //
4667 // optional
4668 NeedEmail bool `json:"need_email,omitempty"`
4669 // Pass True, if you require the user's shipping address to complete the order
4670 //
4671 // optional
4672 NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
4673 // Pass True, if user's phone number should be sent to provider
4674 //
4675 // optional
4676 SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
4677 // Pass True, if user's email address should be sent to provider
4678 //
4679 // optional
4680 SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
4681 // Pass True, if the final price depends on the shipping method
4682 //
4683 // optional
4684 IsFlexible bool `json:"is_flexible,omitempty"`
4685}
4686
4687// LabeledPrice represents a portion of the price for goods or services.
4688type LabeledPrice struct {
4689 // Label portion label
4690 Label string `json:"label"`
4691 // Amount price of the product in the smallest units of the currency (integer, not float/double).
4692 // For example, for a price of US$ 1.45 pass amount = 145.
4693 // See the exp parameter in currencies.json
4694 // (https://core.telegram.org/bots/payments/currencies.json),
4695 // it shows the number of digits past the decimal point
4696 // for each currency (2 for the majority of currencies).
4697 Amount int `json:"amount"`
4698}
4699
4700// Invoice contains basic information about an invoice.
4701type Invoice struct {
4702 // Title product name
4703 Title string `json:"title"`
4704 // Description product description
4705 Description string `json:"description"`
4706 // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
4707 StartParameter string `json:"start_parameter"`
4708 // Currency three-letter ISO 4217 currency code
4709 // (see https://core.telegram.org/bots/payments#supported-currencies)
4710 Currency string `json:"currency"`
4711 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4712 // For example, for a price of US$ 1.45 pass amount = 145.
4713 // See the exp parameter in currencies.json
4714 // (https://core.telegram.org/bots/payments/currencies.json),
4715 // it shows the number of digits past the decimal point
4716 // for each currency (2 for the majority of currencies).
4717 TotalAmount int `json:"total_amount"`
4718}
4719
4720// ShippingAddress represents a shipping address.
4721type ShippingAddress struct {
4722 // CountryCode ISO 3166-1 alpha-2 country code
4723 CountryCode string `json:"country_code"`
4724 // State if applicable
4725 State string `json:"state"`
4726 // City city
4727 City string `json:"city"`
4728 // StreetLine1 first line for the address
4729 StreetLine1 string `json:"street_line1"`
4730 // StreetLine2 second line for the address
4731 StreetLine2 string `json:"street_line2"`
4732 // PostCode address post code
4733 PostCode string `json:"post_code"`
4734}
4735
4736// OrderInfo represents information about an order.
4737type OrderInfo struct {
4738 // Name user name
4739 //
4740 // optional
4741 Name string `json:"name,omitempty"`
4742 // PhoneNumber user's phone number
4743 //
4744 // optional
4745 PhoneNumber string `json:"phone_number,omitempty"`
4746 // Email user email
4747 //
4748 // optional
4749 Email string `json:"email,omitempty"`
4750 // ShippingAddress user shipping address
4751 //
4752 // optional
4753 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
4754}
4755
4756// ShippingOption represents one shipping option.
4757type ShippingOption struct {
4758 // ID shipping option identifier
4759 ID string `json:"id"`
4760 // Title option title
4761 Title string `json:"title"`
4762 // Prices list of price portions
4763 Prices []LabeledPrice `json:"prices"`
4764}
4765
4766// SuccessfulPayment contains basic information about a successful payment.
4767type SuccessfulPayment struct {
4768 // Currency three-letter ISO 4217 currency code
4769 // (see https://core.telegram.org/bots/payments#supported-currencies)
4770 Currency string `json:"currency"`
4771 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4772 // For example, for a price of US$ 1.45 pass amount = 145.
4773 // See the exp parameter in currencies.json,
4774 // (https://core.telegram.org/bots/payments/currencies.json)
4775 // it shows the number of digits past the decimal point
4776 // for each currency (2 for the majority of currencies).
4777 TotalAmount int `json:"total_amount"`
4778 // InvoicePayload bot specified invoice payload
4779 InvoicePayload string `json:"invoice_payload"`
4780 // ShippingOptionID identifier of the shipping option chosen by the user
4781 //
4782 // optional
4783 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4784 // OrderInfo order info provided by the user
4785 //
4786 // optional
4787 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4788 // TelegramPaymentChargeID telegram payment identifier
4789 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
4790 // ProviderPaymentChargeID provider payment identifier
4791 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
4792}
4793
4794// ShippingQuery contains information about an incoming shipping query.
4795type ShippingQuery struct {
4796 // ID unique query identifier
4797 ID string `json:"id"`
4798 // From user who sent the query
4799 From *User `json:"from"`
4800 // InvoicePayload bot specified invoice payload
4801 InvoicePayload string `json:"invoice_payload"`
4802 // ShippingAddress user specified shipping address
4803 ShippingAddress *ShippingAddress `json:"shipping_address"`
4804}
4805
4806// PreCheckoutQuery contains information about an incoming pre-checkout query.
4807type PreCheckoutQuery struct {
4808 // ID unique query identifier
4809 ID string `json:"id"`
4810 // From user who sent the query
4811 From *User `json:"from"`
4812 // Currency three-letter ISO 4217 currency code
4813 // // (see https://core.telegram.org/bots/payments#supported-currencies)
4814 Currency string `json:"currency"`
4815 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4816 // // For example, for a price of US$ 1.45 pass amount = 145.
4817 // // See the exp parameter in currencies.json,
4818 // // (https://core.telegram.org/bots/payments/currencies.json)
4819 // // it shows the number of digits past the decimal point
4820 // // for each currency (2 for the majority of currencies).
4821 TotalAmount int `json:"total_amount"`
4822 // InvoicePayload bot specified invoice payload
4823 InvoicePayload string `json:"invoice_payload"`
4824 // ShippingOptionID identifier of the shipping option chosen by the user
4825 //
4826 // optional
4827 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4828 // OrderInfo order info provided by the user
4829 //
4830 // optional
4831 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4832}