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