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