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