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"`
17 ErrorCode int `json:"error_code"`
18 Description string `json:"description"`
19 Parameters *ResponseParameters `json:"parameters"`
20}
21
22// ResponseParameters are various errors that can be returned in APIResponse.
23type ResponseParameters struct {
24 MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
25 RetryAfter int `json:"retry_after"` // optional
26}
27
28// Update is an update response, from GetUpdates.
29type Update struct {
30 // UpdateID is the update's unique identifier.
31 // Update identifiers start from a certain positive number and increase sequentially.
32 // This ID becomes especially handy if you're using Webhooks,
33 // since it allows you to ignore repeated updates or to restore
34 // the correct update sequence, should they get out of order.
35 // If there are no new updates for at least a week, then identifier
36 // of the next update will be chosen randomly instead of sequentially.
37 UpdateID int `json:"update_id"`
38 // Message new incoming message of any kind — text, photo, sticker, etc.
39 //
40 // optional
41 Message *Message `json:"message"`
42 // EditedMessage
43 //
44 // optional
45 EditedMessage *Message `json:"edited_message"`
46 // ChannelPost new version of a message that is known to the bot and was edited
47 //
48 // optional
49 ChannelPost *Message `json:"channel_post"`
50 // EditedChannelPost new incoming channel post of any kind — text, photo, sticker, etc.
51 //
52 // optional
53 EditedChannelPost *Message `json:"edited_channel_post"`
54 // InlineQuery new incoming inline query
55 //
56 // optional
57 InlineQuery *InlineQuery `json:"inline_query"`
58 // ChosenInlineResult is the result of an inline query
59 // that was chosen by a user and sent to their chat partner.
60 // Please see our documentation on the feedback collecting
61 // for details on how to enable these updates for your bot.
62 //
63 // optional
64 ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
65 // CallbackQuery new incoming callback query
66 //
67 // optional
68 CallbackQuery *CallbackQuery `json:"callback_query"`
69 // ShippingQuery new incoming shipping query. Only for invoices with flexible price
70 //
71 // optional
72 ShippingQuery *ShippingQuery `json:"shipping_query"`
73 // PreCheckoutQuery new incoming pre-checkout query. Contains full information about checkout
74 //
75 // optional
76 PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
77}
78
79// SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
80// about the user in the update object.
81func (u *Update) SentFrom() *User {
82 switch {
83 case u.Message != nil:
84 return u.Message.From
85 case u.EditedMessage != nil:
86 return u.EditedMessage.From
87 case u.InlineQuery != nil:
88 return u.InlineQuery.From
89 case u.ChosenInlineResult != nil:
90 return u.ChosenInlineResult.From
91 case u.CallbackQuery != nil:
92 return u.CallbackQuery.From
93 case u.ShippingQuery != nil:
94 return u.ShippingQuery.From
95 case u.PreCheckoutQuery != nil:
96 return u.PreCheckoutQuery.From
97 default:
98 return nil
99 }
100}
101
102// CallbackData returns the callback query data, if it exists.
103func (u *Update) CallbackData() string {
104 if u.CallbackQuery != nil {
105 return u.CallbackQuery.Data
106 }
107 return ""
108}
109
110// FromChat returns the chat where an update occured.
111func (u *Update) FromChat() *Chat {
112 switch {
113 case u.Message != nil:
114 return u.Message.Chat
115 case u.EditedMessage != nil:
116 return u.EditedMessage.Chat
117 case u.ChannelPost != nil:
118 return u.ChannelPost.Chat
119 case u.EditedChannelPost != nil:
120 return u.EditedChannelPost.Chat
121 case u.CallbackQuery != nil:
122 return u.CallbackQuery.Message.Chat
123 default:
124 return nil
125 }
126}
127
128// UpdatesChannel is the channel for getting updates.
129type UpdatesChannel <-chan Update
130
131// Clear discards all unprocessed incoming updates.
132func (ch UpdatesChannel) Clear() {
133 for len(ch) != 0 {
134 <-ch
135 }
136}
137
138// User represents a Telegram user or bot.
139type User struct {
140 // ID is a unique identifier for this user or bot
141 ID int `json:"id"`
142 // FirstName user's or bot's first name
143 FirstName string `json:"first_name"`
144 // LastName user's or bot's last name
145 //
146 // optional
147 LastName string `json:"last_name"`
148 // UserName user's or bot's username
149 //
150 // optional
151 UserName string `json:"username"`
152 // LanguageCode IETF language tag of the user's language
153 // more info: https://en.wikipedia.org/wiki/IETF_language_tag
154 //
155 // optional
156 LanguageCode string `json:"language_code"`
157 // IsBot true, if this user is a bot
158 //
159 // optional
160 IsBot bool `json:"is_bot"`
161}
162
163// String displays a simple text version of a user.
164//
165// It is normally a user's username, but falls back to a first/last
166// name as available.
167func (u *User) String() string {
168 if u == nil {
169 return ""
170 }
171 if u.UserName != "" {
172 return u.UserName
173 }
174
175 name := u.FirstName
176 if u.LastName != "" {
177 name += " " + u.LastName
178 }
179
180 return name
181}
182
183// GroupChat is a group chat.
184type GroupChat struct {
185 ID int `json:"id"`
186 Title string `json:"title"`
187}
188
189// ChatPhoto represents a chat photo.
190type ChatPhoto struct {
191 // SmallFileID is a file identifier of small (160x160) chat photo.
192 // This file_id can be used only for photo download and
193 // only for as long as the photo is not changed.
194 SmallFileID string `json:"small_file_id"`
195 // BigFileID is a file identifier of big (640x640) chat photo.
196 // This file_id can be used only for photo download and
197 // only for as long as the photo is not changed.
198 BigFileID string `json:"big_file_id"`
199}
200
201// Chat contains information about the place a message was sent.
202type Chat struct {
203 // ID is a unique identifier for this chat
204 ID int64 `json:"id"`
205 // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
206 Type string `json:"type"`
207 // Title for supergroups, channels and group chats
208 //
209 // optional
210 Title string `json:"title"`
211 // UserName for private chats, supergroups and channels if available
212 //
213 // optional
214 UserName string `json:"username"`
215 // FirstName of the other party in a private chat
216 //
217 // optional
218 FirstName string `json:"first_name"`
219 // LastName of the other party in a private chat
220 //
221 // optional
222 LastName string `json:"last_name"`
223 // AllMembersAreAdmins
224 //
225 // optional
226 AllMembersAreAdmins bool `json:"all_members_are_administrators"`
227 // Photo is a chat photo
228 Photo *ChatPhoto `json:"photo"`
229 // Description for groups, supergroups and channel chats
230 //
231 // optional
232 Description string `json:"description,omitempty"`
233 // InviteLink is a chat invite link, for groups, supergroups and channel chats.
234 // Each administrator in a chat generates their own invite links,
235 // so the bot must first generate the link using exportChatInviteLink
236 //
237 // optional
238 InviteLink string `json:"invite_link,omitempty"`
239 // PinnedMessage Pinned message, for groups, supergroups and channels
240 //
241 // optional
242 PinnedMessage *Message `json:"pinned_message"`
243}
244
245// IsPrivate returns if the Chat is a private conversation.
246func (c Chat) IsPrivate() bool {
247 return c.Type == "private"
248}
249
250// IsGroup returns if the Chat is a group.
251func (c Chat) IsGroup() bool {
252 return c.Type == "group"
253}
254
255// IsSuperGroup returns if the Chat is a supergroup.
256func (c Chat) IsSuperGroup() bool {
257 return c.Type == "supergroup"
258}
259
260// IsChannel returns if the Chat is a channel.
261func (c Chat) IsChannel() bool {
262 return c.Type == "channel"
263}
264
265// ChatConfig returns a ChatConfig struct for chat related methods.
266func (c Chat) ChatConfig() ChatConfig {
267 return ChatConfig{ChatID: c.ID}
268}
269
270// Message is returned by almost every request, and contains data about
271// almost anything.
272type Message struct {
273 // MessageID is a unique message identifier inside this chat
274 MessageID int `json:"message_id"`
275 // From is a sender, empty for messages sent to channels;
276 //
277 // optional
278 From *User `json:"from"`
279 // Date of the message was sent in Unix time
280 Date int `json:"date"`
281 // Chat is the conversation the message belongs to
282 Chat *Chat `json:"chat"`
283 // ForwardFrom for forwarded messages, sender of the original message;
284 //
285 // optional
286 ForwardFrom *User `json:"forward_from"`
287 // ForwardFromChat for messages forwarded from channels,
288 // information about the original channel;
289 //
290 // optional
291 ForwardFromChat *Chat `json:"forward_from_chat"`
292 // ForwardFromMessageID for messages forwarded from channels,
293 // identifier of the original message in the channel;
294 //
295 // optional
296 ForwardFromMessageID int `json:"forward_from_message_id"`
297 // ForwardDate for forwarded messages, date the original message was sent in Unix time;
298 //
299 // optional
300 ForwardDate int `json:"forward_date"`
301 // ReplyToMessage for replies, the original message.
302 // Note that the Message object in this field will not contain further ReplyToMessage fields
303 // even if it itself is a reply;
304 //
305 // optional
306 ReplyToMessage *Message `json:"reply_to_message"`
307 // ViaBot through which the message was sent;
308 //
309 // optional
310 ViaBot *User `json:"via_bot"`
311 // EditDate of the message was last edited in Unix time;
312 //
313 // optional
314 EditDate int `json:"edit_date"`
315 // MediaGroupID is the unique identifier of a media message group this message belongs to;
316 //
317 // optional
318 MediaGroupID string `json:"media_group_id"`
319 // AuthorSignature is the signature of the post author for messages in channels;
320 //
321 // optional
322 AuthorSignature string `json:"author_signature"`
323 // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
324 //
325 // optional
326 Text string `json:"text"`
327 // Entities is for text messages, special entities like usernames,
328 // URLs, bot commands, etc. that appear in the text;
329 //
330 // optional
331 Entities *[]MessageEntity `json:"entities"`
332 // CaptionEntities;
333 //
334 // optional
335 CaptionEntities *[]MessageEntity `json:"caption_entities"`
336 // Audio message is an audio file, information about the file;
337 //
338 // optional
339 Audio *Audio `json:"audio"`
340 // Document message is a general file, information about the file;
341 //
342 // optional
343 Document *Document `json:"document"`
344 // Animation message is an animation, information about the animation.
345 // For backward compatibility, when this field is set, the document field will also be set;
346 //
347 // optional
348 Animation *ChatAnimation `json:"animation"`
349 // Game message is a game, information about the game;
350 //
351 // optional
352 Game *Game `json:"game"`
353 // Photo message is a photo, available sizes of the photo;
354 //
355 // optional
356 Photo *[]PhotoSize `json:"photo"`
357 // Sticker message is a sticker, information about the sticker;
358 //
359 // optional
360 Sticker *Sticker `json:"sticker"`
361 // Video message is a video, information about the video;
362 //
363 // optional
364 Video *Video `json:"video"`
365 // VideoNote message is a video note, information about the video message;
366 //
367 // optional
368 VideoNote *VideoNote `json:"video_note"`
369 // Voice message is a voice message, information about the file;
370 //
371 // optional
372 Voice *Voice `json:"voice"`
373 // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
374 //
375 // optional
376 Caption string `json:"caption"`
377 // Contact message is a shared contact, information about the contact;
378 //
379 // optional
380 Contact *Contact `json:"contact"`
381 // Location message is a shared location, information about the location;
382 //
383 // optional
384 Location *Location `json:"location"`
385 // Venue message is a venue, information about the venue.
386 // For backward compatibility, when this field is set, the location field will also be set;
387 //
388 // optional
389 Venue *Venue `json:"venue"`
390 // NewChatMembers that were added to the group or supergroup
391 // and information about them (the bot itself may be one of these members);
392 //
393 // optional
394 NewChatMembers *[]User `json:"new_chat_members"`
395 // LeftChatMember is a member was removed from the group,
396 // information about them (this member may be the bot itself);
397 //
398 // optional
399 LeftChatMember *User `json:"left_chat_member"`
400 // NewChatTitle is a chat title was changed to this value;
401 //
402 // optional
403 NewChatTitle string `json:"new_chat_title"`
404 // NewChatPhoto is a chat photo was change to this value;
405 //
406 // optional
407 NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
408 // DeleteChatPhoto is a service message: the chat photo was deleted;
409 //
410 // optional
411 DeleteChatPhoto bool `json:"delete_chat_photo"`
412 // GroupChatCreated is a service message: the group has been created;
413 //
414 // optional
415 GroupChatCreated bool `json:"group_chat_created"`
416 // SuperGroupChatCreated is a service message: the supergroup has been created.
417 // This field can't be received in a message coming through updates,
418 // because bot can't be a member of a supergroup when it is created.
419 // It can only be found in ReplyToMessage if someone replies to a very first message
420 // in a directly created supergroup;
421 //
422 // optional
423 SuperGroupChatCreated bool `json:"supergroup_chat_created"`
424 // ChannelChatCreated is a service message: the channel has been created.
425 // This field can't be received in a message coming through updates,
426 // because bot can't be a member of a channel when it is created.
427 // It can only be found in ReplyToMessage
428 // if someone replies to a very first message in a channel;
429 //
430 // optional
431 ChannelChatCreated bool `json:"channel_chat_created"`
432 // MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
433 // This number may be greater than 32 bits and some programming languages
434 // may have difficulty/silent defects in interpreting it.
435 // But it is smaller than 52 bits, so a signed 64 bit integer
436 // or double-precision float type are safe for storing this identifier;
437 //
438 // optional
439 MigrateToChatID int64 `json:"migrate_to_chat_id"`
440 // MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
441 // This number may be greater than 32 bits and some programming languages
442 // may have difficulty/silent defects in interpreting it.
443 // But it is smaller than 52 bits, so a signed 64 bit integer
444 // or double-precision float type are safe for storing this identifier;
445 //
446 // optional
447 MigrateFromChatID int64 `json:"migrate_from_chat_id"`
448 // PinnedMessage is a specified message was pinned.
449 // Note that the Message object in this field will not contain further ReplyToMessage
450 // fields even if it is itself a reply;
451 //
452 // optional
453 PinnedMessage *Message `json:"pinned_message"`
454 // Invoice message is an invoice for a payment;
455 //
456 // optional
457 Invoice *Invoice `json:"invoice"`
458 // SuccessfulPayment message is a service message about a successful payment,
459 // information about the payment;
460 //
461 // optional
462 SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
463 // PassportData is a Telegram Passport data;
464 //
465 // optional
466 PassportData *PassportData `json:"passport_data,omitempty"`
467}
468
469// Time converts the message timestamp into a Time.
470func (m *Message) Time() time.Time {
471 return time.Unix(int64(m.Date), 0)
472}
473
474// IsCommand returns true if message starts with a "bot_command" entity.
475func (m *Message) IsCommand() bool {
476 if m.Entities == nil || len(*m.Entities) == 0 {
477 return false
478 }
479
480 entity := (*m.Entities)[0]
481 return entity.Offset == 0 && entity.IsCommand()
482}
483
484// Command checks if the message was a command and if it was, returns the
485// command. If the Message was not a command, it returns an empty string.
486//
487// If the command contains the at name syntax, it is removed. Use
488// CommandWithAt() if you do not want that.
489func (m *Message) Command() string {
490 command := m.CommandWithAt()
491
492 if i := strings.Index(command, "@"); i != -1 {
493 command = command[:i]
494 }
495
496 return command
497}
498
499// CommandWithAt checks if the message was a command and if it was, returns the
500// command. If the Message was not a command, it returns an empty string.
501//
502// If the command contains the at name syntax, it is not removed. Use Command()
503// if you want that.
504func (m *Message) CommandWithAt() string {
505 if !m.IsCommand() {
506 return ""
507 }
508
509 // IsCommand() checks that the message begins with a bot_command entity
510 entity := (*m.Entities)[0]
511 return m.Text[1:entity.Length]
512}
513
514// CommandArguments checks if the message was a command and if it was,
515// returns all text after the command name. If the Message was not a
516// command, it returns an empty string.
517//
518// Note: The first character after the command name is omitted:
519// - "/foo bar baz" yields "bar baz", not " bar baz"
520// - "/foo-bar baz" yields "bar baz", too
521// Even though the latter is not a command conforming to the spec, the API
522// marks "/foo" as command entity.
523func (m *Message) CommandArguments() string {
524 if !m.IsCommand() {
525 return ""
526 }
527
528 // IsCommand() checks that the message begins with a bot_command entity
529 entity := (*m.Entities)[0]
530 if len(m.Text) == entity.Length {
531 return "" // The command makes up the whole message
532 }
533
534 return m.Text[entity.Length+1:]
535}
536
537// MessageEntity contains information about data in a Message.
538type MessageEntity struct {
539 // Type of the entity.
540 // Can be:
541 // “mention” (@username),
542 // “hashtag” (#hashtag),
543 // “cashtag” ($USD),
544 // “bot_command” (/start@jobs_bot),
545 // “url” (https://telegram.org),
546 // “email” (do-not-reply@telegram.org),
547 // “phone_number” (+1-212-555-0123),
548 // “bold” (bold text),
549 // “italic” (italic text),
550 // “underline” (underlined text),
551 // “strikethrough” (strikethrough text),
552 // “code” (monowidth string),
553 // “pre” (monowidth block),
554 // “text_link” (for clickable text URLs),
555 // “text_mention” (for users without usernames)
556 Type string `json:"type"`
557 // Offset in UTF-16 code units to the start of the entity
558 Offset int `json:"offset"`
559 // Length
560 Length int `json:"length"`
561 // URL for “text_link” only, url that will be opened after user taps on the text
562 //
563 // optional
564 URL string `json:"url"`
565 // User for “text_mention” only, the mentioned user
566 //
567 // optional
568 User *User `json:"user"`
569}
570
571// ParseURL attempts to parse a URL contained within a MessageEntity.
572func (e MessageEntity) ParseURL() (*url.URL, error) {
573 if e.URL == "" {
574 return nil, errors.New(ErrBadURL)
575 }
576
577 return url.Parse(e.URL)
578}
579
580// IsMention returns true if the type of the message entity is "mention" (@username).
581func (e MessageEntity) IsMention() bool {
582 return e.Type == "mention"
583}
584
585// IsHashtag returns true if the type of the message entity is "hashtag".
586func (e MessageEntity) IsHashtag() bool {
587 return e.Type == "hashtag"
588}
589
590// IsCommand returns true if the type of the message entity is "bot_command".
591func (e MessageEntity) IsCommand() bool {
592 return e.Type == "bot_command"
593}
594
595// IsUrl returns true if the type of the message entity is "url".
596func (e MessageEntity) IsUrl() bool {
597 return e.Type == "url"
598}
599
600// IsEmail returns true if the type of the message entity is "email".
601func (e MessageEntity) IsEmail() bool {
602 return e.Type == "email"
603}
604
605// IsBold returns true if the type of the message entity is "bold" (bold text).
606func (e MessageEntity) IsBold() bool {
607 return e.Type == "bold"
608}
609
610// IsItalic returns true if the type of the message entity is "italic" (italic text).
611func (e MessageEntity) IsItalic() bool {
612 return e.Type == "italic"
613}
614
615// IsCode returns true if the type of the message entity is "code" (monowidth string).
616func (e MessageEntity) IsCode() bool {
617 return e.Type == "code"
618}
619
620// IsPre returns true if the type of the message entity is "pre" (monowidth block).
621func (e MessageEntity) IsPre() bool {
622 return e.Type == "pre"
623}
624
625// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
626func (e MessageEntity) IsTextLink() bool {
627 return e.Type == "text_link"
628}
629
630// PhotoSize contains information about photos.
631type PhotoSize struct {
632 // FileID identifier for this file, which can be used to download or reuse the file
633 FileID string `json:"file_id"`
634 // Width photo width
635 Width int `json:"width"`
636 // Height photo height
637 Height int `json:"height"`
638 // FileSize file size
639 //
640 // optional
641 FileSize int `json:"file_size"`
642}
643
644// Audio contains information about audio.
645type Audio struct {
646 // FileID is an identifier for this file, which can be used to download or reuse the file
647 FileID string `json:"file_id"`
648 // Duration of the audio in seconds as defined by sender
649 Duration int `json:"duration"`
650 // Performer of the audio as defined by sender or by audio tags
651 //
652 // optional
653 Performer string `json:"performer"`
654 // Title of the audio as defined by sender or by audio tags
655 //
656 // optional
657 Title string `json:"title"`
658 // MimeType of the file as defined by sender
659 //
660 // optional
661 MimeType string `json:"mime_type"`
662 // FileSize file size
663 //
664 // optional
665 FileSize int `json:"file_size"`
666}
667
668// Document contains information about a document.
669type Document struct {
670 // FileID is a identifier for this file, which can be used to download or reuse the file
671 FileID string `json:"file_id"`
672 // Thumbnail document thumbnail as defined by sender
673 //
674 // optional
675 Thumbnail *PhotoSize `json:"thumb"`
676 // FileName original filename as defined by sender
677 //
678 // optional
679 FileName string `json:"file_name"`
680 // MimeType of the file as defined by sender
681 //
682 // optional
683 MimeType string `json:"mime_type"`
684 // FileSize file size
685 //
686 // optional
687 FileSize int `json:"file_size"`
688}
689
690// Sticker contains information about a sticker.
691type Sticker struct {
692 // FileUniqueID is an unique identifier for this file,
693 // which is supposed to be the same over time and for different bots.
694 // Can't be used to download or reuse the file.
695 FileUniqueID string `json:"file_unique_id"`
696 // FileID is an identifier for this file, which can be used to download or reuse the file
697 FileID string `json:"file_id"`
698 // Width sticker width
699 Width int `json:"width"`
700 // Height sticker height
701 Height int `json:"height"`
702 // Thumbnail sticker thumbnail in the .WEBP or .JPG format
703 //
704 // optional
705 Thumbnail *PhotoSize `json:"thumb"`
706 // Emoji associated with the sticker
707 //
708 // optional
709 Emoji string `json:"emoji"`
710 // FileSize
711 //
712 // optional
713 FileSize int `json:"file_size"`
714 // SetName of the sticker set to which the sticker belongs
715 //
716 // optional
717 SetName string `json:"set_name"`
718 // IsAnimated true, if the sticker is animated
719 //
720 // optional
721 IsAnimated bool `json:"is_animated"`
722}
723
724// StickerSet contains information about an sticker set.
725type StickerSet struct {
726 // Name sticker set name
727 Name string `json:"name"`
728 // Title sticker set title
729 Title string `json:"title"`
730 // IsAnimated true, if the sticker set contains animated stickers
731 IsAnimated bool `json:"is_animated"`
732 // ContainsMasks true, if the sticker set contains masks
733 ContainsMasks bool `json:"contains_masks"`
734 // Stickers list of all set stickers
735 Stickers []Sticker `json:"stickers"`
736}
737
738// ChatAnimation contains information about an animation.
739type ChatAnimation struct {
740 // FileID odentifier for this file, which can be used to download or reuse the file
741 FileID string `json:"file_id"`
742 // Width video width as defined by sender
743 Width int `json:"width"`
744 // Height video height as defined by sender
745 Height int `json:"height"`
746 // Duration of the video in seconds as defined by sender
747 Duration int `json:"duration"`
748 // Thumbnail animation thumbnail as defined by sender
749 //
750 // optional
751 Thumbnail *PhotoSize `json:"thumb"`
752 // FileName original animation filename as defined by sender
753 //
754 // optional
755 FileName string `json:"file_name"`
756 // MimeType of the file as defined by sender
757 //
758 // optional
759 MimeType string `json:"mime_type"`
760 // FileSize file size
761 //
762 // optional
763 FileSize int `json:"file_size"`
764}
765
766// Video contains information about a video.
767type Video struct {
768 // FileID identifier for this file, which can be used to download or reuse the file
769 FileID string `json:"file_id"`
770 // Width video width as defined by sender
771 Width int `json:"width"`
772 // Height video height as defined by sender
773 Height int `json:"height"`
774 // Duration of the video in seconds as defined by sender
775 Duration int `json:"duration"`
776 // Thumbnail video thumbnail
777 //
778 // optional
779 Thumbnail *PhotoSize `json:"thumb"`
780 // MimeType of a file as defined by sender
781 //
782 // optional
783 MimeType string `json:"mime_type"`
784 // FileSize file size
785 //
786 // optional
787 FileSize int `json:"file_size"`
788}
789
790// VideoNote contains information about a video.
791type VideoNote struct {
792 // FileID identifier for this file, which can be used to download or reuse the file
793 FileID string `json:"file_id"`
794 // Length video width and height (diameter of the video message) as defined by sender
795 Length int `json:"length"`
796 // Duration of the video in seconds as defined by sender
797 Duration int `json:"duration"`
798 // Thumbnail video thumbnail
799 //
800 // optional
801 Thumbnail *PhotoSize `json:"thumb"`
802 // FileSize file size
803 //
804 // optional
805 FileSize int `json:"file_size"`
806}
807
808// Voice contains information about a voice.
809type Voice struct {
810 // FileID identifier for this file, which can be used to download or reuse the file
811 FileID string `json:"file_id"`
812 // Duration of the audio in seconds as defined by sender
813 Duration int `json:"duration"`
814 // MimeType of the file as defined by sender
815 //
816 // optional
817 MimeType string `json:"mime_type"`
818 // FileSize file size
819 //
820 // optional
821 FileSize int `json:"file_size"`
822}
823
824// Contact contains information about a contact.
825//
826// Note that LastName and UserID may be empty.
827type Contact struct {
828 // PhoneNumber contact's phone number
829 PhoneNumber string `json:"phone_number"`
830 // FirstName contact's first name
831 FirstName string `json:"first_name"`
832 // LastName contact's last name
833 //
834 // optional
835 LastName string `json:"last_name"`
836 // UserID contact's user identifier in Telegram
837 //
838 // optional
839 UserID int `json:"user_id"`
840}
841
842// Location contains information about a place.
843type Location struct {
844 // Longitude as defined by sender
845 Longitude float64 `json:"longitude"`
846 // Latitude as defined by sender
847 Latitude float64 `json:"latitude"`
848}
849
850// Venue contains information about a venue, including its Location.
851type Venue struct {
852 // Location venue location
853 Location Location `json:"location"`
854 // Title name of the venue
855 Title string `json:"title"`
856 // Address of the venue
857 Address string `json:"address"`
858 // FoursquareID foursquare identifier of the venue
859 //
860 // optional
861 FoursquareID string `json:"foursquare_id"`
862}
863
864// UserProfilePhotos contains a set of user profile photos.
865type UserProfilePhotos struct {
866 // TotalCount total number of profile pictures the target user has
867 TotalCount int `json:"total_count"`
868 // Photos requested profile pictures (in up to 4 sizes each)
869 Photos [][]PhotoSize `json:"photos"`
870}
871
872// File contains information about a file to download from Telegram.
873type File struct {
874 // FileID identifier for this file, which can be used to download or reuse the file
875 FileID string `json:"file_id"`
876 // FileSize file size, if known
877 //
878 // optional
879 FileSize int `json:"file_size"`
880 // FilePath file path
881 //
882 // optional
883 FilePath string `json:"file_path"`
884}
885
886// Link returns a full path to the download URL for a File.
887//
888// It requires the Bot Token to create the link.
889func (f *File) Link(token string) string {
890 return fmt.Sprintf(FileEndpoint, token, f.FilePath)
891}
892
893// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
894type ReplyKeyboardMarkup struct {
895 // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
896 Keyboard [][]KeyboardButton `json:"keyboard"`
897 // ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
898 // (e.g., make the keyboard smaller if there are just two rows of buttons).
899 // Defaults to false, in which case the custom keyboard
900 // is always of the same height as the app's standard keyboard.
901 //
902 // optional
903 ResizeKeyboard bool `json:"resize_keyboard"`
904 // OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
905 // The keyboard will still be available, but clients will automatically display
906 // the usual letter-keyboard in the chat – the user can press a special button
907 // in the input field to see the custom keyboard again.
908 // Defaults to false.
909 //
910 // optional
911 OneTimeKeyboard bool `json:"one_time_keyboard"`
912 // Selective use this parameter if you want to show the keyboard to specific users only.
913 // Targets:
914 // 1) users that are @mentioned in the text of the Message object;
915 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
916 //
917 // Example: A user requests to change the bot's language,
918 // bot replies to the request with a keyboard to select the new language.
919 // Other users in the group don't see the keyboard.
920 //
921 // optional
922 Selective bool `json:"selective"`
923}
924
925// KeyboardButton is a button within a custom keyboard.
926type KeyboardButton struct {
927 // Text of the button. If none of the optional fields are used,
928 // it will be sent as a message when the button is pressed.
929 Text string `json:"text"`
930 // RequestContact if True, the user's phone number will be sent
931 // as a contact when the button is pressed.
932 // Available in private chats only.
933 //
934 // optional
935 RequestContact bool `json:"request_contact"`
936 // RequestLocation if True, the user's current location will be sent when the button is pressed.
937 // Available in private chats only.
938 //
939 // optional
940 RequestLocation bool `json:"request_location"`
941}
942
943// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
944type ReplyKeyboardHide struct {
945 HideKeyboard bool `json:"hide_keyboard"`
946 Selective bool `json:"selective"` // optional
947}
948
949// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
950type ReplyKeyboardRemove struct {
951 // RemoveKeyboard requests clients to remove the custom keyboard
952 // (user will not be able to summon this keyboard;
953 // if you want to hide the keyboard from sight but keep it accessible,
954 // use one_time_keyboard in ReplyKeyboardMarkup).
955 RemoveKeyboard bool `json:"remove_keyboard"`
956 // Selective use this parameter if you want to remove the keyboard for specific users only.
957 // Targets:
958 // 1) users that are @mentioned in the text of the Message object;
959 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
960 //
961 // Example: A user votes in a poll, bot returns confirmation message
962 // in reply to the vote and removes the keyboard for that user,
963 // while still showing the keyboard with poll options to users who haven't voted yet.
964 //
965 // optional
966 Selective bool `json:"selective"`
967}
968
969// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
970type InlineKeyboardMarkup struct {
971 // InlineKeyboard array of button rows, each represented by an Array of InlineKeyboardButton objects
972 InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
973}
974
975// InlineKeyboardButton is a button within a custom keyboard for
976// inline query responses.
977//
978// Note that some values are references as even an empty string
979// will change behavior.
980//
981// CallbackGame, if set, MUST be first button in first row.
982type InlineKeyboardButton struct {
983 // Text label text on the button
984 Text string `json:"text"`
985 // URL HTTP or tg:// url to be opened when button is pressed.
986 //
987 // optional
988 URL *string `json:"url,omitempty"`
989 // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
990 //
991 // optional
992 CallbackData *string `json:"callback_data,omitempty"`
993 // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
994 // open that chat and insert the bot's username and the specified inline query in the input field.
995 // Can be empty, in which case just the bot's username will be inserted.
996 //
997 // This offers an easy way for users to start using your bot
998 // in inline mode when they are currently in a private chat with it.
999 // Especially useful when combined with switch_pm… actions – in this case
1000 // the user will be automatically returned to the chat they switched from,
1001 // skipping the chat selection screen.
1002 //
1003 // optional
1004 SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
1005 // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
1006 // and the specified inline query in the current chat's input field.
1007 // Can be empty, in which case only the bot's username will be inserted.
1008 //
1009 // This offers a quick way for the user to open your bot in inline mode
1010 // in the same chat – good for selecting something from multiple options.
1011 //
1012 // optional
1013 SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
1014 // CallbackGame description of the game that will be launched when the user presses the button.
1015 //
1016 // optional
1017 CallbackGame *CallbackGame `json:"callback_game,omitempty"`
1018 // Pay specify True, to send a Pay button.
1019 //
1020 // NOTE: This type of button must always be the first button in the first row.
1021 //
1022 // optional
1023 Pay bool `json:"pay,omitempty"`
1024}
1025
1026// CallbackQuery is data sent when a keyboard button with callback data
1027// is clicked.
1028type CallbackQuery struct {
1029 // ID unique identifier for this query
1030 ID string `json:"id"`
1031 // From sender
1032 From *User `json:"from"`
1033 // Message with the callback button that originated the query.
1034 // Note that message content and message date will not be available if the message is too old.
1035 //
1036 // optional
1037 Message *Message `json:"message"`
1038 // InlineMessageID identifier of the message sent via the bot in inline mode, that originated the query.
1039 //
1040 // optional
1041 //
1042 InlineMessageID string `json:"inline_message_id"`
1043 // ChatInstance global identifier, uniquely corresponding to the chat to which
1044 // the message with the callback button was sent. Useful for high scores in games.
1045 //
1046 ChatInstance string `json:"chat_instance"`
1047 // Data associated with the callback button. Be aware that
1048 // a bad client can send arbitrary data in this field.
1049 //
1050 // optional
1051 Data string `json:"data"`
1052 // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
1053 //
1054 // optional
1055 GameShortName string `json:"game_short_name"`
1056}
1057
1058// ForceReply allows the Bot to have users directly reply to it without
1059// additional interaction.
1060type ForceReply struct {
1061 // ForceReply shows reply interface to the user,
1062 // as if they manually selected the bot's message and tapped 'Reply'.
1063 ForceReply bool `json:"force_reply"`
1064 // Selective use this parameter if you want to force reply from specific users only.
1065 // Targets:
1066 // 1) users that are @mentioned in the text of the Message object;
1067 // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
1068 //
1069 // optional
1070 Selective bool `json:"selective"`
1071}
1072
1073// ChatMember is information about a member in a chat.
1074type ChatMember struct {
1075 // User information about the user
1076 User *User `json:"user"`
1077 // Status the member's status in the chat.
1078 // Can be
1079 // “creator”,
1080 // “administrator”,
1081 // “member”,
1082 // “restricted”,
1083 // “left” or
1084 // “kicked”
1085 Status string `json:"status"`
1086 // CustomTitle owner and administrators only. Custom title for this user
1087 //
1088 // optional
1089 CustomTitle string `json:"custom_title,omitempty"`
1090 // UntilDate restricted and kicked only.
1091 // Date when restrictions will be lifted for this user;
1092 // unix time.
1093 //
1094 // optional
1095 UntilDate int64 `json:"until_date,omitempty"`
1096 // CanBeEdited administrators only.
1097 // True, if the bot is allowed to edit administrator privileges of that user.
1098 //
1099 // optional
1100 CanBeEdited bool `json:"can_be_edited,omitempty"`
1101 // CanChangeInfo administrators and restricted only.
1102 // True, if the user is allowed to change the chat title, photo and other settings.
1103 //
1104 // optional
1105 CanChangeInfo bool `json:"can_change_info,omitempty"`
1106 // CanChangeInfo administrators only.
1107 // True, if the administrator can post in the channel;
1108 // channels only.
1109 //
1110 // optional
1111 CanPostMessages bool `json:"can_post_messages,omitempty"`
1112 // CanEditMessages administrators only.
1113 // True, if the administrator can edit messages of other users and can pin messages;
1114 // channels only.
1115 //
1116 // optional
1117 CanEditMessages bool `json:"can_edit_messages,omitempty"`
1118 // CanDeleteMessages administrators only.
1119 // True, if the administrator can delete messages of other users.
1120 //
1121 // optional
1122 CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
1123 // CanInviteUsers administrators and restricted only.
1124 // True, if the user is allowed to invite new users to the chat.
1125 //
1126 // optional
1127 CanInviteUsers bool `json:"can_invite_users,omitempty"`
1128 // CanRestrictMembers administrators only.
1129 // True, if the administrator can restrict, ban or unban chat members.
1130 //
1131 // optional
1132 CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
1133 // CanPinMessages
1134 //
1135 // optional
1136 CanPinMessages bool `json:"can_pin_messages,omitempty"`
1137 // CanPromoteMembers administrators only.
1138 // True, if the administrator can add new administrators
1139 // with a subset of their own privileges or demote administrators that he has promoted,
1140 // directly or indirectly (promoted by administrators that were appointed by the user).
1141 //
1142 // optional
1143 CanPromoteMembers bool `json:"can_promote_members,omitempty"`
1144 // CanSendMessages
1145 //
1146 // optional
1147 CanSendMessages bool `json:"can_send_messages,omitempty"`
1148 // CanSendMediaMessages restricted only.
1149 // True, if the user is allowed to send text messages, contacts, locations and venues
1150 //
1151 // optional
1152 CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
1153 // CanSendOtherMessages restricted only.
1154 // True, if the user is allowed to send audios, documents,
1155 // photos, videos, video notes and voice notes.
1156 //
1157 // optional
1158 CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
1159 // CanAddWebPagePreviews restricted only.
1160 // True, if the user is allowed to add web page previews to their messages.
1161 //
1162 // optional
1163 CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
1164}
1165
1166// IsCreator returns if the ChatMember was the creator of the chat.
1167func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
1168
1169// IsAdministrator returns if the ChatMember is a chat administrator.
1170func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
1171
1172// IsMember returns if the ChatMember is a current member of the chat.
1173func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
1174
1175// HasLeft returns if the ChatMember left the chat.
1176func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
1177
1178// WasKicked returns if the ChatMember was kicked from the chat.
1179func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
1180
1181// Game is a game within Telegram.
1182type Game struct {
1183 // Title of the game
1184 Title string `json:"title"`
1185 // Description of the game
1186 Description string `json:"description"`
1187 // Photo that will be displayed in the game message in chats.
1188 Photo []PhotoSize `json:"photo"`
1189 // Text a brief description of the game or high scores included in the game message.
1190 // Can be automatically edited to include current high scores for the game
1191 // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
1192 //
1193 // optional
1194 Text string `json:"text"`
1195 // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
1196 //
1197 // optional
1198 TextEntities []MessageEntity `json:"text_entities"`
1199 // Animation animation that will be displayed in the game message in chats.
1200 // Upload via BotFather (https://t.me/botfather).
1201 //
1202 // optional
1203 Animation Animation `json:"animation"`
1204}
1205
1206// Animation is a GIF animation demonstrating the game.
1207type Animation struct {
1208 // FileID identifier for this file, which can be used to download or reuse the file.
1209 FileID string `json:"file_id"`
1210 // Thumb animation thumbnail as defined by sender.
1211 //
1212 // optional
1213 Thumb PhotoSize `json:"thumb"`
1214 // FileName original animation filename as defined by sender.
1215 //
1216 // optional
1217 FileName string `json:"file_name"`
1218 // MimeType of the file as defined by sender.
1219 //
1220 // optional
1221 MimeType string `json:"mime_type"`
1222 // FileSize ile size
1223 //
1224 // optional
1225 FileSize int `json:"file_size"`
1226}
1227
1228// GameHighScore is a user's score and position on the leaderboard.
1229type GameHighScore struct {
1230 // Position in high score table for the game
1231 Position int `json:"position"`
1232 // User user
1233 User User `json:"user"`
1234 // Score score
1235 Score int `json:"score"`
1236}
1237
1238// CallbackGame is for starting a game in an inline keyboard button.
1239type CallbackGame struct{}
1240
1241// WebhookInfo is information about a currently set webhook.
1242type WebhookInfo struct {
1243 // URL webhook URL, may be empty if webhook is not set up.
1244 URL string `json:"url"`
1245 // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
1246 HasCustomCertificate bool `json:"has_custom_certificate"`
1247 // PendingUpdateCount number of updates awaiting delivery.
1248 PendingUpdateCount int `json:"pending_update_count"`
1249 // LastErrorDate unix time for the most recent error
1250 // that happened when trying to deliver an update via webhook.
1251 //
1252 // optional
1253 LastErrorDate int `json:"last_error_date"`
1254 // LastErrorMessage error message in human-readable format for the most recent error
1255 // that happened when trying to deliver an update via webhook.
1256 //
1257 // optional
1258 LastErrorMessage string `json:"last_error_message"`
1259 // MaxConnections maximum allowed number of simultaneous
1260 // HTTPS connections to the webhook for update delivery.
1261 //
1262 // optional
1263 MaxConnections int `json:"max_connections"`
1264}
1265
1266// IsSet returns true if a webhook is currently set.
1267func (info WebhookInfo) IsSet() bool {
1268 return info.URL != ""
1269}
1270
1271// InputMediaPhoto contains a photo for displaying as part of a media group.
1272type InputMediaPhoto struct {
1273 // Type of the result, must be photo.
1274 Type string `json:"type"`
1275 // Media file to send. Pass a file_id to send a file that
1276 // exists on the Telegram servers (recommended),
1277 // pass an HTTP URL for Telegram to get a file from the Internet,
1278 // or pass “attach://<file_attach_name>” to upload a new one
1279 // using multipart/form-data under <file_attach_name> name.
1280 Media string `json:"media"`
1281 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
1282 //
1283 // optional
1284 Caption string `json:"caption"`
1285 // ParseMode mode for parsing entities in the photo caption.
1286 // See formatting options for more details
1287 // (https://core.telegram.org/bots/api#formatting-options).
1288 //
1289 // optional
1290 ParseMode string `json:"parse_mode"`
1291}
1292
1293// InputMediaVideo contains a video for displaying as part of a media group.
1294type InputMediaVideo struct {
1295 // Type of the result, must be video.
1296 Type string `json:"type"`
1297 // Media file to send. Pass a file_id to send a file
1298 // that exists on the Telegram servers (recommended),
1299 // pass an HTTP URL for Telegram to get a file from the Internet,
1300 // or pass “attach://<file_attach_name>” to upload a new one
1301 // using multipart/form-data under <file_attach_name> name.
1302 Media string `json:"media"`
1303 // thumb intentionally missing as it is not currently compatible
1304
1305 // Caption of the video to be sent, 0-1024 characters after entities parsing.
1306 //
1307 // optional
1308 Caption string `json:"caption"`
1309 // ParseMode mode for parsing entities in the video caption.
1310 // See formatting options for more details
1311 // (https://core.telegram.org/bots/api#formatting-options).
1312 //
1313 // optional
1314 ParseMode string `json:"parse_mode"`
1315 // Width video width
1316 //
1317 // optional
1318 Width int `json:"width"`
1319 // Height video height
1320 //
1321 // optional
1322 Height int `json:"height"`
1323 // Duration video duration
1324 //
1325 // optional
1326 Duration int `json:"duration"`
1327 // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
1328 //
1329 // optional
1330 SupportsStreaming bool `json:"supports_streaming"`
1331}
1332
1333// InlineQuery is a Query from Telegram for an inline request.
1334type InlineQuery struct {
1335 // ID unique identifier for this query
1336 ID string `json:"id"`
1337 // From sender
1338 From *User `json:"from"`
1339 // Location sender location, only for bots that request user location.
1340 //
1341 // optional
1342 Location *Location `json:"location"`
1343 // Query text of the query (up to 256 characters).
1344 Query string `json:"query"`
1345 // Offset of the results to be returned, can be controlled by the bot.
1346 Offset string `json:"offset"`
1347}
1348
1349// InlineQueryResultArticle is an inline query response article.
1350type InlineQueryResultArticle struct {
1351 // Type of the result, must be article.
1352 //
1353 // required
1354 Type string `json:"type"`
1355 // ID unique identifier for this result, 1-64 Bytes.
1356 //
1357 // required
1358 ID string `json:"id"`
1359 // Title of the result
1360 //
1361 // required
1362 Title string `json:"title"`
1363 // InputMessageContent content of the message to be sent.
1364 //
1365 // required
1366 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1367 // ReplyMarkup Inline keyboard attached to the message.
1368 //
1369 // optional
1370 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1371 // URL of the result.
1372 //
1373 // optional
1374 URL string `json:"url"`
1375 // HideURL pass True, if you don't want the URL to be shown in the message.
1376 //
1377 // optional
1378 HideURL bool `json:"hide_url"`
1379 // Description short description of the result.
1380 //
1381 // optional
1382 Description string `json:"description"`
1383 // ThumbURL url of the thumbnail for the result
1384 //
1385 // optional
1386 ThumbURL string `json:"thumb_url"`
1387 // ThumbWidth thumbnail width
1388 //
1389 // optional
1390 ThumbWidth int `json:"thumb_width"`
1391 // ThumbHeight thumbnail height
1392 //
1393 // optional
1394 ThumbHeight int `json:"thumb_height"`
1395}
1396
1397// InlineQueryResultPhoto is an inline query response photo.
1398type InlineQueryResultPhoto struct {
1399 // Type of the result, must be article.
1400 //
1401 // required
1402 Type string `json:"type"`
1403 // ID unique identifier for this result, 1-64 Bytes.
1404 //
1405 // required
1406 ID string `json:"id"`
1407 // URL a valid URL of the photo. Photo must be in jpeg format.
1408 // Photo size must not exceed 5MB.
1409 URL string `json:"photo_url"`
1410 // MimeType
1411 MimeType string `json:"mime_type"`
1412 // Width of the photo
1413 //
1414 // optional
1415 Width int `json:"photo_width"`
1416 // Height of the photo
1417 //
1418 // optional
1419 Height int `json:"photo_height"`
1420 // ThumbURL url of the thumbnail for the photo.
1421 //
1422 // optional
1423 ThumbURL string `json:"thumb_url"`
1424 // Title for the result
1425 //
1426 // optional
1427 Title string `json:"title"`
1428 // Description short description of the result
1429 //
1430 // optional
1431 Description string `json:"description"`
1432 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
1433 //
1434 // optional
1435 Caption string `json:"caption"`
1436 // ParseMode mode for parsing entities in the photo caption.
1437 // See formatting options for more details
1438 // (https://core.telegram.org/bots/api#formatting-options).
1439 //
1440 // optional
1441 ParseMode string `json:"parse_mode"`
1442 // ReplyMarkup inline keyboard attached to the message.
1443 //
1444 // optional
1445 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1446 // InputMessageContent content of the message to be sent instead of the photo.
1447 //
1448 // optional
1449 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1450}
1451
1452// InlineQueryResultCachedPhoto is an inline query response with cached photo.
1453type InlineQueryResultCachedPhoto struct {
1454 // Type of the result, must be photo.
1455 //
1456 // required
1457 Type string `json:"type"`
1458 // ID unique identifier for this result, 1-64 bytes.
1459 //
1460 // required
1461 ID string `json:"id"`
1462 // PhotoID a valid file identifier of the photo.
1463 //
1464 // required
1465 PhotoID string `json:"photo_file_id"`
1466 // Title for the result.
1467 //
1468 // optional
1469 Title string `json:"title"`
1470 // Description short description of the result.
1471 //
1472 // optional
1473 Description string `json:"description"`
1474 // Caption of the photo to be sent, 0-1024 characters after entities parsing.
1475 //
1476 // optional
1477 Caption string `json:"caption"`
1478 // ParseMode mode for parsing entities in the photo caption.
1479 // See formatting options for more details
1480 // (https://core.telegram.org/bots/api#formatting-options).
1481 //
1482 // optional
1483 ParseMode string `json:"parse_mode"`
1484 // ReplyMarkup inline keyboard attached to the message.
1485 //
1486 // optional
1487 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1488 // InputMessageContent content of the message to be sent instead of the photo.
1489 //
1490 // optional
1491 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1492}
1493
1494// InlineQueryResultGIF is an inline query response GIF.
1495type InlineQueryResultGIF struct {
1496 // Type of the result, must be gif.
1497 //
1498 // required
1499 Type string `json:"type"`
1500 // ID unique identifier for this result, 1-64 bytes.
1501 //
1502 // required
1503 ID string `json:"id"`
1504 // URL a valid URL for the GIF file. File size must not exceed 1MB.
1505 //
1506 // required
1507 URL string `json:"gif_url"`
1508 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
1509 //
1510 // required
1511 ThumbURL string `json:"thumb_url"`
1512 // Width of the GIF
1513 //
1514 // optional
1515 Width int `json:"gif_width,omitempty"`
1516 // Height of the GIF
1517 //
1518 // optional
1519 Height int `json:"gif_height,omitempty"`
1520 // Duration of the GIF
1521 //
1522 // optional
1523 Duration int `json:"gif_duration,omitempty"`
1524 // Title for the result
1525 //
1526 // optional
1527 Title string `json:"title,omitempty"`
1528 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
1529 //
1530 // optional
1531 Caption string `json:"caption,omitempty"`
1532 // ReplyMarkup inline keyboard attached to the message
1533 //
1534 // optional
1535 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1536 // InputMessageContent content of the message to be sent instead of the GIF animation.
1537 //
1538 // optional
1539 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1540}
1541
1542// InlineQueryResultCachedGIF is an inline query response with cached gif.
1543type InlineQueryResultCachedGIF struct {
1544 // Type of the result, must be gif.
1545 //
1546 // required
1547 Type string `json:"type"`
1548 // ID unique identifier for this result, 1-64 bytes.
1549 //
1550 // required
1551 ID string `json:"id"`
1552 // GifID a valid file identifier for the GIF file.
1553 //
1554 // required
1555 GifID string `json:"gif_file_id"`
1556 // Title for the result
1557 //
1558 // optional
1559 Title string `json:"title"`
1560 // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
1561 //
1562 // optional
1563 Caption string `json:"caption"`
1564 // ParseMode mode for parsing entities in the caption.
1565 // See formatting options for more details
1566 // (https://core.telegram.org/bots/api#formatting-options).
1567 //
1568 // optional
1569 ParseMode string `json:"parse_mode"`
1570 // ReplyMarkup inline keyboard attached to the message.
1571 //
1572 // optional
1573 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1574 // InputMessageContent content of the message to be sent instead of the GIF animation.
1575 //
1576 // optional
1577 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1578}
1579
1580// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
1581type InlineQueryResultMPEG4GIF struct {
1582 // Type of the result, must be mpeg4_gif
1583 //
1584 // required
1585 Type string `json:"type"`
1586 // ID unique identifier for this result, 1-64 bytes
1587 //
1588 // required
1589 ID string `json:"id"`
1590 // URL a valid URL for the MP4 file. File size must not exceed 1MB
1591 //
1592 // required
1593 URL string `json:"mpeg4_url"`
1594 // Width video width
1595 //
1596 // optional
1597 Width int `json:"mpeg4_width"`
1598 // Height vVideo height
1599 //
1600 // optional
1601 Height int `json:"mpeg4_height"`
1602 // Duration video duration
1603 //
1604 // optional
1605 Duration int `json:"mpeg4_duration"`
1606 // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
1607 ThumbURL string `json:"thumb_url"`
1608 // Title for the result
1609 //
1610 // optional
1611 Title string `json:"title"`
1612 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
1613 //
1614 // optional
1615 Caption string `json:"caption"`
1616 // ReplyMarkup inline keyboard attached to the message
1617 //
1618 // optional
1619 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1620 // InputMessageContent content of the message to be sent instead of the video animation
1621 //
1622 // optional
1623 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1624}
1625
1626// InlineQueryResultCachedMpeg4Gif is an inline query response with cached
1627// H.264/MPEG-4 AVC video without sound gif.
1628type InlineQueryResultCachedMpeg4Gif struct {
1629 // Type of the result, must be mpeg4_gif
1630 //
1631 // required
1632 Type string `json:"type"`
1633 // ID unique identifier for this result, 1-64 bytes
1634 //
1635 // required
1636 ID string `json:"id"`
1637 // MGifID a valid file identifier for the MP4 file
1638 //
1639 // required
1640 MGifID string `json:"mpeg4_file_id"`
1641 // Title for the result
1642 //
1643 // optional
1644 Title string `json:"title"`
1645 // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
1646 //
1647 // optional
1648 Caption string `json:"caption"`
1649 // ParseMode mode for parsing entities in the caption.
1650 // See formatting options for more details
1651 // (https://core.telegram.org/bots/api#formatting-options).
1652 //
1653 // optional
1654 ParseMode string `json:"parse_mode"`
1655 // ReplyMarkup inline keyboard attached to the message.
1656 //
1657 // optional
1658 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1659 // InputMessageContent content of the message to be sent instead of the video animation.
1660 //
1661 // optional
1662 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1663}
1664
1665// InlineQueryResultVideo is an inline query response video.
1666type InlineQueryResultVideo struct {
1667 // Type of the result, must be video
1668 //
1669 // required
1670 Type string `json:"type"`
1671 // ID unique identifier for this result, 1-64 bytes
1672 //
1673 // required
1674 ID string `json:"id"`
1675 // URL a valid url for the embedded video player or video file
1676 //
1677 // required
1678 URL string `json:"video_url"`
1679 // MimeType of the content of video url, “text/html” or “video/mp4”
1680 //
1681 // required
1682 MimeType string `json:"mime_type"`
1683 //
1684 // ThumbURL url of the thumbnail (jpeg only) for the video
1685 // optional
1686 ThumbURL string `json:"thumb_url"`
1687 // Title for the result
1688 //
1689 // required
1690 Title string `json:"title"`
1691 // Caption of the video to be sent, 0-1024 characters after entities parsing
1692 //
1693 // optional
1694 Caption string `json:"caption"`
1695 // Width video width
1696 //
1697 // optional
1698 Width int `json:"video_width"`
1699 // Height video height
1700 //
1701 // optional
1702 Height int `json:"video_height"`
1703 // Duration video duration in seconds
1704 //
1705 // optional
1706 Duration int `json:"video_duration"`
1707 // Description short description of the result
1708 //
1709 // optional
1710 Description string `json:"description"`
1711 // ReplyMarkup inline keyboard attached to the message
1712 //
1713 // optional
1714 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1715 // InputMessageContent content of the message to be sent instead of the video.
1716 // This field is required if InlineQueryResultVideo is used to send
1717 // an HTML-page as a result (e.g., a YouTube video).
1718 //
1719 // optional
1720 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1721}
1722
1723// InlineQueryResultCachedVideo is an inline query response with cached video.
1724type InlineQueryResultCachedVideo struct {
1725 // Type of the result, must be video
1726 //
1727 // required
1728 Type string `json:"type"`
1729 // ID unique identifier for this result, 1-64 bytes
1730 //
1731 // required
1732 ID string `json:"id"`
1733 // VideoID a valid file identifier for the video file
1734 //
1735 // required
1736 VideoID string `json:"video_file_id"`
1737 // Title for the result
1738 //
1739 // required
1740 Title string `json:"title"`
1741 // Description short description of the result
1742 //
1743 // optional
1744 Description string `json:"description"`
1745 // Caption of the video to be sent, 0-1024 characters after entities parsing
1746 //
1747 // optional
1748 Caption string `json:"caption"`
1749 // ParseMode mode for parsing entities in the video caption.
1750 // See formatting options for more details
1751 // (https://core.telegram.org/bots/api#formatting-options).
1752 //
1753 // optional
1754 ParseMode string `json:"parse_mode"`
1755 // ReplyMarkup inline keyboard attached to the message
1756 //
1757 // optional
1758 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1759 // InputMessageContent content of the message to be sent instead of the video
1760 //
1761 // optional
1762 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1763}
1764
1765// InlineQueryResultCachedSticker is an inline query response with cached sticker.
1766type InlineQueryResultCachedSticker struct {
1767 // Type of the result, must be sticker
1768 //
1769 // required
1770 Type string `json:"type"`
1771 // ID unique identifier for this result, 1-64 bytes
1772 //
1773 // required
1774 ID string `json:"id"`
1775 // StickerID a valid file identifier of the sticker
1776 //
1777 // required
1778 StickerID string `json:"sticker_file_id"`
1779 // Title is a title
1780 Title string `json:"title"`
1781 // ParseMode mode for parsing entities in the video caption.
1782 // See formatting options for more details
1783 // (https://core.telegram.org/bots/api#formatting-options).
1784 //
1785 // optional
1786 ParseMode string `json:"parse_mode"`
1787 // ReplyMarkup inline keyboard attached to the message
1788 //
1789 // optional
1790 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1791 // InputMessageContent content of the message to be sent instead of the sticker
1792 //
1793 // optional
1794 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1795}
1796
1797// InlineQueryResultAudio is an inline query response audio.
1798type InlineQueryResultAudio struct {
1799 // Type of the result, must be audio
1800 //
1801 // required
1802 Type string `json:"type"`
1803 // ID unique identifier for this result, 1-64 bytes
1804 //
1805 // required
1806 ID string `json:"id"`
1807 // URL a valid url for the audio file
1808 //
1809 // required
1810 URL string `json:"audio_url"`
1811 // Title is a title
1812 //
1813 // required
1814 Title string `json:"title"`
1815 // Caption 0-1024 characters after entities parsing
1816 //
1817 // optional
1818 Caption string `json:"caption"`
1819 // Performer is a performer
1820 //
1821 // optional
1822 Performer string `json:"performer"`
1823 // Duration audio duration in seconds
1824 //
1825 // optional
1826 Duration int `json:"audio_duration"`
1827 // ReplyMarkup inline keyboard attached to the message
1828 //
1829 // optional
1830 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1831 // InputMessageContent content of the message to be sent instead of the audio
1832 //
1833 // optional
1834 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1835}
1836
1837// InlineQueryResultCachedAudio is an inline query response with cached audio.
1838type InlineQueryResultCachedAudio struct {
1839 // Type of the result, must be audio
1840 //
1841 // required
1842 Type string `json:"type"`
1843 // ID unique identifier for this result, 1-64 bytes
1844 //
1845 // required
1846 ID string `json:"id"`
1847 // AudioID a valid file identifier for the audio file
1848 //
1849 // required
1850 AudioID string `json:"audio_file_id"`
1851 // Caption 0-1024 characters after entities parsing
1852 //
1853 // optional
1854 Caption string `json:"caption"`
1855 // ParseMode mode for parsing entities in the video caption.
1856 // See formatting options for more details
1857 // (https://core.telegram.org/bots/api#formatting-options).
1858 //
1859 // optional
1860 ParseMode string `json:"parse_mode"`
1861 // ReplyMarkup inline keyboard attached to the message
1862 //
1863 // optional
1864 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1865 // InputMessageContent content of the message to be sent instead of the audio
1866 //
1867 // optional
1868 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1869}
1870
1871// InlineQueryResultVoice is an inline query response voice.
1872type InlineQueryResultVoice struct {
1873 // Type of the result, must be voice
1874 //
1875 // required
1876 Type string `json:"type"`
1877 // ID unique identifier for this result, 1-64 bytes
1878 //
1879 // required
1880 ID string `json:"id"`
1881 // URL a valid URL for the voice recording
1882 //
1883 // required
1884 URL string `json:"voice_url"`
1885 // Title recording title
1886 //
1887 // required
1888 Title string `json:"title"`
1889 // Caption 0-1024 characters after entities parsing
1890 //
1891 // optional
1892 Caption string `json:"caption"`
1893 // Duration recording duration in seconds
1894 //
1895 // optional
1896 Duration int `json:"voice_duration"`
1897 // ReplyMarkup inline keyboard attached to the message
1898 //
1899 // optional
1900 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1901 // InputMessageContent content of the message to be sent instead of the voice recording
1902 //
1903 // optional
1904 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1905}
1906
1907// InlineQueryResultCachedVoice is an inline query response with cached voice.
1908type InlineQueryResultCachedVoice struct {
1909 // Type of the result, must be voice
1910 //
1911 // required
1912 Type string `json:"type"`
1913 // ID unique identifier for this result, 1-64 bytes
1914 //
1915 // required
1916 ID string `json:"id"`
1917 // VoiceID a valid file identifier for the voice message
1918 //
1919 // required
1920 VoiceID string `json:"voice_file_id"`
1921 // Title voice message title
1922 //
1923 // required
1924 Title string `json:"title"`
1925 // Caption 0-1024 characters after entities parsing
1926 //
1927 // optional
1928 Caption string `json:"caption"`
1929 // ParseMode mode for parsing entities in the video caption.
1930 // See formatting options for more details
1931 // (https://core.telegram.org/bots/api#formatting-options).
1932 //
1933 // optional
1934 ParseMode string `json:"parse_mode"`
1935 // ReplyMarkup inline keyboard attached to the message
1936 //
1937 // optional
1938 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1939 // InputMessageContent content of the message to be sent instead of the voice message
1940 //
1941 // optional
1942 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1943}
1944
1945// InlineQueryResultDocument is an inline query response document.
1946type InlineQueryResultDocument struct {
1947 // Type of the result, must be document
1948 //
1949 // required
1950 Type string `json:"type"`
1951 // ID unique identifier for this result, 1-64 bytes
1952 //
1953 // required
1954 ID string `json:"id"`
1955 // Title for the result
1956 //
1957 // required
1958 Title string `json:"title"`
1959 // Caption of the document to be sent, 0-1024 characters after entities parsing
1960 //
1961 // optional
1962 Caption string `json:"caption"`
1963 // URL a valid url for the file
1964 //
1965 // required
1966 URL string `json:"document_url"`
1967 // MimeType of the content of the file, either “application/pdf” or “application/zip”
1968 //
1969 // required
1970 MimeType string `json:"mime_type"`
1971 // Description short description of the result
1972 //
1973 // optional
1974 Description string `json:"description"`
1975 // ReplyMarkup nline keyboard attached to the message
1976 //
1977 // optional
1978 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
1979 // InputMessageContent content of the message to be sent instead of the file
1980 //
1981 // optional
1982 InputMessageContent interface{} `json:"input_message_content,omitempty"`
1983 // ThumbURL url of the thumbnail (jpeg only) for the file
1984 //
1985 // optional
1986 ThumbURL string `json:"thumb_url"`
1987 // ThumbWidth thumbnail width
1988 //
1989 // optional
1990 ThumbWidth int `json:"thumb_width"`
1991 // ThumbHeight thumbnail height
1992 //
1993 // optional
1994 ThumbHeight int `json:"thumb_height"`
1995}
1996
1997// InlineQueryResultCachedDocument is an inline query response with cached document.
1998type InlineQueryResultCachedDocument struct {
1999 // Type of the result, must be document
2000 //
2001 // required
2002 Type string `json:"type"`
2003 // ID unique identifier for this result, 1-64 bytes
2004 //
2005 // required
2006 ID string `json:"id"`
2007 // DocumentID a valid file identifier for the file
2008 //
2009 // required
2010 DocumentID string `json:"document_file_id"`
2011 // Title for the result
2012 //
2013 // optional
2014 Title string `json:"title"` // required
2015 // Caption of the document to be sent, 0-1024 characters after entities parsing
2016 //
2017 // optional
2018 Caption string `json:"caption"`
2019 // Description short description of the result
2020 //
2021 // optional
2022 Description string `json:"description"`
2023 // ParseMode mode for parsing entities in the video caption.
2024 // // See formatting options for more details
2025 // // (https://core.telegram.org/bots/api#formatting-options).
2026 //
2027 // optional
2028 ParseMode string `json:"parse_mode"`
2029 // ReplyMarkup inline keyboard attached to the message
2030 //
2031 // optional
2032 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2033 // InputMessageContent content of the message to be sent instead of the file
2034 //
2035 // optional
2036 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2037}
2038
2039// InlineQueryResultLocation is an inline query response location.
2040type InlineQueryResultLocation struct {
2041 // Type of the result, must be location
2042 //
2043 // required
2044 Type string `json:"type"`
2045 // ID unique identifier for this result, 1-64 Bytes
2046 //
2047 // required
2048 ID string `json:"id"`
2049 // Latitude of the location in degrees
2050 //
2051 // required
2052 Latitude float64 `json:"latitude"`
2053 // Longitude of the location in degrees
2054 //
2055 // required
2056 Longitude float64 `json:"longitude"`
2057 // Title of the location
2058 //
2059 // required
2060 Title string `json:"title"`
2061 // ReplyMarkup inline keyboard attached to the message
2062 //
2063 // optional
2064 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2065 // InputMessageContent content of the message to be sent instead of the location
2066 //
2067 // optional
2068 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2069 // ThumbURL url of the thumbnail for the result
2070 //
2071 // optional
2072 ThumbURL string `json:"thumb_url"`
2073 // ThumbWidth thumbnail width
2074 //
2075 // optional
2076 ThumbWidth int `json:"thumb_width"`
2077 // ThumbHeight thumbnail height
2078 //
2079 // optional
2080 ThumbHeight int `json:"thumb_height"`
2081}
2082
2083// InlineQueryResultVenue is an inline query response venue.
2084type InlineQueryResultVenue struct {
2085 // Type of the result, must be venue
2086 //
2087 // required
2088 Type string `json:"type"`
2089 // ID unique identifier for this result, 1-64 Bytes
2090 //
2091 // required
2092 ID string `json:"id"`
2093 // Latitude of the venue location in degrees
2094 //
2095 // required
2096 Latitude float64 `json:"latitude"`
2097 // Longitude of the venue location in degrees
2098 //
2099 // required
2100 Longitude float64 `json:"longitude"`
2101 // Title of the venue
2102 //
2103 // required
2104 Title string `json:"title"`
2105 // Address of the venue
2106 //
2107 // required
2108 Address string `json:"address"`
2109 // FoursquareID foursquare identifier of the venue if known
2110 //
2111 // optional
2112 FoursquareID string `json:"foursquare_id"`
2113 // FoursquareType foursquare type of the venue, if known.
2114 // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
2115 //
2116 // optional
2117 FoursquareType string `json:"foursquare_type"`
2118 // ReplyMarkup inline keyboard attached to the message
2119 //
2120 // optional
2121 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2122 // InputMessageContent content of the message to be sent instead of the venue
2123 //
2124 // optional
2125 InputMessageContent interface{} `json:"input_message_content,omitempty"`
2126 // ThumbURL url of the thumbnail for the result
2127 //
2128 // optional
2129 ThumbURL string `json:"thumb_url"`
2130 // ThumbWidth thumbnail width
2131 //
2132 // optional
2133 ThumbWidth int `json:"thumb_width"`
2134 // ThumbHeight thumbnail height
2135 //
2136 // optional
2137 ThumbHeight int `json:"thumb_height"`
2138}
2139
2140// InlineQueryResultGame is an inline query response game.
2141type InlineQueryResultGame struct {
2142 // Type of the result, must be game
2143 //
2144 // required
2145 Type string `json:"type"`
2146 // ID unique identifier for this result, 1-64 bytes
2147 //
2148 // required
2149 ID string `json:"id"`
2150 // GameShortName short name of the game
2151 //
2152 // required
2153 GameShortName string `json:"game_short_name"`
2154 // ReplyMarkup inline keyboard attached to the message
2155 //
2156 // optional
2157 ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
2158}
2159
2160// ChosenInlineResult is an inline query result chosen by a User
2161type ChosenInlineResult struct {
2162 // ResultID the unique identifier for the result that was chosen
2163 ResultID string `json:"result_id"`
2164 // From the user that chose the result
2165 From *User `json:"from"`
2166 // Location sender location, only for bots that require user location
2167 //
2168 // optional
2169 Location *Location `json:"location"`
2170 // InlineMessageID identifier of the sent inline message.
2171 // Available only if there is an inline keyboard attached to the message.
2172 // Will be also received in callback queries and can be used to edit the message.
2173 //
2174 // optional
2175 InlineMessageID string `json:"inline_message_id"`
2176 // Query the query that was used to obtain the result
2177 Query string `json:"query"`
2178}
2179
2180// InputTextMessageContent contains text for displaying
2181// as an inline query result.
2182type InputTextMessageContent struct {
2183 // Text of the message to be sent, 1-4096 characters
2184 Text string `json:"message_text"`
2185 // ParseMode mode for parsing entities in the message text.
2186 // See formatting options for more details
2187 // (https://core.telegram.org/bots/api#formatting-options).
2188 //
2189 // optional
2190 ParseMode string `json:"parse_mode"`
2191 // DisableWebPagePreview disables link previews for links in the sent message
2192 //
2193 // optional
2194 DisableWebPagePreview bool `json:"disable_web_page_preview"`
2195}
2196
2197// InputLocationMessageContent contains a location for displaying
2198// as an inline query result.
2199type InputLocationMessageContent struct {
2200 // Latitude of the location in degrees
2201 Latitude float64 `json:"latitude"`
2202 // Longitude of the location in degrees
2203 Longitude float64 `json:"longitude"`
2204}
2205
2206// InputVenueMessageContent contains a venue for displaying
2207// as an inline query result.
2208type InputVenueMessageContent struct {
2209 // Latitude of the venue in degrees
2210 Latitude float64 `json:"latitude"`
2211 // Longitude of the venue in degrees
2212 Longitude float64 `json:"longitude"`
2213 // Title name of the venue
2214 Title string `json:"title"`
2215 // Address of the venue
2216 Address string `json:"address"`
2217 // FoursquareID foursquare identifier of the venue, if known
2218 //
2219 // optional
2220 FoursquareID string `json:"foursquare_id"`
2221}
2222
2223// InputContactMessageContent contains a contact for displaying
2224// as an inline query result.
2225type InputContactMessageContent struct {
2226 // PhoneNumber contact's phone number
2227 PhoneNumber string `json:"phone_number"`
2228 // FirstName contact's first name
2229 FirstName string `json:"first_name"`
2230 // LastName contact's last name
2231 //
2232 // optional
2233 LastName string `json:"last_name"`
2234}
2235
2236// Invoice contains basic information about an invoice.
2237type Invoice struct {
2238 // Title product name
2239 Title string `json:"title"`
2240 // Description product description
2241 Description string `json:"description"`
2242 // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
2243 StartParameter string `json:"start_parameter"`
2244 // Currency three-letter ISO 4217 currency code
2245 // (see https://core.telegram.org/bots/payments#supported-currencies)
2246 Currency string `json:"currency"`
2247 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
2248 // For example, for a price of US$ 1.45 pass amount = 145.
2249 // See the exp parameter in currencies.json
2250 // (https://core.telegram.org/bots/payments/currencies.json),
2251 // it shows the number of digits past the decimal point
2252 // for each currency (2 for the majority of currencies).
2253 TotalAmount int `json:"total_amount"`
2254}
2255
2256// LabeledPrice represents a portion of the price for goods or services.
2257type LabeledPrice struct {
2258 // Label portion label
2259 Label string `json:"label"`
2260 // Amount price of the product in the smallest units of the currency (integer, not float/double).
2261 // For example, for a price of US$ 1.45 pass amount = 145.
2262 // See the exp parameter in currencies.json
2263 // (https://core.telegram.org/bots/payments/currencies.json),
2264 // it shows the number of digits past the decimal point
2265 // for each currency (2 for the majority of currencies).
2266 Amount int `json:"amount"`
2267}
2268
2269// ShippingAddress represents a shipping address.
2270type ShippingAddress struct {
2271 // CountryCode ISO 3166-1 alpha-2 country code
2272 CountryCode string `json:"country_code"`
2273 // State if applicable
2274 State string `json:"state"`
2275 // City city
2276 City string `json:"city"`
2277 // StreetLine1 first line for the address
2278 StreetLine1 string `json:"street_line1"`
2279 // StreetLine2 second line for the address
2280 StreetLine2 string `json:"street_line2"`
2281 // PostCode address post code
2282 PostCode string `json:"post_code"`
2283}
2284
2285// OrderInfo represents information about an order.
2286type OrderInfo struct {
2287 // Name user name
2288 //
2289 // optional
2290 Name string `json:"name,omitempty"`
2291 // PhoneNumber user's phone number
2292 //
2293 // optional
2294 PhoneNumber string `json:"phone_number,omitempty"`
2295 // Email user email
2296 //
2297 // optional
2298 Email string `json:"email,omitempty"`
2299 // ShippingAddress user shipping address
2300 //
2301 // optional
2302 ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
2303}
2304
2305// ShippingOption represents one shipping option.
2306type ShippingOption struct {
2307 // ID shipping option identifier
2308 ID string `json:"id"`
2309 // Title option title
2310 Title string `json:"title"`
2311 // Prices list of price portions
2312 Prices *[]LabeledPrice `json:"prices"`
2313}
2314
2315// SuccessfulPayment contains basic information about a successful payment.
2316type SuccessfulPayment struct {
2317 // Currency three-letter ISO 4217 currency code
2318 // (see https://core.telegram.org/bots/payments#supported-currencies)
2319 Currency string `json:"currency"`
2320 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
2321 // For example, for a price of US$ 1.45 pass amount = 145.
2322 // See the exp parameter in currencies.json,
2323 // (https://core.telegram.org/bots/payments/currencies.json)
2324 // it shows the number of digits past the decimal point
2325 // for each currency (2 for the majority of currencies).
2326 TotalAmount int `json:"total_amount"`
2327 // InvoicePayload bot specified invoice payload
2328 InvoicePayload string `json:"invoice_payload"`
2329 // ShippingOptionID identifier of the shipping option chosen by the user
2330 //
2331 // optional
2332 ShippingOptionID string `json:"shipping_option_id,omitempty"`
2333 // OrderInfo order info provided by the user
2334 //
2335 // optional
2336 OrderInfo *OrderInfo `json:"order_info,omitempty"`
2337 // TelegramPaymentChargeID telegram payment identifier
2338 TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
2339 // ProviderPaymentChargeID provider payment identifier
2340 ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
2341}
2342
2343// ShippingQuery contains information about an incoming shipping query.
2344type ShippingQuery struct {
2345 // ID unique query identifier
2346 ID string `json:"id"`
2347 // From user who sent the query
2348 From *User `json:"from"`
2349 // InvoicePayload bot specified invoice payload
2350 InvoicePayload string `json:"invoice_payload"`
2351 // ShippingAddress user specified shipping address
2352 ShippingAddress *ShippingAddress `json:"shipping_address"`
2353}
2354
2355// PreCheckoutQuery contains information about an incoming pre-checkout query.
2356type PreCheckoutQuery struct {
2357 // ID unique query identifier
2358 ID string `json:"id"`
2359 // From user who sent the query
2360 From *User `json:"from"`
2361 // Currency three-letter ISO 4217 currency code
2362 // // (see https://core.telegram.org/bots/payments#supported-currencies)
2363 Currency string `json:"currency"`
2364 // TotalAmount total price in the smallest units of the currency (integer, not float/double).
2365 // // For example, for a price of US$ 1.45 pass amount = 145.
2366 // // See the exp parameter in currencies.json,
2367 // // (https://core.telegram.org/bots/payments/currencies.json)
2368 // // it shows the number of digits past the decimal point
2369 // // for each currency (2 for the majority of currencies).
2370 TotalAmount int `json:"total_amount"`
2371 // InvoicePayload bot specified invoice payload
2372 InvoicePayload string `json:"invoice_payload"`
2373 // ShippingOptionID identifier of the shipping option chosen by the user
2374 //
2375 // optional
2376 ShippingOptionID string `json:"shipping_option_id,omitempty"`
2377 // OrderInfo order info provided by the user
2378 //
2379 // optional
2380 OrderInfo *OrderInfo `json:"order_info,omitempty"`
2381}
2382
2383// Error is an error containing extra information returned by the Telegram API.
2384type Error struct {
2385 Code int
2386 Message string
2387 ResponseParameters
2388}
2389
2390func (e Error) Error() string {
2391 return e.Message
2392}
2393
2394// BotCommand represents a bot command.
2395type BotCommand struct {
2396 // Command text of the command, 1-32 characters.
2397 // Can contain only lowercase English letters, digits and underscores.
2398 Command string `json:"command"`
2399 // Description of the command, 3-256 characters.
2400 Description string `json:"description"`
2401}