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