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