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