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