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