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