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