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 // Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username,
2378 // if this is allowed by their privacy settings.
2379 //
2380 // optional
2381 URL *string `json:"url,omitempty"`
2382 // LoginURL is an HTTP URL used to automatically authorize the user. Can be
2383 // used as a replacement for the Telegram Login Widget
2384 //
2385 // optional
2386 LoginURL *LoginURL `json:"login_url,omitempty"`
2387 // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
2388 //
2389 // optional
2390 CallbackData *string `json:"callback_data,omitempty"`
2391 // WebApp is the Description of the Web App that will be launched when the user presses the button.
2392 // The Web App will be able to send an arbitrary message on behalf of the user using the method
2393 // answerWebAppQuery. Available only in private chats between a user and the bot.
2394 // Not supported for messages sent on behalf of a Telegram Business account.
2395 //
2396 // optional
2397 WebApp *WebAppInfo `json:"web_app,omitempty"`
2398 // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
2399 // open that chat and insert the bot's username and the specified inline query in the input field.
2400 // Can be empty, in which case just the bot's username will be inserted.
2401 //
2402 // This offers an easy way for users to start using your bot
2403 // in inline mode when they are currently in a private chat with it.
2404 // Especially useful when combined with switch_pm… actions – in this case
2405 // the user will be automatically returned to the chat they switched from,
2406 // skipping the chat selection screen.
2407 // Not supported for messages sent on behalf of a Telegram Business account.
2408 //
2409 // optional
2410 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
2411 // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
2412 // and the specified inline query in the current chat's input field.
2413 // Can be empty, in which case only the bot's username will be inserted.
2414 //
2415 // This offers a quick way for the user to open your bot in inline mode
2416 // in the same chat – good for selecting something from multiple options.
2417 // Not supported for messages sent on behalf of a Telegram Business account.
2418 //
2419 // optional
2420 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
2421 //SwitchInlineQueryChosenChat If set, pressing the button will prompt the user to
2422 //select one of their chats of the specified type, open that chat and insert the bot's
2423 //username and the specified inline query in the input field.
2424 // Not supported for messages sent on behalf of a Telegram Business account.
2425 //
2426 //optional
2427 SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`
2428 // CallbackGame description of the game that will be launched when the user presses the button.
2429 //
2430 // optional
2431 CallbackGame *CallbackGame `json:"callback_game,omitempty"`
2432 // Pay specify True, to send a Pay button.
2433 // Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
2434 //
2435 // NOTE: This type of button must always be the first button in the first row.
2436 //
2437 // optional
2438 Pay bool `json:"pay,omitempty"`
2439}
2440
2441// LoginURL represents a parameter of the inline keyboard button used to
2442// automatically authorize a user. Serves as a great replacement for the
2443// Telegram Login Widget when the user is coming from Telegram. All the user
2444// needs to do is tap/click a button and confirm that they want to log in.
2445type LoginURL struct {
2446 // URL is an HTTP URL to be opened with user authorization data added to the
2447 // query string when the button is pressed. If the user refuses to provide
2448 // authorization data, the original URL without information about the user
2449 // will be opened. The data added is the same as described in Receiving
2450 // authorization data.
2451 //
2452 // NOTE: You must always check the hash of the received data to verify the
2453 // authentication and the integrity of the data as described in Checking
2454 // authorization.
2455 URL string `json:"url"`
2456 // ForwardText is the new text of the button in forwarded messages
2457 //
2458 // optional
2459 ForwardText string `json:"forward_text,omitempty"`
2460 // BotUsername is the username of a bot, which will be used for user
2461 // authorization. See Setting up a bot for more details. If not specified,
2462 // the current bot's username will be assumed. The url's domain must be the
2463 // same as the domain linked with the bot. See Linking your domain to the
2464 // bot for more details.
2465 //
2466 // optional
2467 BotUsername string `json:"bot_username,omitempty"`
2468 // RequestWriteAccess if true requests permission for your bot to send
2469 // messages to the user
2470 //
2471 // optional
2472 RequestWriteAccess bool `json:"request_write_access,omitempty"`
2473}
2474
2475// CallbackQuery represents an incoming callback query from a callback button in
2476// an inline keyboard. If the button that originated the query was attached to a
2477// message sent by the bot, the field message will be present. If the button was
2478// attached to a message sent via the bot (in inline mode), the field
2479// inline_message_id will be present. Exactly one of the fields data or
2480// game_short_name will be present.
2481type CallbackQuery struct {
2482 // ID unique identifier for this query
2483 ID string `json:"id"`
2484 // From sender
2485 From *User `json:"from"`
2486 // Message sent by the bot with the callback button that originated the query
2487 //
2488 // optional
2489 Message *Message `json:"message,omitempty"`
2490 // InlineMessageID identifier of the message sent via the bot in inline
2491 // mode, that originated the query.
2492 //
2493 // optional
2494 InlineMessageID string `json:"inline_message_id,omitempty"`
2495 // ChatInstance global identifier, uniquely corresponding to the chat to
2496 // which the message with the callback button was sent. Useful for high
2497 // scores in games.
2498 ChatInstance string `json:"chat_instance"`
2499 // Data associated with the callback button. Be aware that
2500 // a bad client can send arbitrary data in this field.
2501 //
2502 // optional
2503 Data string `json:"data,omitempty"`
2504 // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
2505 //
2506 // optional
2507 GameShortName string `json:"game_short_name,omitempty"`
2508}
2509
2510// IsInaccessibleMessage method that shows whether message is inaccessible
2511func (c CallbackQuery) IsInaccessibleMessage() bool {
2512 return c.Message != nil && c.Message.Date == 0
2513}
2514
2515func (c CallbackQuery) GetInaccessibleMessage() InaccessibleMessage {
2516 if c.Message == nil {
2517 return InaccessibleMessage{}
2518 }
2519 return InaccessibleMessage{
2520 Chat: c.Message.Chat,
2521 MessageID: c.Message.MessageID,
2522 }
2523}
2524
2525// ForceReply when receiving a message with this object, Telegram clients will
2526// display a reply interface to the user (act as if the user has selected the
2527// bot's message and tapped 'Reply'). This can be extremely useful if you want
2528// to create user-friendly step-by-step interfaces without having to sacrifice
2529// privacy mode.
2530type ForceReply struct {
2531 // ForceReply shows reply interface to the user,
2532 // as if they manually selected the bot's message and tapped 'Reply'.
2533 ForceReply bool `json:"force_reply"`
2534 // InputFieldPlaceholder is the placeholder to be shown in the input field when
2535 // the reply is active; 1-64 characters.
2536 //
2537 // optional
2538 InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
2539 // Selective use this parameter if you want to force reply from specific users only.
2540 // Targets:
2541 // 1) users that are @mentioned in the text of the Message object;
2542 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
2543 //
2544 // optional
2545 Selective bool `json:"selective,omitempty"`
2546}
2547
2548// ChatPhoto represents a chat photo.
2549type ChatPhoto struct {
2550 // SmallFileID is a file identifier of small (160x160) chat photo.
2551 // This file_id can be used only for photo download and
2552 // only for as long as the photo is not changed.
2553 SmallFileID string `json:"small_file_id"`
2554 // SmallFileUniqueID is a unique file identifier of small (160x160) chat
2555 // photo, which is supposed to be the same over time and for different bots.
2556 // Can't be used to download or reuse the file.
2557 SmallFileUniqueID string `json:"small_file_unique_id"`
2558 // BigFileID is a file identifier of big (640x640) chat photo.
2559 // This file_id can be used only for photo download and
2560 // only for as long as the photo is not changed.
2561 BigFileID string `json:"big_file_id"`
2562 // BigFileUniqueID is a file identifier of big (640x640) chat photo, which
2563 // is supposed to be the same over time and for different bots. Can't be
2564 // used to download or reuse the file.
2565 BigFileUniqueID string `json:"big_file_unique_id"`
2566}
2567
2568// ChatInviteLink represents an invite link for a chat.
2569type ChatInviteLink struct {
2570 // InviteLink is the invite link. If the link was created by another chat
2571 // administrator, then the second part of the link will be replaced with “…”.
2572 InviteLink string `json:"invite_link"`
2573 // Creator of the link.
2574 Creator User `json:"creator"`
2575 // CreatesJoinRequest is true if users joining the chat via the link need to
2576 // be approved by chat administrators.
2577 //
2578 // optional
2579 CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
2580 // IsPrimary is true, if the link is primary.
2581 IsPrimary bool `json:"is_primary"`
2582 // IsRevoked is true, if the link is revoked.
2583 IsRevoked bool `json:"is_revoked"`
2584 // Name is the name of the invite link.
2585 //
2586 // optional
2587 Name string `json:"name,omitempty"`
2588 // ExpireDate is the point in time (Unix timestamp) when the link will
2589 // expire or has been expired.
2590 //
2591 // optional
2592 ExpireDate int `json:"expire_date,omitempty"`
2593 // MemberLimit is the maximum number of users that can be members of the
2594 // chat simultaneously after joining the chat via this invite link; 1-99999.
2595 //
2596 // optional
2597 MemberLimit int `json:"member_limit,omitempty"`
2598 // PendingJoinRequestCount is the number of pending join requests created
2599 // using this link.
2600 //
2601 // optional
2602 PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
2603}
2604
2605type ChatAdministratorRights struct {
2606 IsAnonymous bool `json:"is_anonymous"`
2607 CanManageChat bool `json:"can_manage_chat"`
2608 CanDeleteMessages bool `json:"can_delete_messages"`
2609 CanManageVideoChats bool `json:"can_manage_video_chats"`
2610 CanRestrictMembers bool `json:"can_restrict_members"`
2611 CanPromoteMembers bool `json:"can_promote_members"`
2612 CanChangeInfo bool `json:"can_change_info"`
2613 CanInviteUsers bool `json:"can_invite_users"`
2614 CanPostMessages bool `json:"can_post_messages"`
2615 CanEditMessages bool `json:"can_edit_messages"`
2616 CanPinMessages bool `json:"can_pin_messages"`
2617 CanPostStories bool `json:"can_post_stories"`
2618 CanEditStories bool `json:"can_edit_stories"`
2619 CanDeleteStories bool `json:"can_delete_stories"`
2620 CanManageTopics bool `json:"can_manage_topics"`
2621}
2622
2623// ChatMember contains information about one member of a chat.
2624type ChatMember struct {
2625 // User information about the user
2626 User *User `json:"user"`
2627 // Status the member's status in the chat.
2628 // Can be
2629 // “creator”,
2630 // “administrator”,
2631 // “member”,
2632 // “restricted”,
2633 // “left” or
2634 // “kicked”
2635 Status string `json:"status"`
2636 // CustomTitle owner and administrators only. Custom title for this user
2637 //
2638 // optional
2639 CustomTitle string `json:"custom_title,omitempty"`
2640 // IsAnonymous owner and administrators only. True, if the user's presence
2641 // in the chat is hidden
2642 //
2643 // optional
2644 IsAnonymous bool `json:"is_anonymous,omitempty"`
2645 // UntilDate restricted and kicked only.
2646 // Date when restrictions will be lifted for this user;
2647 // unix time.
2648 //
2649 // optional
2650 UntilDate int64 `json:"until_date,omitempty"`
2651 // CanBeEdited administrators only.
2652 // True, if the bot is allowed to edit administrator privileges of that user.
2653 //
2654 // optional
2655 CanBeEdited bool `json:"can_be_edited,omitempty"`
2656 // CanManageChat administrators only.
2657 // True, if the administrator can access the chat event log, chat
2658 // statistics, message statistics in channels, see channel members, see
2659 // anonymous administrators in supergroups and ignore slow mode. Implied by
2660 // any other administrator privilege.
2661 //
2662 // optional
2663 CanManageChat bool `json:"can_manage_chat,omitempty"`
2664 // CanPostMessages administrators only.
2665 // True, if the administrator can post in the channel;
2666 // channels only.
2667 //
2668 // optional
2669 CanPostMessages bool `json:"can_post_messages,omitempty"`
2670 // CanEditMessages administrators only.
2671 // True, if the administrator can edit messages of other users and can pin messages;
2672 // channels only.
2673 //
2674 // optional
2675 CanEditMessages bool `json:"can_edit_messages,omitempty"`
2676 // CanDeleteMessages administrators only.
2677 // True, if the administrator can delete messages of other users.
2678 //
2679 // optional
2680 CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
2681 // CanManageVideoChats administrators only.
2682 // True, if the administrator can manage video chats.
2683 //
2684 // optional
2685 CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
2686 // CanRestrictMembers administrators only.
2687 // True, if the administrator can restrict, ban or unban chat members.
2688 //
2689 // optional
2690 CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
2691 // CanPromoteMembers administrators only.
2692 // True, if the administrator can add new administrators
2693 // with a subset of their own privileges or demote administrators that he has promoted,
2694 // directly or indirectly (promoted by administrators that were appointed by the user).
2695 //
2696 // optional
2697 CanPromoteMembers bool `json:"can_promote_members,omitempty"`
2698 // CanChangeInfo administrators and restricted only.
2699 // True, if the user is allowed to change the chat title, photo and other settings.
2700 //
2701 // optional
2702 CanChangeInfo bool `json:"can_change_info,omitempty"`
2703 // CanInviteUsers administrators and restricted only.
2704 // True, if the user is allowed to invite new users to the chat.
2705 //
2706 // optional
2707 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2708 // CanPinMessages administrators and restricted only.
2709 // True, if the user is allowed to pin messages; groups and supergroups only
2710 //
2711 // optional
2712 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2713 // CanPostStories administrators only.
2714 // True, if the administrator can post stories in the channel; channels only
2715 //
2716 // optional
2717 CanPostStories bool `json:"can_post_stories,omitempty"`
2718 // CanEditStories administrators only.
2719 // True, if the administrator can edit stories posted by other users; channels only
2720 //
2721 // optional
2722 CanEditStories bool `json:"can_edit_stories,omitempty"`
2723 // CanDeleteStories administrators only.
2724 // True, if the administrator can delete stories posted by other users; channels only
2725 //
2726 // optional
2727 CanDeleteStories bool `json:"can_delete_stories,omitempty"`
2728 // CanManageTopics administrators and restricted only.
2729 // True, if the user is allowed to create, rename,
2730 // close, and reopen forum topics; supergroups only
2731 //
2732 // optional
2733 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2734 // IsMember is true, if the user is a member of the chat at the moment of
2735 // the request
2736 IsMember bool `json:"is_member"`
2737 // CanSendMessages
2738 //
2739 // optional
2740 CanSendMessages bool `json:"can_send_messages,omitempty"`
2741 // CanSendAudios restricted only.
2742 // True, if the user is allowed to send audios
2743 //
2744 // optional
2745 CanSendAudios bool `json:"can_send_audios,omitempty"`
2746 // CanSendDocuments restricted only.
2747 // True, if the user is allowed to send documents
2748 //
2749 // optional
2750 CanSendDocuments bool `json:"can_send_documents,omitempty"`
2751 // CanSendPhotos is restricted only.
2752 // True, if the user is allowed to send photos
2753 //
2754 // optional
2755 CanSendPhotos bool `json:"can_send_photos,omitempty"`
2756 // CanSendVideos restricted only.
2757 // True, if the user is allowed to send videos
2758 //
2759 // optional
2760 CanSendVideos bool `json:"can_send_videos,omitempty"`
2761 // CanSendVideoNotes restricted only.
2762 // True, if the user is allowed to send video notes
2763 //
2764 // optional
2765 CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"`
2766 // CanSendVoiceNotes restricted only.
2767 // True, if the user is allowed to send voice notes
2768 //
2769 // optional
2770 CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"`
2771 // CanSendPolls restricted only.
2772 // True, if the user is allowed to send polls
2773 //
2774 // optional
2775 CanSendPolls bool `json:"can_send_polls,omitempty"`
2776 // CanSendOtherMessages restricted only.
2777 // True, if the user is allowed to send audios, documents,
2778 // photos, videos, video notes and voice notes.
2779 //
2780 // optional
2781 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2782 // CanAddWebPagePreviews restricted only.
2783 // True, if the user is allowed to add web page previews to their messages.
2784 //
2785 // optional
2786 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2787}
2788
2789// IsCreator returns if the ChatMember was the creator of the chat.
2790func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
2791
2792// IsAdministrator returns if the ChatMember is a chat administrator.
2793func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
2794
2795// HasLeft returns if the ChatMember left the chat.
2796func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
2797
2798// WasKicked returns if the ChatMember was kicked from the chat.
2799func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
2800
2801// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2802// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2803// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2804func (chat *ChatMember) SetCanSendMediaMessages(b bool) {
2805 chat.CanSendAudios = b
2806 chat.CanSendDocuments = b
2807 chat.CanSendPhotos = b
2808 chat.CanSendVideos = b
2809 chat.CanSendVideoNotes = b
2810 chat.CanSendVoiceNotes = b
2811}
2812
2813// CanSendMediaMessages method to replace field "can_send_media_messages".
2814// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2815// CanSendVideoNotes and CanSendVoiceNotes are true.
2816func (chat *ChatMember) CanSendMediaMessages() bool {
2817 return chat.CanSendAudios && chat.CanSendDocuments &&
2818 chat.CanSendPhotos && chat.CanSendVideos &&
2819 chat.CanSendVideoNotes && chat.CanSendVoiceNotes
2820}
2821
2822// ChatMemberUpdated represents changes in the status of a chat member.
2823type ChatMemberUpdated struct {
2824 // Chat the user belongs to.
2825 Chat Chat `json:"chat"`
2826 // From is the performer of the action, which resulted in the change.
2827 From User `json:"from"`
2828 // Date the change was done in Unix time.
2829 Date int `json:"date"`
2830 // Previous information about the chat member.
2831 OldChatMember ChatMember `json:"old_chat_member"`
2832 // New information about the chat member.
2833 NewChatMember ChatMember `json:"new_chat_member"`
2834 // InviteLink is the link which was used by the user to join the chat;
2835 // for joining by invite link events only.
2836 //
2837 // optional
2838 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2839 // ViaJoinRequest is true, if the user joined the chat
2840 // after sending a direct join request
2841 // and being approved by an administrator
2842 //
2843 // optional
2844 ViaJoinRequest bool `json:"via_join_request,omitempty"`
2845 // ViaChatFolderInviteLink is True, if the user joined the chat
2846 // via a chat folder invite link
2847 //
2848 // optional
2849 ViaChatFolderInviteLink bool `json:"via_chat_folder_invite_link,omitempty"`
2850}
2851
2852// ChatJoinRequest represents a join request sent to a chat.
2853type ChatJoinRequest struct {
2854 // Chat to which the request was sent.
2855 Chat Chat `json:"chat"`
2856 // User that sent the join request.
2857 From User `json:"from"`
2858 // UserChatID identifier of a private chat with the user who sent the join request.
2859 UserChatID int64 `json:"user_chat_id"`
2860 // Date the request was sent in Unix time.
2861 Date int `json:"date"`
2862 // Bio of the user.
2863 //
2864 // optional
2865 Bio string `json:"bio,omitempty"`
2866 // InviteLink is the link that was used by the user to send the join request.
2867 //
2868 // optional
2869 InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
2870}
2871
2872// ChatPermissions describes actions that a non-administrator user is
2873// allowed to take in a chat. All fields are optional.
2874type ChatPermissions struct {
2875 // CanSendMessages is true, if the user is allowed to send text messages,
2876 // contacts, locations and venues
2877 //
2878 // optional
2879 CanSendMessages bool `json:"can_send_messages,omitempty"`
2880 // CanSendAudios is true, if the user is allowed to send audios
2881 //
2882 // optional
2883 CanSendAudios bool `json:"can_send_audios,omitempty"`
2884 // CanSendDocuments is true, if the user is allowed to send documents
2885 //
2886 // optional
2887 CanSendDocuments bool `json:"can_send_documents,omitempty"`
2888 // CanSendPhotos is true, if the user is allowed to send photos
2889 //
2890 // optional
2891 CanSendPhotos bool `json:"can_send_photos,omitempty"`
2892 // CanSendVideos is true, if the user is allowed to send videos
2893 //
2894 // optional
2895 CanSendVideos bool `json:"can_send_videos,omitempty"`
2896 // CanSendVideoNotes is true, if the user is allowed to send video notes
2897 //
2898 // optional
2899 CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"`
2900 // CanSendVoiceNotes is true, if the user is allowed to send voice notes
2901 //
2902 // optional
2903 CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"`
2904 // CanSendPolls is true, if the user is allowed to send polls, implies
2905 // can_send_messages
2906 //
2907 // optional
2908 CanSendPolls bool `json:"can_send_polls,omitempty"`
2909 // CanSendOtherMessages is true, if the user is allowed to send animations,
2910 // games, stickers and use inline bots, implies can_send_media_messages
2911 //
2912 // optional
2913 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
2914 // CanAddWebPagePreviews is true, if the user is allowed to add web page
2915 // previews to their messages, implies can_send_media_messages
2916 //
2917 // optional
2918 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2919 // CanChangeInfo is true, if the user is allowed to change the chat title,
2920 // photo and other settings. Ignored in public supergroups
2921 //
2922 // optional
2923 CanChangeInfo bool `json:"can_change_info,omitempty"`
2924 // CanInviteUsers is true, if the user is allowed to invite new users to the
2925 // chat
2926 //
2927 // optional
2928 CanInviteUsers bool `json:"can_invite_users,omitempty"`
2929 // CanPinMessages is true, if the user is allowed to pin messages. Ignored
2930 // in public supergroups
2931 //
2932 // optional
2933 CanPinMessages bool `json:"can_pin_messages,omitempty"`
2934 // CanManageTopics is true, if the user is allowed to create forum topics.
2935 // If omitted defaults to the value of can_pin_messages
2936 //
2937 // optional
2938 CanManageTopics bool `json:"can_manage_topics,omitempty"`
2939}
2940
2941// SetCanSendMediaMessages is a method to replace field "can_send_media_messages".
2942// It sets CanSendAudio, CanSendDocuments, CanSendPhotos, CanSendVideos,
2943// CanSendVideoNotes, CanSendVoiceNotes to passed value.
2944func (c *ChatPermissions) SetCanSendMediaMessages(b bool) {
2945 c.CanSendAudios = b
2946 c.CanSendDocuments = b
2947 c.CanSendPhotos = b
2948 c.CanSendVideos = b
2949 c.CanSendVideoNotes = b
2950 c.CanSendVoiceNotes = b
2951}
2952
2953// CanSendMediaMessages method to replace field "can_send_media_messages".
2954// It returns true if CanSendAudio and CanSendDocuments and CanSendPhotos and CanSendVideos and
2955// CanSendVideoNotes and CanSendVoiceNotes are true.
2956func (c *ChatPermissions) CanSendMediaMessages() bool {
2957 return c.CanSendAudios && c.CanSendDocuments &&
2958 c.CanSendPhotos && c.CanSendVideos &&
2959 c.CanSendVideoNotes && c.CanSendVoiceNotes
2960}
2961
2962// Birthdate represents a user's birthdate
2963type Birthdate struct {
2964 // Day of the user's birth; 1-31
2965 Day int `json:"day"`
2966 // Month of the user's birth; 1-12
2967 Month int `json:"month"`
2968 // Year of the user's birth
2969 //
2970 // optional
2971 Year *int `json:"year,omitempty"`
2972}
2973
2974// BusinessIntro represents a basic information about your business
2975type BusinessIntro struct {
2976 // Title text of the business intro
2977 //
2978 // optional
2979 Title *string `json:"title,omitempty"`
2980 // Message text of the business intro
2981 //
2982 // optional
2983 Message *string `json:"message,omitempty"`
2984 // Sticker of the business intro
2985 //
2986 // optional
2987 Sticker *Sticker `json:"sticker,omitempty"`
2988}
2989
2990// BusinessLocation represents a business geodata
2991type BusinessLocation struct {
2992 // Address of the business
2993 Address string `json:"address"`
2994 // Location of the business
2995 //
2996 // optional
2997 Location *Location `json:"location,omitempty"`
2998}
2999
3000// BusinessOpeningHoursInterval represents a business working interval
3001type BusinessOpeningHoursInterval struct {
3002 // OpeningMinute is the minute's sequence number in a week, starting on Monday,
3003 // marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60
3004 OpeningMinute int `json:"opening_minute"`
3005 // ClosingMinute is the minute's sequence number in a week, starting on Monday,
3006 // marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60
3007 ClosingMinute int `json:"closing_minute"`
3008}
3009
3010// BusinessOpeningHours represents a set of business working intervals
3011type BusinessOpeningHours struct {
3012 // TimeZoneName is the unique name of the time zone
3013 // for which the opening hours are defined
3014 TimeZoneName string `json:"time_zone_name"`
3015 // OpeningHours is the list of time intervals describing
3016 // business opening hours
3017 OpeningHours []BusinessOpeningHoursInterval `json:"opening_hours"`
3018}
3019
3020// ChatLocation represents a location to which a chat is connected.
3021type ChatLocation struct {
3022 // Location is the location to which the supergroup is connected. Can't be a
3023 // live location.
3024 Location Location `json:"location"`
3025 // Address is the location address; 1-64 characters, as defined by the chat
3026 // owner
3027 Address string `json:"address"`
3028}
3029
3030const (
3031 ReactionTypeEmoji = "emoji"
3032 ReactionTypeCustomEmoji = "custom_emoji"
3033)
3034
3035// ReactionType describes the type of a reaction. Currently, it can be one of: "emoji", "custom_emoji"
3036type ReactionType struct {
3037 // Type of the reaction. Can be "emoji", "custom_emoji"
3038 Type string `json:"type"`
3039 // Emoji type "emoji" only. Is a reaction emoji.
3040 Emoji string `json:"emoji"`
3041 // CustomEmoji type "custom_emoji" only. Is a custom emoji identifier.
3042 CustomEmoji string `json:"custom_emoji"`
3043}
3044
3045func (r ReactionType) IsEmoji() bool {
3046 return r.Type == ReactionTypeEmoji
3047}
3048
3049func (r ReactionType) IsCustomEmoji() bool {
3050 return r.Type == ReactionTypeCustomEmoji
3051}
3052
3053// ReactionCount represents a reaction added to a message along with the number of times it was added.
3054type ReactionCount struct {
3055 // Type of the reaction
3056 Type ReactionType `json:"type"`
3057 // TotalCount number of times the reaction was added
3058 TotalCount int `json:"total_count"`
3059}
3060
3061// MessageReactionUpdated represents a change of a reaction on a message performed by a user.
3062type MessageReactionUpdated struct {
3063 // Chat containing the message the user reacted to.
3064 Chat Chat `json:"chat"`
3065 // MessageID unique identifier of the message inside the chat.
3066 MessageID int `json:"message_id"`
3067 // User that changed the reaction, if the user isn't anonymous.
3068 //
3069 // optional
3070 User *User `json:"user"`
3071 // ActorChat the chat on behalf of which the reaction was changed,
3072 // if the user is anonymous.
3073 //
3074 // optional
3075 ActorChat *Chat `json:"actor_chat"`
3076 // Date of the change in Unix time.
3077 Date int64 `json:"date"`
3078 // OldReaction is a previous list of reaction types that were set by the user.
3079 OldReaction []ReactionType `json:"old_reaction"`
3080 // NewReaction is a new list of reaction types that have been set by the user.
3081 NewReaction []ReactionType `json:"new_reaction"`
3082}
3083
3084// MessageReactionCountUpdated represents reaction changes on a message with anonymous reactions.
3085type MessageReactionCountUpdated struct {
3086 // Chat containing the message.
3087 Chat Chat `json:"chat"`
3088 // MessageID unique identifier of the message inside the chat.
3089 MessageID int `json:"message_id"`
3090 // Date of the change in Unix time.
3091 Date int64 `json:"date"`
3092 // Reactions is a list of reactions that are present on the message.
3093 Reactions []ReactionCount `json:"reactions"`
3094}
3095
3096// ForumTopic represents a forum topic.
3097type ForumTopic struct {
3098 // MessageThreadID is the unique identifier of the forum topic
3099 MessageThreadID int `json:"message_thread_id"`
3100 // Name is the name of the topic
3101 Name string `json:"name"`
3102 // IconColor is the color of the topic icon in RGB format
3103 IconColor int `json:"icon_color"`
3104 // IconCustomEmojiID is the unique identifier of the custom emoji
3105 // shown as the topic icon
3106 //
3107 // optional
3108 IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
3109}
3110
3111// BotCommand represents a bot command.
3112type BotCommand struct {
3113 // Command text of the command, 1-32 characters.
3114 // Can contain only lowercase English letters, digits and underscores.
3115 Command string `json:"command"`
3116 // Description of the command, 3-256 characters.
3117 Description string `json:"description"`
3118}
3119
3120// BotCommandScope represents the scope to which bot commands are applied.
3121//
3122// It contains the fields for all types of scopes, different types only support
3123// specific (or no) fields.
3124type BotCommandScope struct {
3125 Type string `json:"type"`
3126 ChatID int64 `json:"chat_id,omitempty"`
3127 UserID int64 `json:"user_id,omitempty"`
3128}
3129
3130// BotName represents the bot's name.
3131type BotName struct {
3132 Name string `json:"name"`
3133}
3134
3135// BotDescription represents the bot's description.
3136type BotDescription struct {
3137 Description string `json:"description"`
3138}
3139
3140// BotShortDescription represents the bot's short description
3141type BotShortDescription struct {
3142 ShortDescription string `json:"short_description"`
3143}
3144
3145// MenuButton describes the bot's menu button in a private chat.
3146type MenuButton struct {
3147 // Type is the type of menu button, must be one of:
3148 // - `commands`
3149 // - `web_app`
3150 // - `default`
3151 Type string `json:"type"`
3152 // Text is the text on the button, for `web_app` type.
3153 Text string `json:"text,omitempty"`
3154 // WebApp is the description of the Web App that will be launched when the
3155 // user presses the button for the `web_app` type.
3156 WebApp *WebAppInfo `json:"web_app,omitempty"`
3157}
3158
3159const (
3160 ChatBoostSourcePremium = "premium"
3161 ChatBoostSourceGiftCode = "gift_code"
3162 ChatBoostSourceGiveaway = "giveaway"
3163)
3164
3165// ChatBoostSource describes the source of a chat boost
3166type ChatBoostSource struct {
3167 // Source of the boost, It can be one of:
3168 // "premium", "gift_code", "giveaway"
3169 Source string `json:"source"`
3170 // For "premium": User that boosted the chat
3171 // For "gift_code": User for which the gift code was created
3172 // Optional for "giveaway": User that won the prize in the giveaway if any
3173 User *User `json:"user,omitempty"`
3174 // GiveawayMessageID "giveaway" only.
3175 // Is an identifier of a message in the chat with the giveaway;
3176 // the message could have been deleted already. May be 0 if the message isn't sent yet.
3177 GiveawayMessageID int `json:"giveaway_message_id,omitempty"`
3178 // IsUnclaimed "giveaway" only.
3179 // True, if the giveaway was completed, but there was no user to win the prize
3180 //
3181 // optional
3182 IsUnclaimed bool `json:"is_unclaimed,omitempty"`
3183}
3184
3185func (c ChatBoostSource) IsPremium() bool {
3186 return c.Source == ChatBoostSourcePremium
3187}
3188
3189func (c ChatBoostSource) IsGiftCode() bool {
3190 return c.Source == ChatBoostSourceGiftCode
3191}
3192
3193func (c ChatBoostSource) IsGiveaway() bool {
3194 return c.Source == ChatBoostSourceGiveaway
3195}
3196
3197// ChatBoost contains information about a chat boost.
3198type ChatBoost struct {
3199 // BoostID is an unique identifier of the boost
3200 BoostID string `json:"boost_id"`
3201 // AddDate is a point in time (Unix timestamp) when the chat was boosted
3202 AddDate int64 `json:"add_date"`
3203 // ExpirationDate is a point in time (Unix timestamp) when the boost will
3204 // automatically expire, unless the booster's Telegram Premium subscription is prolonged
3205 ExpirationDate int64 `json:"expiration_date"`
3206 // Source of the added boost
3207 Source ChatBoostSource `json:"source"`
3208}
3209
3210// ChatBoostUpdated represents a boost added to a chat or changed.
3211type ChatBoostUpdated struct {
3212 // Chat which was boosted
3213 Chat Chat `json:"chat"`
3214 // Boost infomation about the chat boost
3215 Boost ChatBoost `json:"boost"`
3216}
3217
3218// ChatBoostRemoved represents a boost removed from a chat.
3219type ChatBoostRemoved struct {
3220 // Chat which was boosted
3221 Chat Chat `json:"chat"`
3222 // BoostID unique identifier of the boost
3223 BoostID string `json:"boost_id"`
3224 // RemoveDate point in time (Unix timestamp) when the boost was removed
3225 RemoveDate int64 `json:"remove_date"`
3226 // Source of the removed boost
3227 Source ChatBoostSource `json:"source"`
3228}
3229
3230// UserChatBoosts represents a list of boosts added to a chat by a user.
3231type UserChatBoosts struct {
3232 // Boosts is the list of boosts added to the chat by the user
3233 Boosts []ChatBoost `json:"boosts"`
3234}
3235
3236// BusinessConnection describes the connection of the bot with a business account.
3237type BusinessConnection struct {
3238 // ID is an unique identifier of the business connection
3239 ID string `json:"id"`
3240 // User is a business account user that created the business connection
3241 User User `json:"user"`
3242 // UserChatID identifier of a private chat with the user who
3243 // created the business connection.
3244 UserChatID int64 `json:"user_chat_id"`
3245 // Date the connection was established in Unix time
3246 Date int64 `json:"date"`
3247 // CanReply is True, if the bot can act on behalf of the
3248 // business account in chats that were active in the last 24 hours
3249 CanReply bool `json:"can_reply"`
3250 // IsEnabled is True, if the connection is active
3251 IsEnabled bool `json:"is_enabled"`
3252}
3253
3254// BusinessMessagesDeleted is received when messages are deleted
3255// from a connected business account.
3256type BusinessMessagesDeleted struct {
3257 // BusinessConnectionID is an unique identifier
3258 // of the business connection
3259 BusinessConnectionID string `json:"business_connection_id"`
3260 // Chat is the information about a chat in the business account.
3261 // The bot may not have access to the chat or the corresponding user.
3262 Chat Chat `json:"chat"`
3263 // MessageIDs is a JSON-serialized list of identifiers of deleted messages
3264 // in the chat of the business account
3265 MessageIDs []int `json:"message_ids"`
3266}
3267
3268// ResponseParameters are various errors that can be returned in APIResponse.
3269type ResponseParameters struct {
3270 // The group has been migrated to a supergroup with the specified identifier.
3271 //
3272 // optional
3273 MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
3274 // In case of exceeding flood control, the number of seconds left to wait
3275 // before the request can be repeated.
3276 //
3277 // optional
3278 RetryAfter int `json:"retry_after,omitempty"`
3279}
3280
3281// BaseInputMedia is a base type for the InputMedia types.
3282type BaseInputMedia struct {
3283 // Type of the result.
3284 Type string `json:"type"`
3285 // Media file to send. Pass a file_id to send a file
3286 // that exists on the Telegram servers (recommended),
3287 // pass an HTTP URL for Telegram to get a file from the Internet,
3288 // or pass “attach://<file_attach_name>” to upload a new one
3289 // using multipart/form-data under <file_attach_name> name.
3290 Media RequestFileData `json:"media"`
3291 // thumb intentionally missing as it is not currently compatible
3292
3293 // Caption of the video to be sent, 0-1024 characters after entities parsing.
3294 //
3295 // optional
3296 Caption string `json:"caption,omitempty"`
3297 // ParseMode mode for parsing entities in the video caption.
3298 // See formatting options for more details
3299 // (https://core.telegram.org/bots/api#formatting-options).
3300 //
3301 // optional
3302 ParseMode string `json:"parse_mode,omitempty"`
3303 // CaptionEntities is a list of special entities that appear in the caption,
3304 // which can be specified instead of parse_mode
3305 //
3306 // optional
3307 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3308 // Pass True, if the caption must be shown above the message media
3309 //
3310 // optional
3311 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
3312 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
3313 //
3314 // optional
3315 HasSpoiler bool `json:"has_spoiler,omitempty"`
3316}
3317
3318// InputMediaPhoto is a photo to send as part of a media group.
3319type InputMediaPhoto struct {
3320 BaseInputMedia
3321}
3322
3323// InputMediaVideo is a video to send as part of a media group.
3324type InputMediaVideo struct {
3325 BaseInputMedia
3326 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3327 // the file is supported server-side.
3328 //
3329 // optional
3330 Thumb RequestFileData `json:"thumbnail,omitempty"`
3331 // Width video width
3332 //
3333 // optional
3334 Width int `json:"width,omitempty"`
3335 // Height video height
3336 //
3337 // optional
3338 Height int `json:"height,omitempty"`
3339 // Duration video duration
3340 //
3341 // optional
3342 Duration int `json:"duration,omitempty"`
3343 // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
3344 //
3345 // optional
3346 SupportsStreaming bool `json:"supports_streaming,omitempty"`
3347 // HasSpoiler pass True, if the video needs to be covered with a spoiler animation
3348 //
3349 // optional
3350 HasSpoiler bool `json:"has_spoiler,omitempty"`
3351}
3352
3353// InputMediaAnimation is an animation to send as part of a media group.
3354type InputMediaAnimation struct {
3355 BaseInputMedia
3356 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3357 // the file is supported server-side.
3358 //
3359 // optional
3360 Thumb RequestFileData `json:"thumbnail,omitempty"`
3361 // Width video width
3362 //
3363 // optional
3364 Width int `json:"width,omitempty"`
3365 // Height video height
3366 //
3367 // optional
3368 Height int `json:"height,omitempty"`
3369 // Duration video duration
3370 //
3371 // optional
3372 Duration int `json:"duration,omitempty"`
3373 // HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
3374 //
3375 // optional
3376 HasSpoiler bool `json:"has_spoiler,omitempty"`
3377}
3378
3379// InputMediaAudio is an audio to send as part of a media group.
3380type InputMediaAudio struct {
3381 BaseInputMedia
3382 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3383 // the file is supported server-side.
3384 //
3385 // optional
3386 Thumb RequestFileData `json:"thumbnail,omitempty"`
3387 // Duration of the audio in seconds
3388 //
3389 // optional
3390 Duration int `json:"duration,omitempty"`
3391 // Performer of the audio
3392 //
3393 // optional
3394 Performer string `json:"performer,omitempty"`
3395 // Title of the audio
3396 //
3397 // optional
3398 Title string `json:"title,omitempty"`
3399}
3400
3401// InputMediaDocument is a general file to send as part of a media group.
3402type InputMediaDocument struct {
3403 BaseInputMedia
3404 // Thumbnail of the file sent; can be ignored if thumbnail generation for
3405 // the file is supported server-side.
3406 //
3407 // optional
3408 Thumb RequestFileData `json:"thumbnail,omitempty"`
3409 // DisableContentTypeDetection disables automatic server-side content type
3410 // detection for files uploaded using multipart/form-data. Always true, if
3411 // the document is sent as part of an album
3412 //
3413 // optional
3414 DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
3415}
3416
3417// Constant values for sticker types
3418const (
3419 StickerTypeRegular = "regular"
3420 StickerTypeMask = "mask"
3421 StickerTypeCustomEmoji = "custom_emoji"
3422)
3423
3424// Sticker represents a sticker.
3425type Sticker struct {
3426 // FileID is an identifier for this file, which can be used to download or
3427 // reuse the file
3428 FileID string `json:"file_id"`
3429 // FileUniqueID is a unique identifier for this file,
3430 // which is supposed to be the same over time and for different bots.
3431 // Can't be used to download or reuse the file.
3432 FileUniqueID string `json:"file_unique_id"`
3433 // Type is a type of the sticker, currently one of “regular”,
3434 // “mask”, “custom_emoji”. The type of the sticker is independent
3435 // from its format, which is determined by the fields is_animated and is_video.
3436 Type string `json:"type"`
3437 // Width sticker width
3438 Width int `json:"width"`
3439 // Height sticker height
3440 Height int `json:"height"`
3441 // IsAnimated true, if the sticker is animated
3442 //
3443 // optional
3444 IsAnimated bool `json:"is_animated,omitempty"`
3445 // IsVideo true, if the sticker is a video sticker
3446 //
3447 // optional
3448 IsVideo bool `json:"is_video,omitempty"`
3449 // Thumbnail sticker thumbnail in the .WEBP or .JPG format
3450 //
3451 // optional
3452 Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
3453 // Emoji associated with the sticker
3454 //
3455 // optional
3456 Emoji string `json:"emoji,omitempty"`
3457 // SetName of the sticker set to which the sticker belongs
3458 //
3459 // optional
3460 SetName string `json:"set_name,omitempty"`
3461 // PremiumAnimation for premium regular stickers, premium animation for the sticker
3462 //
3463 // optional
3464 PremiumAnimation *File `json:"premium_animation,omitempty"`
3465 // MaskPosition is for mask stickers, the position where the mask should be
3466 // placed
3467 //
3468 // optional
3469 MaskPosition *MaskPosition `json:"mask_position,omitempty"`
3470 // CustomEmojiID for custom emoji stickers, unique identifier of the custom emoji
3471 //
3472 // optional
3473 CustomEmojiID string `json:"custom_emoji_id,omitempty"`
3474 // 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
3475 //
3476 //optional
3477 NeedsRepainting bool `json:"needs_reainting,omitempty"`
3478 // FileSize
3479 //
3480 // optional
3481 FileSize int `json:"file_size,omitempty"`
3482}
3483
3484// IsRegular returns if the Sticker is regular
3485func (s Sticker) IsRegular() bool {
3486 return s.Type == StickerTypeRegular
3487}
3488
3489// IsMask returns if the Sticker is mask
3490func (s Sticker) IsMask() bool {
3491 return s.Type == StickerTypeMask
3492}
3493
3494// IsCustomEmoji returns if the Sticker is custom emoji
3495func (s Sticker) IsCustomEmoji() bool {
3496 return s.Type == StickerTypeCustomEmoji
3497}
3498
3499// StickerSet represents a sticker set.
3500type StickerSet struct {
3501 // Name sticker set name
3502 Name string `json:"name"`
3503 // Title sticker set title
3504 Title string `json:"title"`
3505 // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
3506 StickerType string `json:"sticker_type"`
3507 // ContainsMasks true, if the sticker set contains masks
3508 //
3509 // deprecated. Use sticker_type instead
3510 ContainsMasks bool `json:"contains_masks"`
3511 // Stickers list of all set stickers
3512 Stickers []Sticker `json:"stickers"`
3513 // Thumb is the sticker set thumbnail in the .WEBP or .TGS format
3514 Thumbnail *PhotoSize `json:"thumbnail"`
3515}
3516
3517// IsRegular returns if the StickerSet is regular
3518func (s StickerSet) IsRegular() bool {
3519 return s.StickerType == StickerTypeRegular
3520}
3521
3522// IsMask returns if the StickerSet is mask
3523func (s StickerSet) IsMask() bool {
3524 return s.StickerType == StickerTypeMask
3525}
3526
3527// IsCustomEmoji returns if the StickerSet is custom emoji
3528func (s StickerSet) IsCustomEmoji() bool {
3529 return s.StickerType == StickerTypeCustomEmoji
3530}
3531
3532// MaskPosition describes the position on faces where a mask should be placed
3533// by default.
3534type MaskPosition struct {
3535 // The part of the face relative to which the mask should be placed.
3536 // One of “forehead”, “eyes”, “mouth”, or “chin”.
3537 Point string `json:"point"`
3538 // Shift by X-axis measured in widths of the mask scaled to the face size,
3539 // from left to right. For example, choosing -1.0 will place mask just to
3540 // the left of the default mask position.
3541 XShift float64 `json:"x_shift"`
3542 // Shift by Y-axis measured in heights of the mask scaled to the face size,
3543 // from top to bottom. For example, 1.0 will place the mask just below the
3544 // default mask position.
3545 YShift float64 `json:"y_shift"`
3546 // Mask scaling coefficient. For example, 2.0 means double size.
3547 Scale float64 `json:"scale"`
3548}
3549
3550// InputSticker describes a sticker to be added to a sticker set.
3551type InputSticker struct {
3552 // 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.
3553 Sticker RequestFile `json:"sticker"`
3554 // Format of the added sticker, must be one of “static” for a
3555 // .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video
3556 Format string `json:"format"`
3557 // List of 1-20 emoji associated with the sticker
3558 EmojiList []string `json:"emoji_list"`
3559 // Position where the mask should be placed on faces. For “mask” stickers only.
3560 //
3561 // optional
3562 MaskPosition *MaskPosition `json:"mask_position"`
3563 // List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only.
3564 //
3565 // optional
3566 Keywords []string `json:"keywords"`
3567}
3568
3569// Game represents a game. Use BotFather to create and edit games, their short
3570// names will act as unique identifiers.
3571type Game struct {
3572 // Title of the game
3573 Title string `json:"title"`
3574 // Description of the game
3575 Description string `json:"description"`
3576 // Photo that will be displayed in the game message in chats.
3577 Photo []PhotoSize `json:"photo"`
3578 // Text a brief description of the game or high scores included in the game message.
3579 // Can be automatically edited to include current high scores for the game
3580 // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
3581 //
3582 // optional
3583 Text string `json:"text,omitempty"`
3584 // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
3585 //
3586 // optional
3587 TextEntities []MessageEntity `json:"text_entities,omitempty"`
3588 // Animation is an animation that will be displayed in the game message in chats.
3589 // Upload via BotFather (https://t.me/botfather).
3590 //
3591 // optional
3592 Animation Animation `json:"animation,omitempty"`
3593}
3594
3595// GameHighScore is a user's score and position on the leaderboard.
3596type GameHighScore struct {
3597 // Position in high score table for the game
3598 Position int `json:"position"`
3599 // User user
3600 User User `json:"user"`
3601 // Score score
3602 Score int `json:"score"`
3603}
3604
3605// CallbackGame is for starting a game in an inline keyboard button.
3606type CallbackGame struct{}
3607
3608// SwitchInlineQueryChosenChat represents an inline button that switches the current
3609// user to inline mode in a chosen chat, with an optional default inline query.
3610type SwitchInlineQueryChosenChat struct {
3611 // Query is default inline query to be inserted in the input field.
3612 // If left empty, only the bot's username will be inserted
3613 //
3614 // optional
3615 Query string `json:"query,omitempty"`
3616 // AllowUserChats is True, if private chats with users can be chosen
3617 //
3618 // optional
3619 AllowUserChats bool `json:"allow_user_chats,omitempty"`
3620 // AllowBotChats is True, if private chats with bots can be chosen
3621 //
3622 // optional
3623 AllowBotChats bool `json:"allow_bot_chats,omitempty"`
3624 // AllowGroupChats is True, if group and supergroup chats can be chosen
3625 //
3626 // optional
3627 AllowGroupChats bool `json:"allow_group_chats,omitempty"`
3628 // AllowChannelChats is True, if channel chats can be chosen
3629 //
3630 // optional
3631 AllowChannelChats bool `json:"allow_channel_chats,omitempty"`
3632}
3633
3634// WebhookInfo is information about a currently set webhook.
3635type WebhookInfo struct {
3636 // URL webhook URL, may be empty if webhook is not set up.
3637 URL string `json:"url"`
3638 // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
3639 HasCustomCertificate bool `json:"has_custom_certificate"`
3640 // PendingUpdateCount number of updates awaiting delivery.
3641 PendingUpdateCount int `json:"pending_update_count"`
3642 // IPAddress is the currently used webhook IP address
3643 //
3644 // optional
3645 IPAddress string `json:"ip_address,omitempty"`
3646 // LastErrorDate unix time for the most recent error
3647 // that happened when trying to deliver an update via webhook.
3648 //
3649 // optional
3650 LastErrorDate int `json:"last_error_date,omitempty"`
3651 // LastErrorMessage error message in human-readable format for the most recent error
3652 // that happened when trying to deliver an update via webhook.
3653 //
3654 // optional
3655 LastErrorMessage string `json:"last_error_message,omitempty"`
3656 // LastSynchronizationErrorDate is the unix time of the most recent error that
3657 // happened when trying to synchronize available updates with Telegram datacenters.
3658 LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
3659 // MaxConnections maximum allowed number of simultaneous
3660 // HTTPS connections to the webhook for update delivery.
3661 //
3662 // optional
3663 MaxConnections int `json:"max_connections,omitempty"`
3664 // AllowedUpdates is a list of update types the bot is subscribed to.
3665 // Defaults to all update types
3666 //
3667 // optional
3668 AllowedUpdates []string `json:"allowed_updates,omitempty"`
3669}
3670
3671// IsSet returns true if a webhook is currently set.
3672func (info WebhookInfo) IsSet() bool {
3673 return info.URL != ""
3674}
3675
3676// InlineQuery is a Query from Telegram for an inline request.
3677type InlineQuery struct {
3678 // ID unique identifier for this query
3679 ID string `json:"id"`
3680 // From sender
3681 From *User `json:"from"`
3682 // Query text of the query (up to 256 characters).
3683 Query string `json:"query"`
3684 // Offset of the results to be returned, can be controlled by the bot.
3685 Offset string `json:"offset"`
3686 // Type of the chat, from which the inline query was sent. Can be either
3687 // “sender” for a private chat with the inline query sender, “private”,
3688 // “group”, “supergroup”, or “channel”. The chat type should be always known
3689 // for requests sent from official clients and most third-party clients,
3690 // unless the request was sent from a secret chat
3691 //
3692 // optional
3693 ChatType string `json:"chat_type,omitempty"`
3694 // Location sender location, only for bots that request user location.
3695 //
3696 // optional
3697 Location *Location `json:"location,omitempty"`
3698}
3699
3700// InlineQueryResultCachedAudio is an inline query response with cached audio.
3701type InlineQueryResultCachedAudio struct {
3702 // Type of the result, must be audio
3703 Type string `json:"type"`
3704 // ID unique identifier for this result, 1-64 bytes
3705 ID string `json:"id"`
3706 // AudioID a valid file identifier for the audio file
3707 AudioID string `json:"audio_file_id"`
3708 // Caption 0-1024 characters after entities parsing
3709 //
3710 // optional
3711 Caption string `json:"caption,omitempty"`
3712 // ParseMode mode for parsing entities in the video caption.
3713 // See formatting options for more details
3714 // (https://core.telegram.org/bots/api#formatting-options).
3715 //
3716 // optional
3717 ParseMode string `json:"parse_mode,omitempty"`
3718 // CaptionEntities is a list of special entities that appear in the caption,
3719 // which can be specified instead of parse_mode
3720 //
3721 // optional
3722 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3723 // ReplyMarkup inline keyboard attached to the message
3724 //
3725 // optional
3726 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3727 // InputMessageContent content of the message to be sent instead of the audio
3728 //
3729 // optional
3730 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3731}
3732
3733// InlineQueryResultCachedDocument is an inline query response with cached document.
3734type InlineQueryResultCachedDocument struct {
3735 // Type of the result, must be a document
3736 Type string `json:"type"`
3737 // ID unique identifier for this result, 1-64 bytes
3738 ID string `json:"id"`
3739 // DocumentID a valid file identifier for the file
3740 DocumentID string `json:"document_file_id"`
3741 // Title for the result
3742 //
3743 // optional
3744 Title string `json:"title,omitempty"`
3745 // Caption of the document to be sent, 0-1024 characters after entities parsing
3746 //
3747 // optional
3748 Caption string `json:"caption,omitempty"`
3749 // Description short description of the result
3750 //
3751 // optional
3752 Description string `json:"description,omitempty"`
3753 // ParseMode mode for parsing entities in the video caption.
3754 // // See formatting options for more details
3755 // // (https://core.telegram.org/bots/api#formatting-options).
3756 //
3757 // optional
3758 ParseMode string `json:"parse_mode,omitempty"`
3759 // CaptionEntities is a list of special entities that appear in the caption,
3760 // which can be specified instead of parse_mode
3761 //
3762 // optional
3763 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3764 // ReplyMarkup inline keyboard attached to the message
3765 //
3766 // optional
3767 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3768 // InputMessageContent content of the message to be sent instead of the file
3769 //
3770 // optional
3771 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3772}
3773
3774// InlineQueryResultCachedGIF is an inline query response with cached gif.
3775type InlineQueryResultCachedGIF struct {
3776 // Type of the result, must be gif.
3777 Type string `json:"type"`
3778 // ID unique identifier for this result, 1-64 bytes.
3779 ID string `json:"id"`
3780 // GifID a valid file identifier for the GIF file.
3781 GIFID string `json:"gif_file_id"`
3782 // Title for the result
3783 //
3784 // optional
3785 Title string `json:"title,omitempty"`
3786 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
3787 //
3788 // optional
3789 Caption string `json:"caption,omitempty"`
3790 // ParseMode mode for parsing entities in the caption.
3791 // See formatting options for more details
3792 // (https://core.telegram.org/bots/api#formatting-options).
3793 //
3794 // optional
3795 ParseMode string `json:"parse_mode,omitempty"`
3796 // CaptionEntities is a list of special entities that appear in the caption,
3797 // which can be specified instead of parse_mode
3798 //
3799 // optional
3800 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3801 // Pass True, if the caption must be shown above the message media
3802 //
3803 // optional
3804 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
3805 // ReplyMarkup inline keyboard attached to the message.
3806 //
3807 // optional
3808 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3809 // InputMessageContent content of the message to be sent instead of the GIF animation.
3810 //
3811 // optional
3812 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3813}
3814
3815// InlineQueryResultCachedMPEG4GIF is an inline query response with cached
3816// H.264/MPEG-4 AVC video without sound gif.
3817type InlineQueryResultCachedMPEG4GIF struct {
3818 // Type of the result, must be mpeg4_gif
3819 Type string `json:"type"`
3820 // ID unique identifier for this result, 1-64 bytes
3821 ID string `json:"id"`
3822 // MPEG4FileID a valid file identifier for the MP4 file
3823 MPEG4FileID string `json:"mpeg4_file_id"`
3824 // Title for the result
3825 //
3826 // optional
3827 Title string `json:"title,omitempty"`
3828 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
3829 //
3830 // optional
3831 Caption string `json:"caption,omitempty"`
3832 // ParseMode mode for parsing entities in the caption.
3833 // See formatting options for more details
3834 // (https://core.telegram.org/bots/api#formatting-options).
3835 //
3836 // optional
3837 ParseMode string `json:"parse_mode,omitempty"`
3838 // ParseMode mode for parsing entities in the video caption.
3839 // See formatting options for more details
3840 // (https://core.telegram.org/bots/api#formatting-options).
3841 //
3842 // optional
3843 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3844 // Pass True, if the caption must be shown above the message media
3845 //
3846 // optional
3847 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
3848 // ReplyMarkup inline keyboard attached to the message.
3849 //
3850 // optional
3851 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3852 // InputMessageContent content of the message to be sent instead of the video animation.
3853 //
3854 // optional
3855 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3856}
3857
3858// InlineQueryResultCachedPhoto is an inline query response with cached photo.
3859type InlineQueryResultCachedPhoto struct {
3860 // Type of the result, must be a photo.
3861 Type string `json:"type"`
3862 // ID unique identifier for this result, 1-64 bytes.
3863 ID string `json:"id"`
3864 // PhotoID a valid file identifier of the photo.
3865 PhotoID string `json:"photo_file_id"`
3866 // Title for the result.
3867 //
3868 // optional
3869 Title string `json:"title,omitempty"`
3870 // Description short description of the result.
3871 //
3872 // optional
3873 Description string `json:"description,omitempty"`
3874 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
3875 //
3876 // optional
3877 Caption string `json:"caption,omitempty"`
3878 // ParseMode mode for parsing entities in the photo caption.
3879 // See formatting options for more details
3880 // (https://core.telegram.org/bots/api#formatting-options).
3881 //
3882 // optional
3883 ParseMode string `json:"parse_mode,omitempty"`
3884 // CaptionEntities is a list of special entities that appear in the caption,
3885 // which can be specified instead of parse_mode
3886 //
3887 // optional
3888 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3889 // Pass True, if the caption must be shown above the message media
3890 //
3891 // optional
3892 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
3893 // ReplyMarkup inline keyboard attached to the message.
3894 //
3895 // optional
3896 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3897 // InputMessageContent content of the message to be sent instead of the photo.
3898 //
3899 // optional
3900 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3901}
3902
3903// InlineQueryResultCachedSticker is an inline query response with cached sticker.
3904type InlineQueryResultCachedSticker struct {
3905 // Type of the result, must be a sticker
3906 Type string `json:"type"`
3907 // ID unique identifier for this result, 1-64 bytes
3908 ID string `json:"id"`
3909 // StickerID a valid file identifier of the sticker
3910 StickerID string `json:"sticker_file_id"`
3911 // Title is a title
3912 Title string `json:"title"`
3913 // ReplyMarkup inline keyboard attached to the message
3914 //
3915 // optional
3916 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3917 // InputMessageContent content of the message to be sent instead of the sticker
3918 //
3919 // optional
3920 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3921}
3922
3923// InlineQueryResultCachedVideo is an inline query response with cached video.
3924type InlineQueryResultCachedVideo struct {
3925 // Type of the result, must be video
3926 Type string `json:"type"`
3927 // ID unique identifier for this result, 1-64 bytes
3928 ID string `json:"id"`
3929 // VideoID a valid file identifier for the video file
3930 VideoID string `json:"video_file_id"`
3931 // Title for the result
3932 Title string `json:"title"`
3933 // Description short description of the result
3934 //
3935 // optional
3936 Description string `json:"description,omitempty"`
3937 // Caption of the video to be sent, 0-1024 characters after entities parsing
3938 //
3939 // optional
3940 Caption string `json:"caption,omitempty"`
3941 // ParseMode mode for parsing entities in the video caption.
3942 // See formatting options for more details
3943 // (https://core.telegram.org/bots/api#formatting-options).
3944 //
3945 // optional
3946 ParseMode string `json:"parse_mode,omitempty"`
3947 // CaptionEntities is a list of special entities that appear in the caption,
3948 // which can be specified instead of parse_mode
3949 //
3950 // optional
3951 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3952 // Pass True, if the caption must be shown above the message media
3953 //
3954 // optional
3955 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
3956 // ReplyMarkup inline keyboard attached to the message
3957 //
3958 // optional
3959 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3960 // InputMessageContent content of the message to be sent instead of the video
3961 //
3962 // optional
3963 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3964}
3965
3966// InlineQueryResultCachedVoice is an inline query response with cached voice.
3967type InlineQueryResultCachedVoice struct {
3968 // Type of the result, must be voice
3969 Type string `json:"type"`
3970 // ID unique identifier for this result, 1-64 bytes
3971 ID string `json:"id"`
3972 // VoiceID a valid file identifier for the voice message
3973 VoiceID string `json:"voice_file_id"`
3974 // Title voice message title
3975 Title string `json:"title"`
3976 // Caption 0-1024 characters after entities parsing
3977 //
3978 // optional
3979 Caption string `json:"caption,omitempty"`
3980 // ParseMode mode for parsing entities in the video caption.
3981 // See formatting options for more details
3982 // (https://core.telegram.org/bots/api#formatting-options).
3983 //
3984 // optional
3985 ParseMode string `json:"parse_mode,omitempty"`
3986 // CaptionEntities is a list of special entities that appear in the caption,
3987 // which can be specified instead of parse_mode
3988 //
3989 // optional
3990 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
3991 // ReplyMarkup inline keyboard attached to the message
3992 //
3993 // optional
3994 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3995 // InputMessageContent content of the message to be sent instead of the voice message
3996 //
3997 // optional
3998 InputMessageContent interface{} `json:"input_message_content,omitempty"`
3999}
4000
4001// InlineQueryResultArticle represents a link to an article or web page.
4002type InlineQueryResultArticle struct {
4003 // Type of the result, must be article.
4004 Type string `json:"type"`
4005 // ID unique identifier for this result, 1-64 Bytes.
4006 ID string `json:"id"`
4007 // Title of the result
4008 Title string `json:"title"`
4009 // InputMessageContent content of the message to be sent.
4010 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4011 // ReplyMarkup Inline keyboard attached to the message.
4012 //
4013 // optional
4014 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4015 // URL of the result.
4016 //
4017 // optional
4018 URL string `json:"url,omitempty"`
4019 // HideURL pass True, if you don't want the URL to be shown in the message.
4020 //
4021 // optional
4022 HideURL bool `json:"hide_url,omitempty"`
4023 // Description short description of the result.
4024 //
4025 // optional
4026 Description string `json:"description,omitempty"`
4027 // ThumbURL url of the thumbnail for the result
4028 //
4029 // optional
4030 ThumbURL string `json:"thumbnail_url,omitempty"`
4031 // ThumbWidth thumbnail width
4032 //
4033 // optional
4034 ThumbWidth int `json:"thumbnail_width,omitempty"`
4035 // ThumbHeight thumbnail height
4036 //
4037 // optional
4038 ThumbHeight int `json:"thumbnail_height,omitempty"`
4039}
4040
4041// InlineQueryResultAudio is an inline query response audio.
4042type InlineQueryResultAudio struct {
4043 // Type of the result, must be audio
4044 Type string `json:"type"`
4045 // ID unique identifier for this result, 1-64 bytes
4046 ID string `json:"id"`
4047 // URL a valid url for the audio file
4048 URL string `json:"audio_url"`
4049 // Title is a title
4050 Title string `json:"title"`
4051 // Caption 0-1024 characters after entities parsing
4052 //
4053 // optional
4054 Caption string `json:"caption,omitempty"`
4055 // ParseMode mode for parsing entities in the video caption.
4056 // See formatting options for more details
4057 // (https://core.telegram.org/bots/api#formatting-options).
4058 //
4059 // optional
4060 ParseMode string `json:"parse_mode,omitempty"`
4061 // CaptionEntities is a list of special entities that appear in the caption,
4062 // which can be specified instead of parse_mode
4063 //
4064 // optional
4065 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4066 // Performer is a performer
4067 //
4068 // optional
4069 Performer string `json:"performer,omitempty"`
4070 // Duration audio duration in seconds
4071 //
4072 // optional
4073 Duration int `json:"audio_duration,omitempty"`
4074 // ReplyMarkup inline keyboard attached to the message
4075 //
4076 // optional
4077 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4078 // InputMessageContent content of the message to be sent instead of the audio
4079 //
4080 // optional
4081 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4082}
4083
4084// InlineQueryResultContact is an inline query response contact.
4085type InlineQueryResultContact struct {
4086 Type string `json:"type"` // required
4087 ID string `json:"id"` // required
4088 PhoneNumber string `json:"phone_number"` // required
4089 FirstName string `json:"first_name"` // required
4090 LastName string `json:"last_name"`
4091 VCard string `json:"vcard"`
4092 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4093 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4094 ThumbURL string `json:"thumbnail_url"`
4095 ThumbWidth int `json:"thumbnail_width"`
4096 ThumbHeight int `json:"thumbnail_height"`
4097}
4098
4099// InlineQueryResultGame is an inline query response game.
4100type InlineQueryResultGame struct {
4101 // Type of the result, must be game
4102 Type string `json:"type"`
4103 // ID unique identifier for this result, 1-64 bytes
4104 ID string `json:"id"`
4105 // GameShortName short name of the game
4106 GameShortName string `json:"game_short_name"`
4107 // ReplyMarkup inline keyboard attached to the message
4108 //
4109 // optional
4110 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4111}
4112
4113// InlineQueryResultDocument is an inline query response document.
4114type InlineQueryResultDocument struct {
4115 // Type of the result, must be a document
4116 Type string `json:"type"`
4117 // ID unique identifier for this result, 1-64 bytes
4118 ID string `json:"id"`
4119 // Title for the result
4120 Title string `json:"title"`
4121 // Caption of the document to be sent, 0-1024 characters after entities parsing
4122 //
4123 // optional
4124 Caption string `json:"caption,omitempty"`
4125 // URL a valid url for the file
4126 URL string `json:"document_url"`
4127 // MimeType of the content of the file, either “application/pdf” or “application/zip”
4128 MimeType string `json:"mime_type"`
4129 // Description short description of the result
4130 //
4131 // optional
4132 Description string `json:"description,omitempty"`
4133 // ReplyMarkup inline keyboard attached to the message
4134 //
4135 // optional
4136 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4137 // InputMessageContent content of the message to be sent instead of the file
4138 //
4139 // optional
4140 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4141 // ThumbURL url of the thumbnail (jpeg only) for the file
4142 //
4143 // optional
4144 ThumbURL string `json:"thumbnail_url,omitempty"`
4145 // ThumbWidth thumbnail width
4146 //
4147 // optional
4148 ThumbWidth int `json:"thumbnail_width,omitempty"`
4149 // ThumbHeight thumbnail height
4150 //
4151 // optional
4152 ThumbHeight int `json:"thumbnail_height,omitempty"`
4153}
4154
4155// InlineQueryResultGIF is an inline query response GIF.
4156type InlineQueryResultGIF struct {
4157 // Type of the result, must be gif.
4158 Type string `json:"type"`
4159 // ID unique identifier for this result, 1-64 bytes.
4160 ID string `json:"id"`
4161 // URL a valid URL for the GIF file. File size must not exceed 1MB.
4162 URL string `json:"gif_url"`
4163 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
4164 ThumbURL string `json:"thumbnail_url"`
4165 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
4166 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
4167 // Width of the GIF
4168 //
4169 // optional
4170 Width int `json:"gif_width,omitempty"`
4171 // Height of the GIF
4172 //
4173 // optional
4174 Height int `json:"gif_height,omitempty"`
4175 // Duration of the GIF
4176 //
4177 // optional
4178 Duration int `json:"gif_duration,omitempty"`
4179 // Title for the result
4180 //
4181 // optional
4182 Title string `json:"title,omitempty"`
4183 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
4184 //
4185 // optional
4186 Caption string `json:"caption,omitempty"`
4187 // ParseMode mode for parsing entities in the video caption.
4188 // See formatting options for more details
4189 // (https://core.telegram.org/bots/api#formatting-options).
4190 //
4191 // optional
4192 ParseMode string `json:"parse_mode,omitempty"`
4193 // CaptionEntities is a list of special entities that appear in the caption,
4194 // which can be specified instead of parse_mode
4195 //
4196 // optional
4197 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4198 // Pass True, if the caption must be shown above the message media
4199 //
4200 // optional
4201 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
4202 // ReplyMarkup inline keyboard attached to the message
4203 //
4204 // optional
4205 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4206 // InputMessageContent content of the message to be sent instead of the GIF animation.
4207 //
4208 // optional
4209 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4210}
4211
4212// InlineQueryResultLocation is an inline query response location.
4213type InlineQueryResultLocation struct {
4214 // Type of the result, must be location
4215 Type string `json:"type"`
4216 // ID unique identifier for this result, 1-64 Bytes
4217 ID string `json:"id"`
4218 // Latitude of the location in degrees
4219 Latitude float64 `json:"latitude"`
4220 // Longitude of the location in degrees
4221 Longitude float64 `json:"longitude"`
4222 // Title of the location
4223 Title string `json:"title"`
4224 // HorizontalAccuracy is the radius of uncertainty for the location,
4225 // measured in meters; 0-1500
4226 //
4227 // optional
4228 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
4229 // LivePeriod is the period in seconds for which the location can be
4230 // updated, should be between 60 and 86400.
4231 //
4232 // optional
4233 LivePeriod int `json:"live_period,omitempty"`
4234 // Heading is for live locations, a direction in which the user is moving,
4235 // in degrees. Must be between 1 and 360 if specified.
4236 //
4237 // optional
4238 Heading int `json:"heading,omitempty"`
4239 // ProximityAlertRadius is for live locations, a maximum distance for
4240 // proximity alerts about approaching another chat member, in meters. Must
4241 // be between 1 and 100000 if specified.
4242 //
4243 // optional
4244 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
4245 // ReplyMarkup inline keyboard attached to the message
4246 //
4247 // optional
4248 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4249 // InputMessageContent content of the message to be sent instead of the location
4250 //
4251 // optional
4252 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4253 // ThumbURL url of the thumbnail for the result
4254 //
4255 // optional
4256 ThumbURL string `json:"thumbnail_url,omitempty"`
4257 // ThumbWidth thumbnail width
4258 //
4259 // optional
4260 ThumbWidth int `json:"thumbnail_width,omitempty"`
4261 // ThumbHeight thumbnail height
4262 //
4263 // optional
4264 ThumbHeight int `json:"thumbnail_height,omitempty"`
4265}
4266
4267// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
4268type InlineQueryResultMPEG4GIF struct {
4269 // Type of the result, must be mpeg4_gif
4270 Type string `json:"type"`
4271 // ID unique identifier for this result, 1-64 bytes
4272 ID string `json:"id"`
4273 // URL a valid URL for the MP4 file. File size must not exceed 1MB
4274 URL string `json:"mpeg4_url"`
4275 // Width video width
4276 //
4277 // optional
4278 Width int `json:"mpeg4_width,omitempty"`
4279 // Height vVideo height
4280 //
4281 // optional
4282 Height int `json:"mpeg4_height,omitempty"`
4283 // Duration video duration
4284 //
4285 // optional
4286 Duration int `json:"mpeg4_duration,omitempty"`
4287 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
4288 ThumbURL string `json:"thumbnail_url"`
4289 // MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
4290 ThumbMimeType string `json:"thumbnail_mime_type,omitempty"`
4291 // Title for the result
4292 //
4293 // optional
4294 Title string `json:"title,omitempty"`
4295 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
4296 //
4297 // optional
4298 Caption string `json:"caption,omitempty"`
4299 // ParseMode mode for parsing entities in the video caption.
4300 // See formatting options for more details
4301 // (https://core.telegram.org/bots/api#formatting-options).
4302 //
4303 // optional
4304 ParseMode string `json:"parse_mode,omitempty"`
4305 // CaptionEntities is a list of special entities that appear in the caption,
4306 // which can be specified instead of parse_mode
4307 //
4308 // optional
4309 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4310 // Pass True, if the caption must be shown above the message media
4311 //
4312 // optional
4313 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
4314 // ReplyMarkup inline keyboard attached to the message
4315 //
4316 // optional
4317 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4318 // InputMessageContent content of the message to be sent instead of the video animation
4319 //
4320 // optional
4321 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4322}
4323
4324// InlineQueryResultPhoto is an inline query response photo.
4325type InlineQueryResultPhoto struct {
4326 // Type of the result, must be article.
4327 Type string `json:"type"`
4328 // ID unique identifier for this result, 1-64 Bytes.
4329 ID string `json:"id"`
4330 // URL a valid URL of the photo. Photo must be in jpeg format.
4331 // Photo size must not exceed 5MB.
4332 URL string `json:"photo_url"`
4333 // MimeType
4334 MimeType string `json:"mime_type"`
4335 // Width of the photo
4336 //
4337 // optional
4338 Width int `json:"photo_width,omitempty"`
4339 // Height of the photo
4340 //
4341 // optional
4342 Height int `json:"photo_height,omitempty"`
4343 // ThumbURL url of the thumbnail for the photo.
4344 //
4345 // optional
4346 ThumbURL string `json:"thumbnail_url,omitempty"`
4347 // Title for the result
4348 //
4349 // optional
4350 Title string `json:"title,omitempty"`
4351 // Description short description of the result
4352 //
4353 // optional
4354 Description string `json:"description,omitempty"`
4355 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
4356 //
4357 // optional
4358 Caption string `json:"caption,omitempty"`
4359 // ParseMode mode for parsing entities in the photo caption.
4360 // See formatting options for more details
4361 // (https://core.telegram.org/bots/api#formatting-options).
4362 //
4363 // optional
4364 ParseMode string `json:"parse_mode,omitempty"`
4365 // ReplyMarkup inline keyboard attached to the message.
4366 //
4367 // optional
4368 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4369 // CaptionEntities is a list of special entities that appear in the caption,
4370 // which can be specified instead of parse_mode
4371 //
4372 // optional
4373 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4374 // Pass True, if the caption must be shown above the message media
4375 //
4376 // optional
4377 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
4378 // InputMessageContent content of the message to be sent instead of the photo.
4379 //
4380 // optional
4381 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4382}
4383
4384// InlineQueryResultVenue is an inline query response venue.
4385type InlineQueryResultVenue struct {
4386 // Type of the result, must be venue
4387 Type string `json:"type"`
4388 // ID unique identifier for this result, 1-64 Bytes
4389 ID string `json:"id"`
4390 // Latitude of the venue location in degrees
4391 Latitude float64 `json:"latitude"`
4392 // Longitude of the venue location in degrees
4393 Longitude float64 `json:"longitude"`
4394 // Title of the venue
4395 Title string `json:"title"`
4396 // Address of the venue
4397 Address string `json:"address"`
4398 // FoursquareID foursquare identifier of the venue if known
4399 //
4400 // optional
4401 FoursquareID string `json:"foursquare_id,omitempty"`
4402 // FoursquareType foursquare type of the venue, if known.
4403 // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
4404 //
4405 // optional
4406 FoursquareType string `json:"foursquare_type,omitempty"`
4407 // GooglePlaceID is the Google Places identifier of the venue
4408 //
4409 // optional
4410 GooglePlaceID string `json:"google_place_id,omitempty"`
4411 // GooglePlaceType is the Google Places type of the venue
4412 //
4413 // optional
4414 GooglePlaceType string `json:"google_place_type,omitempty"`
4415 // ReplyMarkup inline keyboard attached to the message
4416 //
4417 // optional
4418 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4419 // InputMessageContent content of the message to be sent instead of the venue
4420 //
4421 // optional
4422 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4423 // ThumbURL url of the thumbnail for the result
4424 //
4425 // optional
4426 ThumbURL string `json:"thumbnail_url,omitempty"`
4427 // ThumbWidth thumbnail width
4428 //
4429 // optional
4430 ThumbWidth int `json:"thumbnail_width,omitempty"`
4431 // ThumbHeight thumbnail height
4432 //
4433 // optional
4434 ThumbHeight int `json:"thumbnail_height,omitempty"`
4435}
4436
4437// InlineQueryResultVideo is an inline query response video.
4438type InlineQueryResultVideo struct {
4439 // Type of the result, must be video
4440 Type string `json:"type"`
4441 // ID unique identifier for this result, 1-64 bytes
4442 ID string `json:"id"`
4443 // URL a valid url for the embedded video player or video file
4444 URL string `json:"video_url"`
4445 // MimeType of the content of video url, “text/html” or “video/mp4”
4446 MimeType string `json:"mime_type"`
4447 //
4448 // ThumbURL url of the thumbnail (jpeg only) for the video
4449 // optional
4450 ThumbURL string `json:"thumbnail_url,omitempty"`
4451 // Title for the result
4452 Title string `json:"title"`
4453 // Caption of the video to be sent, 0-1024 characters after entities parsing
4454 //
4455 // optional
4456 Caption string `json:"caption,omitempty"`
4457 // CaptionEntities is a list of special entities that appear in the caption,
4458 // which can be specified instead of parse_mode
4459 //
4460 // optional
4461 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4462 // Pass True, if the caption must be shown above the message media
4463 //
4464 // optional
4465 ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
4466 // ParseMode mode for parsing entities in the video caption.
4467 // See formatting options for more details
4468 // (https://core.telegram.org/bots/api#formatting-options).
4469 //
4470 // optional
4471 ParseMode string `json:"parse_mode,omitempty"`
4472 // Width video width
4473 //
4474 // optional
4475 Width int `json:"video_width,omitempty"`
4476 // Height video height
4477 //
4478 // optional
4479 Height int `json:"video_height,omitempty"`
4480 // Duration video duration in seconds
4481 //
4482 // optional
4483 Duration int `json:"video_duration,omitempty"`
4484 // Description short description of the result
4485 //
4486 // optional
4487 Description string `json:"description,omitempty"`
4488 // ReplyMarkup inline keyboard attached to the message
4489 //
4490 // optional
4491 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4492 // InputMessageContent content of the message to be sent instead of the video.
4493 // This field is required if InlineQueryResultVideo is used to send
4494 // an HTML-page as a result (e.g., a YouTube video).
4495 //
4496 // optional
4497 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4498}
4499
4500// InlineQueryResultVoice is an inline query response voice.
4501type InlineQueryResultVoice struct {
4502 // Type of the result, must be voice
4503 Type string `json:"type"`
4504 // ID unique identifier for this result, 1-64 bytes
4505 ID string `json:"id"`
4506 // URL a valid URL for the voice recording
4507 URL string `json:"voice_url"`
4508 // Title recording title
4509 Title string `json:"title"`
4510 // Caption 0-1024 characters after entities parsing
4511 //
4512 // optional
4513 Caption string `json:"caption,omitempty"`
4514 // ParseMode mode for parsing entities in the voice caption.
4515 // See formatting options for more details
4516 // (https://core.telegram.org/bots/api#formatting-options).
4517 //
4518 // optional
4519 ParseMode string `json:"parse_mode,omitempty"`
4520 // CaptionEntities is a list of special entities that appear in the caption,
4521 // which can be specified instead of parse_mode
4522 //
4523 // optional
4524 CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
4525 // Duration recording duration in seconds
4526 //
4527 // optional
4528 Duration int `json:"voice_duration,omitempty"`
4529 // ReplyMarkup inline keyboard attached to the message
4530 //
4531 // optional
4532 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
4533 // InputMessageContent content of the message to be sent instead of the voice recording
4534 //
4535 // optional
4536 InputMessageContent interface{} `json:"input_message_content,omitempty"`
4537}
4538
4539// ChosenInlineResult is an inline query result chosen by a User
4540type ChosenInlineResult struct {
4541 // ResultID the unique identifier for the result that was chosen
4542 ResultID string `json:"result_id"`
4543 // From the user that chose the result
4544 From *User `json:"from"`
4545 // Location sender location, only for bots that require user location
4546 //
4547 // optional
4548 Location *Location `json:"location,omitempty"`
4549 // InlineMessageID identifier of the sent inline message.
4550 // Available only if there is an inline keyboard attached to the message.
4551 // Will be also received in callback queries and can be used to edit the message.
4552 //
4553 // optional
4554 InlineMessageID string `json:"inline_message_id,omitempty"`
4555 // Query the query that was used to obtain the result
4556 Query string `json:"query"`
4557}
4558
4559// SentWebAppMessage contains information about an inline message sent by a Web App
4560// on behalf of a user.
4561type SentWebAppMessage struct {
4562 // Identifier of the sent inline message. Available only if there is an inline
4563 // keyboard attached to the message.
4564 //
4565 // optional
4566 InlineMessageID string `json:"inline_message_id,omitempty"`
4567}
4568
4569// InputTextMessageContent contains text for displaying
4570// as an inline query result.
4571type InputTextMessageContent struct {
4572 // Text of the message to be sent, 1-4096 characters
4573 Text string `json:"message_text"`
4574 // ParseMode mode for parsing entities in the message text.
4575 // See formatting options for more details
4576 // (https://core.telegram.org/bots/api#formatting-options).
4577 //
4578 // optional
4579 ParseMode string `json:"parse_mode,omitempty"`
4580 // Entities is a list of special entities that appear in message text, which
4581 // can be specified instead of parse_mode
4582 //
4583 // optional
4584 Entities []MessageEntity `json:"entities,omitempty"`
4585 // LinkPreviewOptions used for link preview generation for the original message
4586 //
4587 // Optional
4588 LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
4589}
4590
4591// InputLocationMessageContent contains a location for displaying
4592// as an inline query result.
4593type InputLocationMessageContent struct {
4594 // Latitude of the location in degrees
4595 Latitude float64 `json:"latitude"`
4596 // Longitude of the location in degrees
4597 Longitude float64 `json:"longitude"`
4598 // HorizontalAccuracy is the radius of uncertainty for the location,
4599 // measured in meters; 0-1500
4600 //
4601 // optional
4602 HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
4603 // LivePeriod is the period in seconds for which the location can be
4604 // updated, should be between 60 and 86400
4605 //
4606 // optional
4607 LivePeriod int `json:"live_period,omitempty"`
4608 // Heading is for live locations, a direction in which the user is moving,
4609 // in degrees. Must be between 1 and 360 if specified.
4610 //
4611 // optional
4612 Heading int `json:"heading,omitempty"`
4613 // ProximityAlertRadius is for live locations, a maximum distance for
4614 // proximity alerts about approaching another chat member, in meters. Must
4615 // be between 1 and 100000 if specified.
4616 //
4617 // optional
4618 ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
4619}
4620
4621// InputVenueMessageContent contains a venue for displaying
4622// as an inline query result.
4623type InputVenueMessageContent struct {
4624 // Latitude of the venue in degrees
4625 Latitude float64 `json:"latitude"`
4626 // Longitude of the venue in degrees
4627 Longitude float64 `json:"longitude"`
4628 // Title name of the venue
4629 Title string `json:"title"`
4630 // Address of the venue
4631 Address string `json:"address"`
4632 // FoursquareID foursquare identifier of the venue, if known
4633 //
4634 // optional
4635 FoursquareID string `json:"foursquare_id,omitempty"`
4636 // FoursquareType Foursquare type of the venue, if known
4637 //
4638 // optional
4639 FoursquareType string `json:"foursquare_type,omitempty"`
4640 // GooglePlaceID is the Google Places identifier of the venue
4641 //
4642 // optional
4643 GooglePlaceID string `json:"google_place_id,omitempty"`
4644 // GooglePlaceType is the Google Places type of the venue
4645 //
4646 // optional
4647 GooglePlaceType string `json:"google_place_type,omitempty"`
4648}
4649
4650// InputContactMessageContent contains a contact for displaying
4651// as an inline query result.
4652type InputContactMessageContent struct {
4653 // PhoneNumber contact's phone number
4654 PhoneNumber string `json:"phone_number"`
4655 // FirstName contact's first name
4656 FirstName string `json:"first_name"`
4657 // LastName contact's last name
4658 //
4659 // optional
4660 LastName string `json:"last_name,omitempty"`
4661 // Additional data about the contact in the form of a vCard
4662 //
4663 // optional
4664 VCard string `json:"vcard,omitempty"`
4665}
4666
4667// InputInvoiceMessageContent represents the content of an invoice message to be
4668// sent as the result of an inline query.
4669type InputInvoiceMessageContent struct {
4670 // Product name, 1-32 characters
4671 Title string `json:"title"`
4672 // Product description, 1-255 characters
4673 Description string `json:"description"`
4674 // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
4675 // the user, use for your internal processes.
4676 Payload string `json:"payload"`
4677 // Payment provider token, obtained via Botfather. Pass an empty string for payments in Telegram Stars.
4678 //
4679 // optional
4680 ProviderToken string `json:"provider_token"`
4681 // Three-letter ISO 4217 currency code. Pass “XTR” for payments in Telegram Stars.
4682 Currency string `json:"currency"`
4683 // Price breakdown, a JSON-serialized list of components (e.g. product
4684 // price, tax, discount, delivery cost, delivery tax, bonus, etc.)
4685 Prices []LabeledPrice `json:"prices"`
4686 // The maximum accepted amount for tips in the smallest units of the
4687 // currency (integer, not float/double).
4688 //
4689 // optional
4690 MaxTipAmount int `json:"max_tip_amount,omitempty"`
4691 // An array of suggested amounts of tip in the smallest units of the
4692 // currency (integer, not float/double). At most 4 suggested tip amounts can
4693 // be specified. The suggested tip amounts must be positive, passed in a
4694 // strictly increased order and must not exceed max_tip_amount.
4695 //
4696 // optional
4697 SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
4698 // A JSON-serialized object for data about the invoice, which will be shared
4699 // with the payment provider. A detailed description of the required fields
4700 // should be provided by the payment provider.
4701 //
4702 // optional
4703 ProviderData string `json:"provider_data,omitempty"`
4704 // URL of the product photo for the invoice. Can be a photo of the goods or
4705 // a marketing image for a service. People like it better when they see what
4706 // they are paying for.
4707 //
4708 // optional
4709 PhotoURL string `json:"photo_url,omitempty"`
4710 // Photo size
4711 //
4712 // optional
4713 PhotoSize int `json:"photo_size,omitempty"`
4714 // Photo width
4715 //
4716 // optional
4717 PhotoWidth int `json:"photo_width,omitempty"`
4718 // Photo height
4719 //
4720 // optional
4721 PhotoHeight int `json:"photo_height,omitempty"`
4722 // Pass True, if you require the user's full name to complete the order
4723 //
4724 // optional
4725 NeedName bool `json:"need_name,omitempty"`
4726 // Pass True, if you require the user's phone number to complete the order
4727 //
4728 // optional
4729 NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
4730 // Pass True, if you require the user's email address to complete the order
4731 //
4732 // optional
4733 NeedEmail bool `json:"need_email,omitempty"`
4734 // Pass True, if you require the user's shipping address to complete the order
4735 //
4736 // optional
4737 NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
4738 // Pass True, if user's phone number should be sent to provider
4739 //
4740 // optional
4741 SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
4742 // Pass True, if user's email address should be sent to provider
4743 //
4744 // optional
4745 SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
4746 // Pass True, if the final price depends on the shipping method
4747 //
4748 // optional
4749 IsFlexible bool `json:"is_flexible,omitempty"`
4750}
4751
4752// LabeledPrice represents a portion of the price for goods or services.
4753type LabeledPrice struct {
4754 // Label portion label
4755 Label string `json:"label"`
4756 // Amount price of the product in the smallest units of the currency (integer, not float/double).
4757 // For example, for a price of US$ 1.45 pass amount = 145.
4758 // See the exp parameter in currencies.json
4759 // (https://core.telegram.org/bots/payments/currencies.json),
4760 // it shows the number of digits past the decimal point
4761 // for each currency (2 for the majority of currencies).
4762 Amount int `json:"amount"`
4763}
4764
4765// Invoice contains basic information about an invoice.
4766type Invoice struct {
4767 // Title product name
4768 Title string `json:"title"`
4769 // Description product description
4770 Description string `json:"description"`
4771 // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
4772 StartParameter string `json:"start_parameter"`
4773 // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
4774 // (see https://core.telegram.org/bots/payments#supported-currencies)
4775 Currency string `json:"currency"`
4776 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4777 // For example, for a price of US$ 1.45 pass amount = 145.
4778 // See the exp parameter in currencies.json
4779 // (https://core.telegram.org/bots/payments/currencies.json),
4780 // it shows the number of digits past the decimal point
4781 // for each currency (2 for the majority of currencies).
4782 TotalAmount int `json:"total_amount"`
4783}
4784
4785// ShippingAddress represents a shipping address.
4786type ShippingAddress struct {
4787 // CountryCode ISO 3166-1 alpha-2 country code
4788 CountryCode string `json:"country_code"`
4789 // State if applicable
4790 State string `json:"state"`
4791 // City city
4792 City string `json:"city"`
4793 // StreetLine1 first line for the address
4794 StreetLine1 string `json:"street_line1"`
4795 // StreetLine2 second line for the address
4796 StreetLine2 string `json:"street_line2"`
4797 // PostCode address post code
4798 PostCode string `json:"post_code"`
4799}
4800
4801// OrderInfo represents information about an order.
4802type OrderInfo struct {
4803 // Name user name
4804 //
4805 // optional
4806 Name string `json:"name,omitempty"`
4807 // PhoneNumber user's phone number
4808 //
4809 // optional
4810 PhoneNumber string `json:"phone_number,omitempty"`
4811 // Email user email
4812 //
4813 // optional
4814 Email string `json:"email,omitempty"`
4815 // ShippingAddress user shipping address
4816 //
4817 // optional
4818 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
4819}
4820
4821// ShippingOption represents one shipping option.
4822type ShippingOption struct {
4823 // ID shipping option identifier
4824 ID string `json:"id"`
4825 // Title option title
4826 Title string `json:"title"`
4827 // Prices list of price portions
4828 Prices []LabeledPrice `json:"prices"`
4829}
4830
4831// SuccessfulPayment contains basic information about a successful payment.
4832type SuccessfulPayment struct {
4833 // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
4834 // (see https://core.telegram.org/bots/payments#supported-currencies)
4835 Currency string `json:"currency"`
4836 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4837 // For example, for a price of US$ 1.45 pass amount = 145.
4838 // See the exp parameter in currencies.json,
4839 // (https://core.telegram.org/bots/payments/currencies.json)
4840 // it shows the number of digits past the decimal point
4841 // for each currency (2 for the majority of currencies).
4842 TotalAmount int `json:"total_amount"`
4843 // InvoicePayload bot specified invoice payload
4844 InvoicePayload string `json:"invoice_payload"`
4845 // ShippingOptionID identifier of the shipping option chosen by the user
4846 //
4847 // optional
4848 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4849 // OrderInfo order info provided by the user
4850 //
4851 // optional
4852 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4853 // TelegramPaymentChargeID telegram payment identifier
4854 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
4855 // ProviderPaymentChargeID provider payment identifier
4856 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
4857}
4858
4859// ShippingQuery contains information about an incoming shipping query.
4860type ShippingQuery struct {
4861 // ID unique query identifier
4862 ID string `json:"id"`
4863 // From user who sent the query
4864 From *User `json:"from"`
4865 // InvoicePayload bot specified invoice payload
4866 InvoicePayload string `json:"invoice_payload"`
4867 // ShippingAddress user specified shipping address
4868 ShippingAddress *ShippingAddress `json:"shipping_address"`
4869}
4870
4871// PreCheckoutQuery contains information about an incoming pre-checkout query.
4872type PreCheckoutQuery struct {
4873 // ID unique query identifier
4874 ID string `json:"id"`
4875 // From user who sent the query
4876 From *User `json:"from"`
4877 // Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
4878 // // (see https://core.telegram.org/bots/payments#supported-currencies)
4879 Currency string `json:"currency"`
4880 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
4881 // // For example, for a price of US$ 1.45 pass amount = 145.
4882 // // See the exp parameter in currencies.json,
4883 // // (https://core.telegram.org/bots/payments/currencies.json)
4884 // // it shows the number of digits past the decimal point
4885 // // for each currency (2 for the majority of currencies).
4886 TotalAmount int `json:"total_amount"`
4887 // InvoicePayload bot specified invoice payload
4888 InvoicePayload string `json:"invoice_payload"`
4889 // ShippingOptionID identifier of the shipping option chosen by the user
4890 //
4891 // optional
4892 ShippingOptionID string `json:"shipping_option_id,omitempty"`
4893 // OrderInfo order info provided by the user
4894 //
4895 // optional
4896 OrderInfo *OrderInfo `json:"order_info,omitempty"`
4897}
4898
4899// RevenueWithdrawalState describes the state of a revenue withdrawal operation.
4900// Currently, it can be one of
4901// - RevenueWithdrawalStatePending
4902// - RevenueWithdrawalStateSucceeded
4903// - RevenueWithdrawalStateFailed
4904type RevenueWithdrawalState struct {
4905 // Type of the state. Must be one of:
4906 // - pending
4907 // - succeeded
4908 // - failed
4909 Type string `json:"type"`
4910 // Date the withdrawal was completed in Unix time. Represents only in “succeeded” state
4911 Date int64 `json:"date,omitempty"`
4912 // An HTTPS URL that can be used to see transaction details.
4913 // Represents only in “succeeded” state
4914 URL string `json:"url,omitempty"`
4915}
4916
4917// TransactionPartner describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of
4918// - TransactionPartnerFragment
4919// - TransactionPartnerUser
4920// - TransactionPartnerOther
4921type TransactionPartner struct {
4922 //Type of the transaction partner. Must be one of:
4923 // - fragment
4924 // - user
4925 // - other
4926 Type string `json:"type"`
4927 // State of the transaction if the transaction is outgoing.
4928 // Represent only in "fragment" state
4929 //
4930 // optional
4931 WithdrawalState *RevenueWithdrawalState `json:"withdrawal_state,omitempty"`
4932 // Information about the user.
4933 // Represent only in "user" state
4934 User *User `json:"user,omitempty"`
4935}
4936
4937// StarTransaction describes a Telegram Star transaction.
4938type StarTransaction struct {
4939 // Unique identifier of the transaction.
4940 // Coincides with the identifer of the original transaction for refund transactions.
4941 // Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users.
4942 ID string `json:"id"`
4943 // Number of Telegram Stars transferred by the transaction
4944 Amount int64 `json:"amount"`
4945 // Date the transaction was created in Unix time
4946 Date int64 `json:"date"`
4947 // Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal).
4948 // Only for incoming transactions
4949 //
4950 // optional
4951 Source *TransactionPartner `json:"source,omitempty"`
4952 // Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal).
4953 // Only for outgoing transactions
4954 //
4955 // optional
4956 Reciever *TransactionPartner `json:"reciever,omitempty"`
4957}
4958
4959// StarTransactions contains a list of Telegram Star transactions.
4960type StarTransactions struct {
4961 // The list of transactions
4962 Transactions []StarTransaction `json:"transactions"`
4963}