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