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