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