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