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