telegram-bot-api/types.go

2400 lines
74 KiB
Go
Raw Normal View History

package tgbotapi
import (
"encoding/json"
2016-04-14 00:06:18 +02:00
"errors"
"fmt"
2016-04-12 15:28:46 +02:00
"net/url"
2015-11-21 15:26:28 +01:00
"strings"
2015-11-21 15:39:19 +01:00
"time"
)
// APIResponse is a response from the Telegram API with the result
// stored raw.
type APIResponse struct {
Ok bool `json:"ok"`
Result json.RawMessage `json:"result"`
ErrorCode int `json:"error_code"`
Description string `json:"description"`
Parameters *ResponseParameters `json:"parameters"`
}
// ResponseParameters are various errors that can be returned in APIResponse.
type ResponseParameters struct {
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
RetryAfter int `json:"retry_after"` // optional
}
// Update is an update response, from GetUpdates.
type Update struct {
2020-10-24 12:50:11 +02:00
// UpdateID is the update's unique identifier.
// Update identifiers start from a certain positive number and increase sequentially.
// This ID becomes especially handy if you're using Webhooks,
// since it allows you to ignore repeated updates or to restore
// the correct update sequence, should they get out of order.
// If there are no new updates for at least a week, then identifier
// of the next update will be chosen randomly instead of sequentially.
UpdateID int `json:"update_id"`
// Message new incoming message of any kind — text, photo, sticker, etc.
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
Message *Message `json:"message"`
// EditedMessage
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
EditedMessage *Message `json:"edited_message"`
// ChannelPost new version of a message that is known to the bot and was edited
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
ChannelPost *Message `json:"channel_post"`
// EditedChannelPost new incoming channel post of any kind — text, photo, sticker, etc.
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
EditedChannelPost *Message `json:"edited_channel_post"`
// InlineQuery new incoming inline query
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
InlineQuery *InlineQuery `json:"inline_query"`
// ChosenInlineResult is the result of an inline query
// that was chosen by a user and sent to their chat partner.
// Please see our documentation on the feedback collecting
// for details on how to enable these updates for your bot.
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
2020-10-24 12:50:11 +02:00
// CallbackQuery new incoming callback query
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
CallbackQuery *CallbackQuery `json:"callback_query"`
// ShippingQuery new incoming shipping query. Only for invoices with flexible price
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
ShippingQuery *ShippingQuery `json:"shipping_query"`
// PreCheckoutQuery new incoming pre-checkout query. Contains full information about checkout
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:50:11 +02:00
// optional
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
}
2021-02-02 12:56:51 +01:00
// SentFrom return user sender of update. Can be nil, if telegram wont provide info about him in
// update object.
func (u *Update) SentFrom() *User {
switch {
case u.Message != nil:
return u.Message.From
case u.EditedMessage != nil:
return u.EditedMessage.From
case u.InlineQuery != nil:
return u.InlineQuery.From
case u.ChosenInlineResult != nil:
return u.ChosenInlineResult.From
case u.CallbackQuery != nil:
return u.CallbackQuery.From
case u.ShippingQuery != nil:
return u.ShippingQuery.From
case u.PreCheckoutQuery != nil:
return u.PreCheckoutQuery.From
default:
return nil
}
}
2021-02-02 13:38:41 +01:00
func (u *Update) CallbackData() string {
if u.CallbackQuery != nil {
return u.CallbackQuery.Data
}
return ""
}
func (u *Update) FromChat() *Chat {
switch {
case u.Message != nil:
return u.Message.Chat
case u.EditedMessage != nil:
return u.EditedMessage.Chat
case u.ChannelPost != nil:
return u.ChannelPost.Chat
case u.EditedChannelPost != nil:
return u.EditedChannelPost.Chat
case u.CallbackQuery != nil:
return u.CallbackQuery.Message.Chat
default:
return nil
}
}
// UpdatesChannel is the channel for getting updates.
type UpdatesChannel <-chan Update
// Clear discards all unprocessed incoming updates.
func (ch UpdatesChannel) Clear() {
for len(ch) != 0 {
<-ch
}
}
2020-10-24 12:34:34 +02:00
// User represents a Telegram user or bot.
type User struct {
2020-10-24 12:34:34 +02:00
// ID is a unique identifier for this user or bot
ID int `json:"id"`
// FirstName user's or bot's first name
FirstName string `json:"first_name"`
// LastName user's or bot's last name
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:34:34 +02:00
// optional
LastName string `json:"last_name"`
// UserName user's or bot's username
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:34:34 +02:00
// optional
UserName string `json:"username"`
// LanguageCode IETF language tag of the user's language
// more info: https://en.wikipedia.org/wiki/IETF_language_tag
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:34:34 +02:00
// optional
LanguageCode string `json:"language_code"`
// IsBot true, if this user is a bot
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:34:34 +02:00
// optional
IsBot bool `json:"is_bot"`
}
2015-07-31 09:22:01 +02:00
// String displays a simple text version of a user.
//
// It is normally a user's username, but falls back to a first/last
// name as available.
2015-07-31 09:22:01 +02:00
func (u *User) String() string {
2020-05-22 10:42:19 +02:00
if u == nil {
return ""
}
2015-07-31 09:22:01 +02:00
if u.UserName != "" {
return u.UserName
}
name := u.FirstName
if u.LastName != "" {
name += " " + u.LastName
}
return name
}
// GroupChat is a group chat.
type GroupChat struct {
ID int `json:"id"`
Title string `json:"title"`
}
2017-06-30 15:29:59 +02:00
// ChatPhoto represents a chat photo.
type ChatPhoto struct {
2020-10-24 12:43:23 +02:00
// SmallFileID is a file identifier of small (160x160) chat photo.
// This file_id can be used only for photo download and
// only for as long as the photo is not changed.
2017-06-30 15:29:59 +02:00
SmallFileID string `json:"small_file_id"`
2020-10-24 12:43:23 +02:00
// BigFileID is a file identifier of big (640x640) chat photo.
// This file_id can be used only for photo download and
// only for as long as the photo is not changed.
BigFileID string `json:"big_file_id"`
2017-06-30 15:29:59 +02:00
}
// Chat contains information about the place a message was sent.
type Chat struct {
2020-10-24 12:36:41 +02:00
// ID is a unique identifier for this chat
ID int64 `json:"id"`
// Type of chat, can be either “private”, “group”, “supergroup” or “channel”
Type string `json:"type"`
// Title for supergroups, channels and group chats
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
Title string `json:"title"`
// UserName for private chats, supergroups and channels if available
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
UserName string `json:"username"`
// FirstName of the other party in a private chat
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
FirstName string `json:"first_name"`
// LastName of the other party in a private chat
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
LastName string `json:"last_name"`
// AllMembersAreAdmins
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
AllMembersAreAdmins bool `json:"all_members_are_administrators"`
// Photo is a chat photo
Photo *ChatPhoto `json:"photo"`
// Description for groups, supergroups and channel chats
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
Description string `json:"description,omitempty"`
// InviteLink is a chat invite link, for groups, supergroups and channel chats.
// Each administrator in a chat generates their own invite links,
// so the bot must first generate the link using exportChatInviteLink
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
InviteLink string `json:"invite_link,omitempty"`
// PinnedMessage Pinned message, for groups, supergroups and channels
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:36:41 +02:00
// optional
PinnedMessage *Message `json:"pinned_message"`
}
// IsPrivate returns if the Chat is a private conversation.
2016-05-22 17:16:28 +02:00
func (c Chat) IsPrivate() bool {
return c.Type == "private"
}
// IsGroup returns if the Chat is a group.
2016-05-22 17:16:28 +02:00
func (c Chat) IsGroup() bool {
return c.Type == "group"
}
// IsSuperGroup returns if the Chat is a supergroup.
2016-05-22 17:16:28 +02:00
func (c Chat) IsSuperGroup() bool {
return c.Type == "supergroup"
}
// IsChannel returns if the Chat is a channel.
2016-05-22 17:16:28 +02:00
func (c Chat) IsChannel() bool {
return c.Type == "channel"
}
2016-05-22 17:16:28 +02:00
// ChatConfig returns a ChatConfig struct for chat related methods.
func (c Chat) ChatConfig() ChatConfig {
return ChatConfig{ChatID: c.ID}
}
// Message is returned by almost every request, and contains data about
// almost anything.
type Message struct {
2020-10-18 23:09:50 +02:00
// MessageID is a unique message identifier inside this chat
MessageID int `json:"message_id"`
// From is a sender, empty for messages sent to channels;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
From *User `json:"from"`
// Date of the message was sent in Unix time
Date int `json:"date"`
// Chat is the conversation the message belongs to
Chat *Chat `json:"chat"`
// ForwardFrom for forwarded messages, sender of the original message;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ForwardFrom *User `json:"forward_from"`
// ForwardFromChat for messages forwarded from channels,
// information about the original channel;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ForwardFromChat *Chat `json:"forward_from_chat"`
// ForwardFromMessageID for messages forwarded from channels,
// identifier of the original message in the channel;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ForwardFromMessageID int `json:"forward_from_message_id"`
// ForwardDate for forwarded messages, date the original message was sent in Unix time;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ForwardDate int `json:"forward_date"`
// ReplyToMessage for replies, the original message.
// Note that the Message object in this field will not contain further ReplyToMessage fields
// even if it itself is a reply;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ReplyToMessage *Message `json:"reply_to_message"`
// ViaBot through which the message was sent;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ViaBot *User `json:"via_bot"`
// EditDate of the message was last edited in Unix time;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
EditDate int `json:"edit_date"`
// MediaGroupID is the unique identifier of a media message group this message belongs to;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
MediaGroupID string `json:"media_group_id"`
// AuthorSignature is the signature of the post author for messages in channels;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
AuthorSignature string `json:"author_signature"`
// Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Text string `json:"text"`
// Entities is for text messages, special entities like usernames,
// URLs, bot commands, etc. that appear in the text;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Entities *[]MessageEntity `json:"entities"`
// CaptionEntities;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
CaptionEntities *[]MessageEntity `json:"caption_entities"`
// Audio message is an audio file, information about the file;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Audio *Audio `json:"audio"`
// Document message is a general file, information about the file;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Document *Document `json:"document"`
// Animation message is an animation, information about the animation.
// For backward compatibility, when this field is set, the document field will also be set;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Animation *ChatAnimation `json:"animation"`
// Game message is a game, information about the game;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Game *Game `json:"game"`
// Photo message is a photo, available sizes of the photo;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Photo *[]PhotoSize `json:"photo"`
// Sticker message is a sticker, information about the sticker;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Sticker *Sticker `json:"sticker"`
// Video message is a video, information about the video;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Video *Video `json:"video"`
// VideoNote message is a video note, information about the video message;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
VideoNote *VideoNote `json:"video_note"`
// Voice message is a voice message, information about the file;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Voice *Voice `json:"voice"`
// Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Caption string `json:"caption"`
// Contact message is a shared contact, information about the contact;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Contact *Contact `json:"contact"`
// Location message is a shared location, information about the location;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Location *Location `json:"location"`
// Venue message is a venue, information about the venue.
// For backward compatibility, when this field is set, the location field will also be set;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Venue *Venue `json:"venue"`
// NewChatMembers that were added to the group or supergroup
// and information about them (the bot itself may be one of these members);
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
NewChatMembers *[]User `json:"new_chat_members"`
// LeftChatMember is a member was removed from the group,
// information about them (this member may be the bot itself);
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
LeftChatMember *User `json:"left_chat_member"`
// NewChatTitle is a chat title was changed to this value;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
NewChatTitle string `json:"new_chat_title"`
// NewChatPhoto is a chat photo was change to this value;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
// DeleteChatPhoto is a service message: the chat photo was deleted;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
DeleteChatPhoto bool `json:"delete_chat_photo"`
// GroupChatCreated is a service message: the group has been created;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
GroupChatCreated bool `json:"group_chat_created"`
// SuperGroupChatCreated is a service message: the supergroup has been created.
// This field can't be received in a message coming through updates,
// because bot can't be a member of a supergroup when it is created.
// It can only be found in ReplyToMessage if someone replies to a very first message
// in a directly created supergroup;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
SuperGroupChatCreated bool `json:"supergroup_chat_created"`
// ChannelChatCreated is a service message: the channel has been created.
// This field can't be received in a message coming through updates,
// because bot can't be a member of a channel when it is created.
// It can only be found in ReplyToMessage
// if someone replies to a very first message in a channel;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
ChannelChatCreated bool `json:"channel_chat_created"`
// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
// This number may be greater than 32 bits and some programming languages
// may have difficulty/silent defects in interpreting it.
// But it is smaller than 52 bits, so a signed 64 bit integer
// or double-precision float type are safe for storing this identifier;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
MigrateToChatID int64 `json:"migrate_to_chat_id"`
// MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
// This number may be greater than 32 bits and some programming languages
// may have difficulty/silent defects in interpreting it.
// But it is smaller than 52 bits, so a signed 64 bit integer
// or double-precision float type are safe for storing this identifier;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
MigrateFromChatID int64 `json:"migrate_from_chat_id"`
// PinnedMessage is a specified message was pinned.
// Note that the Message object in this field will not contain further ReplyToMessage
// fields even if it is itself a reply;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
PinnedMessage *Message `json:"pinned_message"`
// Invoice message is an invoice for a payment;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
Invoice *Invoice `json:"invoice"`
// SuccessfulPayment message is a service message about a successful payment,
// information about the payment;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
// PassportData is a Telegram Passport data;
2020-10-24 15:47:12 +02:00
//
2020-10-18 23:09:50 +02:00
// optional
PassportData *PassportData `json:"passport_data,omitempty"`
}
2015-07-31 19:40:42 +02:00
// Time converts the message timestamp into a Time.
func (m *Message) Time() time.Time {
return time.Unix(int64(m.Date), 0)
}
// IsCommand returns true if message starts with a "bot_command" entity.
2015-11-21 14:43:39 +01:00
func (m *Message) IsCommand() bool {
if m.Entities == nil || len(*m.Entities) == 0 {
return false
}
entity := (*m.Entities)[0]
2019-01-10 12:40:12 +01:00
return entity.Offset == 0 && entity.IsCommand()
2015-11-21 14:43:39 +01:00
}
// Command checks if the message was a command and if it was, returns the
// command. If the Message was not a command, it returns an empty string.
//
// If the command contains the at name syntax, it is removed. Use
// CommandWithAt() if you do not want that.
2015-11-21 15:26:28 +01:00
func (m *Message) Command() string {
command := m.CommandWithAt()
if i := strings.Index(command, "@"); i != -1 {
command = command[:i]
}
return command
}
// CommandWithAt checks if the message was a command and if it was, returns the
// command. If the Message was not a command, it returns an empty string.
//
// If the command contains the at name syntax, it is not removed. Use Command()
// if you want that.
func (m *Message) CommandWithAt() string {
if !m.IsCommand() {
return ""
}
// IsCommand() checks that the message begins with a bot_command entity
entity := (*m.Entities)[0]
return m.Text[1:entity.Length]
}
// CommandArguments checks if the message was a command and if it was,
// returns all text after the command name. If the Message was not a
// command, it returns an empty string.
//
// Note: The first character after the command name is omitted:
// - "/foo bar baz" yields "bar baz", not " bar baz"
// - "/foo-bar baz" yields "bar baz", too
// Even though the latter is not a command conforming to the spec, the API
// marks "/foo" as command entity.
func (m *Message) CommandArguments() string {
if !m.IsCommand() {
return ""
}
// IsCommand() checks that the message begins with a bot_command entity
entity := (*m.Entities)[0]
if len(m.Text) == entity.Length {
return "" // The command makes up the whole message
}
2018-03-26 18:54:02 +02:00
return m.Text[entity.Length+1:]
2015-11-21 15:26:28 +01:00
}
2016-04-12 15:28:46 +02:00
// MessageEntity contains information about data in a Message.
type MessageEntity struct {
2020-10-24 12:43:23 +02:00
// Type of the entity.
// Can be:
// “mention” (@username),
// “hashtag” (#hashtag),
// “cashtag” ($USD),
// “bot_command” (/start@jobs_bot),
// “url” (https://telegram.org),
// “email” (do-not-reply@telegram.org),
// “phone_number” (+1-212-555-0123),
// “bold” (bold text),
// “italic” (italic text),
// “underline” (underlined text),
// “strikethrough” (strikethrough text),
// “code” (monowidth string),
// “pre” (monowidth block),
// “text_link” (for clickable text URLs),
// “text_mention” (for users without usernames)
Type string `json:"type"`
// Offset in UTF-16 code units to the start of the entity
Offset int `json:"offset"`
// Length
Length int `json:"length"`
// URL for “text_link” only, url that will be opened after user taps on the text
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:43:23 +02:00
// optional
URL string `json:"url"`
// User for “text_mention” only, the mentioned user
2020-10-24 16:18:15 +02:00
//
2020-10-24 12:43:23 +02:00
// optional
User *User `json:"user"`
2016-04-12 15:28:46 +02:00
}
// ParseURL attempts to parse a URL contained within a MessageEntity.
2019-01-10 12:40:12 +01:00
func (e MessageEntity) ParseURL() (*url.URL, error) {
if e.URL == "" {
2016-04-14 00:06:18 +02:00
return nil, errors.New(ErrBadURL)
}
2019-01-10 12:40:12 +01:00
return url.Parse(e.URL)
}
// IsMention returns true if the type of the message entity is "mention" (@username).
func (e MessageEntity) IsMention() bool {
return e.Type == "mention"
}
// IsHashtag returns true if the type of the message entity is "hashtag".
func (e MessageEntity) IsHashtag() bool {
return e.Type == "hashtag"
}
// IsCommand returns true if the type of the message entity is "bot_command".
func (e MessageEntity) IsCommand() bool {
return e.Type == "bot_command"
}
// IsUrl returns true if the type of the message entity is "url".
func (e MessageEntity) IsUrl() bool {
return e.Type == "url"
}
// IsEmail returns true if the type of the message entity is "email".
func (e MessageEntity) IsEmail() bool {
return e.Type == "email"
}
// IsBold returns true if the type of the message entity is "bold" (bold text).
func (e MessageEntity) IsBold() bool {
return e.Type == "bold"
}
// IsItalic returns true if the type of the message entity is "italic" (italic text).
func (e MessageEntity) IsItalic() bool {
return e.Type == "italic"
}
// IsCode returns true if the type of the message entity is "code" (monowidth string).
func (e MessageEntity) IsCode() bool {
return e.Type == "code"
}
// IsPre returns true if the type of the message entity is "pre" (monowidth block).
func (e MessageEntity) IsPre() bool {
return e.Type == "pre"
}
// IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
func (e MessageEntity) IsTextLink() bool {
return e.Type == "text_link"
2016-04-12 15:28:46 +02:00
}
// PhotoSize contains information about photos.
type PhotoSize struct {
// FileID identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Width photo width
Width int `json:"width"`
// Height photo height
Height int `json:"height"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
}
// Audio contains information about audio.
type Audio struct {
// FileID is an identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Duration of the audio in seconds as defined by sender
Duration int `json:"duration"`
// Performer of the audio as defined by sender or by audio tags
2020-10-24 15:47:12 +02:00
//
// optional
Performer string `json:"performer"`
// Title of the audio as defined by sender or by audio tags
2020-10-24 15:47:12 +02:00
//
// optional
Title string `json:"title"`
// MimeType of the file as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
MimeType string `json:"mime_type"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
}
// Document contains information about a document.
type Document struct {
// FileID is a identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Thumbnail document thumbnail as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
Thumbnail *PhotoSize `json:"thumb"`
// FileName original filename as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
FileName string `json:"file_name"`
// MimeType of the file as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
MimeType string `json:"mime_type"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
}
// Sticker contains information about a sticker.
type Sticker struct {
// FileUniqueID is an unique identifier for this file,
// which is supposed to be the same over time and for different bots.
// Can't be used to download or reuse the file.
FileUniqueID string `json:"file_unique_id"`
// FileID is an identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Width sticker width
Width int `json:"width"`
// Height sticker height
Height int `json:"height"`
// Thumbnail sticker thumbnail in the .WEBP or .JPG format
2020-10-24 15:47:12 +02:00
//
// optional
Thumbnail *PhotoSize `json:"thumb"`
// Emoji associated with the sticker
2020-10-24 15:47:12 +02:00
//
// optional
Emoji string `json:"emoji"`
// FileSize
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
// SetName of the sticker set to which the sticker belongs
2020-10-24 15:47:12 +02:00
//
// optional
SetName string `json:"set_name"`
// IsAnimated true, if the sticker is animated
2020-10-24 15:47:12 +02:00
//
// optional
IsAnimated bool `json:"is_animated"`
}
// StickerSet contains information about an sticker set.
2020-01-30 04:58:02 +01:00
type StickerSet struct {
// Name sticker set name
Name string `json:"name"`
// Title sticker set title
Title string `json:"title"`
// IsAnimated true, if the sticker set contains animated stickers
IsAnimated bool `json:"is_animated"`
// ContainsMasks true, if the sticker set contains masks
ContainsMasks bool `json:"contains_masks"`
// Stickers list of all set stickers
Stickers []Sticker `json:"stickers"`
2020-01-30 04:58:02 +01:00
}
2018-09-06 14:44:42 +02:00
// ChatAnimation contains information about an animation.
type ChatAnimation struct {
2020-10-24 15:21:42 +02:00
// FileID odentifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Width video width as defined by sender
Width int `json:"width"`
// Height video height as defined by sender
Height int `json:"height"`
// Duration of the video in seconds as defined by sender
Duration int `json:"duration"`
// Thumbnail animation thumbnail as defined by sender
2020-10-24 15:47:12 +02:00
//
2020-10-24 15:21:42 +02:00
// optional
Thumbnail *PhotoSize `json:"thumb"`
// FileName original animation filename as defined by sender
2020-10-24 15:47:12 +02:00
//
2020-10-24 15:21:42 +02:00
// optional
FileName string `json:"file_name"`
// MimeType of the file as defined by sender
2020-10-24 15:47:12 +02:00
//
2020-10-24 15:21:42 +02:00
// optional
MimeType string `json:"mime_type"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
2020-10-24 15:21:42 +02:00
// optional
FileSize int `json:"file_size"`
2018-09-06 14:44:42 +02:00
}
// Video contains information about a video.
type Video struct {
// FileID identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Width video width as defined by sender
Width int `json:"width"`
// Height video height as defined by sender
Height int `json:"height"`
// Duration of the video in seconds as defined by sender
Duration int `json:"duration"`
// Thumbnail video thumbnail
2020-10-24 15:47:12 +02:00
//
// optional
Thumbnail *PhotoSize `json:"thumb"`
// MimeType of a file as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
MimeType string `json:"mime_type"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
}
2017-05-22 00:04:12 +02:00
// VideoNote contains information about a video.
type VideoNote struct {
// FileID identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Length video width and height (diameter of the video message) as defined by sender
Length int `json:"length"`
// Duration of the video in seconds as defined by sender
Duration int `json:"duration"`
// Thumbnail video thumbnail
2020-10-24 15:47:12 +02:00
//
// optional
Thumbnail *PhotoSize `json:"thumb"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
2017-05-22 00:04:12 +02:00
}
// Voice contains information about a voice.
2015-08-18 03:40:42 +02:00
type Voice struct {
// FileID identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// Duration of the audio in seconds as defined by sender
Duration int `json:"duration"`
// MimeType of the file as defined by sender
2020-10-24 15:47:12 +02:00
//
// optional
MimeType string `json:"mime_type"`
// FileSize file size
2020-10-24 15:47:12 +02:00
//
// optional
FileSize int `json:"file_size"`
2015-08-18 03:40:42 +02:00
}
// Contact contains information about a contact.
//
// Note that LastName and UserID may be empty.
type Contact struct {
// PhoneNumber contact's phone number
PhoneNumber string `json:"phone_number"`
// FirstName contact's first name
FirstName string `json:"first_name"`
// LastName contact's last name
2020-10-24 15:47:12 +02:00
//
// optional
LastName string `json:"last_name"`
// UserID contact's user identifier in Telegram
2020-10-24 15:47:12 +02:00
//
// optional
UserID int `json:"user_id"`
}
// Location contains information about a place.
type Location struct {
// Longitude as defined by sender
2016-04-14 20:28:38 +02:00
Longitude float64 `json:"longitude"`
// Latitude as defined by sender
Latitude float64 `json:"latitude"`
}
2016-04-12 15:28:46 +02:00
// Venue contains information about a venue, including its Location.
type Venue struct {
// Location venue location
Location Location `json:"location"`
// Title name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// FoursquareID foursquare identifier of the venue
2020-10-24 15:47:12 +02:00
//
// optional
FoursquareID string `json:"foursquare_id"`
2016-04-12 15:28:46 +02:00
}
// UserProfilePhotos contains a set of user profile photos.
type UserProfilePhotos struct {
// TotalCount total number of profile pictures the target user has
TotalCount int `json:"total_count"`
// Photos requested profile pictures (in up to 4 sizes each)
Photos [][]PhotoSize `json:"photos"`
}
// File contains information about a file to download from Telegram.
type File struct {
2020-10-24 15:47:12 +02:00
// FileID identifier for this file, which can be used to download or reuse the file
FileID string `json:"file_id"`
// FileSize file size, if known
//
// optional
FileSize int `json:"file_size"`
// FilePath file path
//
// optional
FilePath string `json:"file_path"`
}
// Link returns a full path to the download URL for a File.
//
// It requires the Bot Token to create the link.
func (f *File) Link(token string) string {
2015-09-19 20:42:50 +02:00
return fmt.Sprintf(FileEndpoint, token, f.FilePath)
}
// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
type ReplyKeyboardMarkup struct {
2020-10-24 15:47:12 +02:00
// Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
Keyboard [][]KeyboardButton `json:"keyboard"`
// ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
// (e.g., make the keyboard smaller if there are just two rows of buttons).
// Defaults to false, in which case the custom keyboard
// is always of the same height as the app's standard keyboard.
//
// optional
ResizeKeyboard bool `json:"resize_keyboard"`
// OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
// The keyboard will still be available, but clients will automatically display
// the usual letter-keyboard in the chat the user can press a special button
// in the input field to see the custom keyboard again.
// Defaults to false.
//
// optional
OneTimeKeyboard bool `json:"one_time_keyboard"`
// Selective use this parameter if you want to show the keyboard to specific users only.
// Targets:
// 1) users that are @mentioned in the text of the Message object;
// 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
//
// Example: A user requests to change the bot's language,
// bot replies to the request with a keyboard to select the new language.
// Other users in the group don't see the keyboard.
//
// optional
Selective bool `json:"selective"`
2016-04-12 15:28:46 +02:00
}
// KeyboardButton is a button within a custom keyboard.
type KeyboardButton struct {
2020-10-24 15:47:12 +02:00
// Text of the button. If none of the optional fields are used,
// it will be sent as a message when the button is pressed.
Text string `json:"text"`
// RequestContact if True, the user's phone number will be sent
// as a contact when the button is pressed.
// Available in private chats only.
//
// optional
RequestContact bool `json:"request_contact"`
// RequestLocation if True, the user's current location will be sent when the button is pressed.
// Available in private chats only.
//
// optional
RequestLocation bool `json:"request_location"`
}
// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
type ReplyKeyboardHide struct {
HideKeyboard bool `json:"hide_keyboard"`
Selective bool `json:"selective"` // optional
}
// ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
type ReplyKeyboardRemove struct {
2020-10-24 15:47:12 +02:00
// RemoveKeyboard requests clients to remove the custom keyboard
// (user will not be able to summon this keyboard;
// if you want to hide the keyboard from sight but keep it accessible,
// use one_time_keyboard in ReplyKeyboardMarkup).
RemoveKeyboard bool `json:"remove_keyboard"`
2020-10-24 15:47:12 +02:00
// Selective use this parameter if you want to remove the keyboard for specific users only.
// Targets:
// 1) users that are @mentioned in the text of the Message object;
// 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
//
// Example: A user votes in a poll, bot returns confirmation message
// in reply to the vote and removes the keyboard for that user,
// while still showing the keyboard with poll options to users who haven't voted yet.
//
// optional
Selective bool `json:"selective"`
}
2016-04-12 15:28:46 +02:00
// InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
type InlineKeyboardMarkup struct {
2020-10-24 15:47:12 +02:00
// InlineKeyboard array of button rows, each represented by an Array of InlineKeyboardButton objects
2016-04-12 15:28:46 +02:00
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
// InlineKeyboardButton is a button within a custom keyboard for
// inline query responses.
//
// Note that some values are references as even an empty string
// will change behavior.
//
// CallbackGame, if set, MUST be first button in first row.
2016-04-12 15:28:46 +02:00
type InlineKeyboardButton struct {
2020-10-24 15:47:12 +02:00
// Text label text on the button
Text string `json:"text"`
// URL HTTP or tg:// url to be opened when button is pressed.
//
// optional
URL *string `json:"url,omitempty"`
// CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
//
// optional
CallbackData *string `json:"callback_data,omitempty"`
// SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
// open that chat and insert the bot's username and the specified inline query in the input field.
// Can be empty, in which case just the bot's username will be inserted.
//
// This offers an easy way for users to start using your bot
// in inline mode when they are currently in a private chat with it.
// Especially useful when combined with switch_pm… actions in this case
// the user will be automatically returned to the chat they switched from,
// skipping the chat selection screen.
//
// optional
SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
// SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
// and the specified inline query in the current chat's input field.
// Can be empty, in which case only the bot's username will be inserted.
//
// This offers a quick way for the user to open your bot in inline mode
// in the same chat good for selecting something from multiple options.
//
// optional
SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
// CallbackGame description of the game that will be launched when the user presses the button.
//
// optional
CallbackGame *CallbackGame `json:"callback_game,omitempty"`
// Pay specify True, to send a Pay button.
//
// NOTE: This type of button must always be the first button in the first row.
//
// optional
Pay bool `json:"pay,omitempty"`
2016-04-12 15:28:46 +02:00
}
// CallbackQuery is data sent when a keyboard button with callback data
// is clicked.
type CallbackQuery struct {
// ID unique identifier for this query
ID string `json:"id"`
// From sender
From *User `json:"from"`
// Message with the callback button that originated the query.
// Note that message content and message date will not be available if the message is too old.
//
// optional
Message *Message `json:"message"`
// InlineMessageID identifier of the message sent via the bot in inline mode, that originated the query.
//
// optional
//
InlineMessageID string `json:"inline_message_id"`
// ChatInstance global identifier, uniquely corresponding to the chat to which
// the message with the callback button was sent. Useful for high scores in games.
//
ChatInstance string `json:"chat_instance"`
// Data associated with the callback button. Be aware that
// a bad client can send arbitrary data in this field.
//
// optional
Data string `json:"data"`
// GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
//
// optional
GameShortName string `json:"game_short_name"`
2016-04-12 15:28:46 +02:00
}
// ForceReply allows the Bot to have users directly reply to it without
// additional interaction.
type ForceReply struct {
// ForceReply shows reply interface to the user,
// as if they manually selected the bot's message and tapped 'Reply'.
ForceReply bool `json:"force_reply"`
// Selective use this parameter if you want to force reply from specific users only.
// Targets:
// 1) users that are @mentioned in the text of the Message object;
// 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
//
// optional
Selective bool `json:"selective"`
}
2016-05-22 17:16:28 +02:00
// ChatMember is information about a member in a chat.
type ChatMember struct {
2020-10-24 15:58:02 +02:00
// User information about the user
User *User `json:"user"`
// Status the member's status in the chat.
// Can be
// “creator”,
// “administrator”,
// “member”,
// “restricted”,
// “left” or
// “kicked”
Status string `json:"status"`
// CustomTitle owner and administrators only. Custom title for this user
//
// optional
CustomTitle string `json:"custom_title,omitempty"`
// UntilDate restricted and kicked only.
// Date when restrictions will be lifted for this user;
// unix time.
//
// optional
UntilDate int64 `json:"until_date,omitempty"`
// CanBeEdited administrators only.
// True, if the bot is allowed to edit administrator privileges of that user.
//
// optional
CanBeEdited bool `json:"can_be_edited,omitempty"`
// CanChangeInfo administrators and restricted only.
// True, if the user is allowed to change the chat title, photo and other settings.
//
// optional
CanChangeInfo bool `json:"can_change_info,omitempty"`
// CanChangeInfo administrators only.
// True, if the administrator can post in the channel;
// channels only.
//
// optional
CanPostMessages bool `json:"can_post_messages,omitempty"`
// CanEditMessages administrators only.
// True, if the administrator can edit messages of other users and can pin messages;
// channels only.
//
// optional
CanEditMessages bool `json:"can_edit_messages,omitempty"`
// CanDeleteMessages administrators only.
// True, if the administrator can delete messages of other users.
//
// optional
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
// CanInviteUsers administrators and restricted only.
// True, if the user is allowed to invite new users to the chat.
//
// optional
CanInviteUsers bool `json:"can_invite_users,omitempty"`
// CanRestrictMembers administrators only.
// True, if the administrator can restrict, ban or unban chat members.
//
// optional
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
// CanPinMessages
//
// optional
CanPinMessages bool `json:"can_pin_messages,omitempty"`
// CanPromoteMembers administrators only.
// True, if the administrator can add new administrators
// with a subset of their own privileges or demote administrators that he has promoted,
// directly or indirectly (promoted by administrators that were appointed by the user).
//
// optional
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
// CanSendMessages
//
// optional
CanSendMessages bool `json:"can_send_messages,omitempty"`
// CanSendMediaMessages restricted only.
// True, if the user is allowed to send text messages, contacts, locations and venues
//
// optional
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
// CanSendOtherMessages restricted only.
// True, if the user is allowed to send audios, documents,
// photos, videos, video notes and voice notes.
//
// optional
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
// CanAddWebPagePreviews restricted only.
// True, if the user is allowed to add web page previews to their messages.
//
// optional
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
2016-05-22 17:16:28 +02:00
}
// IsCreator returns if the ChatMember was the creator of the chat.
func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
// IsAdministrator returns if the ChatMember is a chat administrator.
func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
// IsMember returns if the ChatMember is a current member of the chat.
func (chat ChatMember) IsMember() bool { return chat.Status == "member" }
// HasLeft returns if the ChatMember left the chat.
func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
// WasKicked returns if the ChatMember was kicked from the chat.
func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
// Game is a game within Telegram.
type Game struct {
2020-10-24 16:00:46 +02:00
// Title of the game
Title string `json:"title"`
// Description of the game
Description string `json:"description"`
// Photo that will be displayed in the game message in chats.
Photo []PhotoSize `json:"photo"`
// Text a brief description of the game or high scores included in the game message.
// Can be automatically edited to include current high scores for the game
// when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
//
// optional
Text string `json:"text"`
// TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
//
// optional
TextEntities []MessageEntity `json:"text_entities"`
2020-10-24 16:00:46 +02:00
// Animation animation that will be displayed in the game message in chats.
// Upload via BotFather (https://t.me/botfather).
//
// optional
Animation Animation `json:"animation"`
}
// Animation is a GIF animation demonstrating the game.
type Animation struct {
// FileID identifier for this file, which can be used to download or reuse the file.
FileID string `json:"file_id"`
// Thumb animation thumbnail as defined by sender.
//
// optional
Thumb PhotoSize `json:"thumb"`
// FileName original animation filename as defined by sender.
//
// optional
FileName string `json:"file_name"`
// MimeType of the file as defined by sender.
//
// optional
MimeType string `json:"mime_type"`
// FileSize ile size
//
// optional
FileSize int `json:"file_size"`
}
// GameHighScore is a user's score and position on the leaderboard.
type GameHighScore struct {
// Position in high score table for the game
Position int `json:"position"`
// User user
User User `json:"user"`
// Score score
Score int `json:"score"`
}
// CallbackGame is for starting a game in an inline keyboard button.
type CallbackGame struct{}
// WebhookInfo is information about a currently set webhook.
type WebhookInfo struct {
// URL webhook URL, may be empty if webhook is not set up.
URL string `json:"url"`
// HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
HasCustomCertificate bool `json:"has_custom_certificate"`
// PendingUpdateCount number of updates awaiting delivery.
PendingUpdateCount int `json:"pending_update_count"`
// LastErrorDate unix time for the most recent error
// that happened when trying to deliver an update via webhook.
//
// optional
LastErrorDate int `json:"last_error_date"`
// LastErrorMessage error message in human-readable format for the most recent error
// that happened when trying to deliver an update via webhook.
//
// optional
LastErrorMessage string `json:"last_error_message"`
// MaxConnections maximum allowed number of simultaneous
// HTTPS connections to the webhook for update delivery.
//
// optional
MaxConnections int `json:"max_connections"`
}
// IsSet returns true if a webhook is currently set.
func (info WebhookInfo) IsSet() bool {
return info.URL != ""
}
// InputMediaPhoto contains a photo for displaying as part of a media group.
type InputMediaPhoto struct {
2020-10-24 16:12:11 +02:00
// Type of the result, must be photo.
Type string `json:"type"`
// Media file to send. Pass a file_id to send a file that
// exists on the Telegram servers (recommended),
// pass an HTTP URL for Telegram to get a file from the Internet,
// or pass “attach://<file_attach_name>” to upload a new one
// using multipart/form-data under <file_attach_name> name.
Media string `json:"media"`
// Caption of the photo to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the photo caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
}
// InputMediaVideo contains a video for displaying as part of a media group.
type InputMediaVideo struct {
2020-10-24 16:12:11 +02:00
// Type of the result, must be video.
Type string `json:"type"`
// Media file to send. Pass a file_id to send a file
// that exists on the Telegram servers (recommended),
// pass an HTTP URL for Telegram to get a file from the Internet,
// or pass “attach://<file_attach_name>” to upload a new one
// using multipart/form-data under <file_attach_name> name.
Media string `json:"media"`
// thumb intentionally missing as it is not currently compatible
2020-10-24 16:12:11 +02:00
// Caption of the video to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// Width video width
//
// optional
Width int `json:"width"`
// Height video height
//
// optional
Height int `json:"height"`
// Duration video duration
//
// optional
Duration int `json:"duration"`
// SupportsStreaming pass True, if the uploaded video is suitable for streaming.
//
// optional
SupportsStreaming bool `json:"supports_streaming"`
}
// InlineQuery is a Query from Telegram for an inline request.
type InlineQuery struct {
2020-10-24 16:44:17 +02:00
// ID unique identifier for this query
ID string `json:"id"`
// From sender
From *User `json:"from"`
// Location sender location, only for bots that request user location.
//
// optional
Location *Location `json:"location"`
// Query text of the query (up to 256 characters).
Query string `json:"query"`
// Offset of the results to be returned, can be controlled by the bot.
Offset string `json:"offset"`
}
// InlineQueryResultArticle is an inline query response article.
type InlineQueryResultArticle struct {
2020-10-24 16:44:17 +02:00
// Type of the result, must be article.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes.
//
// required
ID string `json:"id"`
// Title of the result
//
// required
Title string `json:"title"`
// InputMessageContent content of the message to be sent.
//
// required
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// ReplyMarkup Inline keyboard attached to the message.
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// URL of the result.
//
// optional
URL string `json:"url"`
// HideURL pass True, if you don't want the URL to be shown in the message.
//
// optional
HideURL bool `json:"hide_url"`
// Description short description of the result.
//
// optional
Description string `json:"description"`
// ThumbURL url of the thumbnail for the result
//
// optional
ThumbURL string `json:"thumb_url"`
// ThumbWidth thumbnail width
//
// optional
ThumbWidth int `json:"thumb_width"`
// ThumbHeight thumbnail height
//
// optional
ThumbHeight int `json:"thumb_height"`
}
// InlineQueryResultPhoto is an inline query response photo.
type InlineQueryResultPhoto struct {
2020-10-24 16:44:17 +02:00
// Type of the result, must be article.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes.
//
// required
ID string `json:"id"`
// URL a valid URL of the photo. Photo must be in jpeg format.
// Photo size must not exceed 5MB.
URL string `json:"photo_url"`
// MimeType
MimeType string `json:"mime_type"`
// Width of the photo
//
// optional
Width int `json:"photo_width"`
// Height of the photo
//
// optional
Height int `json:"photo_height"`
// ThumbURL url of the thumbnail for the photo.
//
// optional
ThumbURL string `json:"thumb_url"`
// Title for the result
//
// optional
Title string `json:"title"`
// Description short description of the result
//
// optional
Description string `json:"description"`
// Caption of the photo to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the photo caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the photo.
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedPhoto is an inline query response with cached photo.
type InlineQueryResultCachedPhoto struct {
// Type of the result, must be photo.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// PhotoID a valid file identifier of the photo.
//
// required
PhotoID string `json:"photo_file_id"`
// Title for the result.
//
// optional
Title string `json:"title"`
// Description short description of the result.
//
// optional
Description string `json:"description"`
// Caption of the photo to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the photo caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the photo.
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultGIF is an inline query response GIF.
type InlineQueryResultGIF struct {
// Type of the result, must be gif.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// URL a valid URL for the GIF file. File size must not exceed 1MB.
//
// required
URL string `json:"gif_url"`
// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
//
// required
ThumbURL string `json:"thumb_url"`
// Width of the GIF
//
// optional
Width int `json:"gif_width,omitempty"`
// Height of the GIF
//
// optional
Height int `json:"gif_height,omitempty"`
// Duration of the GIF
//
// optional
Duration int `json:"gif_duration,omitempty"`
// Title for the result
//
// optional
Title string `json:"title,omitempty"`
// Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the GIF animation.
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedGIF is an inline query response with cached gif.
type InlineQueryResultCachedGIF struct {
// Type of the result, must be gif.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// GifID a valid file identifier for the GIF file.
//
// required
GifID string `json:"gif_file_id"`
// Title for the result
//
// optional
Title string `json:"title"`
// Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the GIF animation.
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
type InlineQueryResultMPEG4GIF struct {
// Type of the result, must be mpeg4_gif
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid URL for the MP4 file. File size must not exceed 1MB
//
// required
URL string `json:"mpeg4_url"`
// Width video width
//
// optional
Width int `json:"mpeg4_width"`
// Height vVideo height
//
// optional
Height int `json:"mpeg4_height"`
// Duration video duration
//
// optional
Duration int `json:"mpeg4_duration"`
// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
ThumbURL string `json:"thumb_url"`
// Title for the result
//
// optional
Title string `json:"title"`
// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the video animation
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedMpeg4Gif is an inline query response with cached
// H.264/MPEG-4 AVC video without sound gif.
type InlineQueryResultCachedMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// MGifID a valid file identifier for the MP4 file
//
// required
MGifID string `json:"mpeg4_file_id"`
// Title for the result
//
// optional
Title string `json:"title"`
// Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the video animation.
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultVideo is an inline query response video.
type InlineQueryResultVideo struct {
// Type of the result, must be video
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid url for the embedded video player or video file
//
// required
URL string `json:"video_url"`
// MimeType of the content of video url, “text/html” or “video/mp4”
//
// required
MimeType string `json:"mime_type"`
//
// ThumbURL url of the thumbnail (jpeg only) for the video
// optional
ThumbURL string `json:"thumb_url"`
// Title for the result
//
// required
Title string `json:"title"`
// Caption of the video to be sent, 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// Width video width
//
// optional
Width int `json:"video_width"`
// Height video height
//
// optional
Height int `json:"video_height"`
// Duration video duration in seconds
//
// optional
Duration int `json:"video_duration"`
// Description short description of the result
//
// optional
Description string `json:"description"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the video.
// This field is required if InlineQueryResultVideo is used to send
// an HTML-page as a result (e.g., a YouTube video).
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
2016-01-04 17:15:57 +01:00
// InlineQueryResultCachedVideo is an inline query response with cached video.
type InlineQueryResultCachedVideo struct {
// Type of the result, must be video
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// VideoID a valid file identifier for the video file
//
// required
VideoID string `json:"video_file_id"`
// Title for the result
//
// required
Title string `json:"title"`
// Description short description of the result
//
// optional
Description string `json:"description"`
// Caption of the video to be sent, 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the video
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedSticker is an inline query response with cached sticker.
type InlineQueryResultCachedSticker struct {
// Type of the result, must be sticker
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// StickerID a valid file identifier of the sticker
//
// required
StickerID string `json:"sticker_file_id"`
// Title is a title
Title string `json:"title"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the sticker
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultAudio is an inline query response audio.
type InlineQueryResultAudio struct {
// Type of the result, must be audio
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid url for the audio file
//
// required
URL string `json:"audio_url"`
// Title is a title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// Performer is a performer
//
// optional
Performer string `json:"performer"`
// Duration audio duration in seconds
//
// optional
Duration int `json:"audio_duration"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the audio
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedAudio is an inline query response with cached audio.
type InlineQueryResultCachedAudio struct {
// Type of the result, must be audio
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// AudioID a valid file identifier for the audio file
//
// required
AudioID string `json:"audio_file_id"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the audio
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultVoice is an inline query response voice.
type InlineQueryResultVoice struct {
// Type of the result, must be voice
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid URL for the voice recording
//
// required
URL string `json:"voice_url"`
// Title recording title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// Duration recording duration in seconds
//
// optional
Duration int `json:"voice_duration"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the voice recording
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVoice is an inline query response with cached voice.
type InlineQueryResultCachedVoice struct {
// Type of the result, must be voice
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// VoiceID a valid file identifier for the voice message
//
// required
VoiceID string `json:"voice_file_id"`
// Title voice message title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the voice message
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultDocument is an inline query response document.
type InlineQueryResultDocument struct {
// Type of the result, must be document
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// Title for the result
//
// required
Title string `json:"title"`
// Caption of the document to be sent, 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// URL a valid url for the file
//
// required
URL string `json:"document_url"`
// MimeType of the content of the file, either “application/pdf” or “application/zip”
//
// required
MimeType string `json:"mime_type"`
// Description short description of the result
//
// optional
Description string `json:"description"`
// ReplyMarkup nline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the file
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// ThumbURL url of the thumbnail (jpeg only) for the file
//
// optional
ThumbURL string `json:"thumb_url"`
// ThumbWidth thumbnail width
//
// optional
ThumbWidth int `json:"thumb_width"`
// ThumbHeight thumbnail height
//
// optional
ThumbHeight int `json:"thumb_height"`
}
// InlineQueryResultCachedDocument is an inline query response with cached document.
type InlineQueryResultCachedDocument struct {
// Type of the result, must be document
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// DocumentID a valid file identifier for the file
//
// required
DocumentID string `json:"document_file_id"`
// Title for the result
//
// optional
Title string `json:"title"` // required
// Caption of the document to be sent, 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption"`
// Description short description of the result
//
// optional
Description string `json:"description"`
// ParseMode mode for parsing entities in the video caption.
// // See formatting options for more details
// // (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the file
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultLocation is an inline query response location.
type InlineQueryResultLocation struct {
// Type of the result, must be location
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes
//
// required
ID string `json:"id"`
// Latitude of the location in degrees
//
// required
Latitude float64 `json:"latitude"`
// Longitude of the location in degrees
//
// required
Longitude float64 `json:"longitude"`
// Title of the location
//
// required
Title string `json:"title"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the location
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// ThumbURL url of the thumbnail for the result
//
// optional
ThumbURL string `json:"thumb_url"`
// ThumbWidth thumbnail width
//
// optional
ThumbWidth int `json:"thumb_width"`
// ThumbHeight thumbnail height
//
// optional
ThumbHeight int `json:"thumb_height"`
}
2020-01-06 17:28:13 +01:00
// InlineQueryResultVenue is an inline query response venue.
type InlineQueryResultVenue struct {
// Type of the result, must be venue
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes
//
// required
ID string `json:"id"`
// Latitude of the venue location in degrees
//
// required
Latitude float64 `json:"latitude"`
// Longitude of the venue location in degrees
//
// required
Longitude float64 `json:"longitude"`
// Title of the venue
//
// required
Title string `json:"title"`
// Address of the venue
//
// required
Address string `json:"address"`
// FoursquareID foursquare identifier of the venue if known
//
// optional
FoursquareID string `json:"foursquare_id"`
// FoursquareType foursquare type of the venue, if known.
// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
//
// optional
FoursquareType string `json:"foursquare_type"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// InputMessageContent content of the message to be sent instead of the venue
//
// optional
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// ThumbURL url of the thumbnail for the result
//
// optional
ThumbURL string `json:"thumb_url"`
// ThumbWidth thumbnail width
//
// optional
ThumbWidth int `json:"thumb_width"`
// ThumbHeight thumbnail height
//
// optional
ThumbHeight int `json:"thumb_height"`
2020-01-06 17:28:13 +01:00
}
// InlineQueryResultGame is an inline query response game.
type InlineQueryResultGame struct {
// Type of the result, must be game
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// GameShortName short name of the game
//
// required
GameShortName string `json:"game_short_name"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
2016-01-04 17:15:57 +01:00
// ChosenInlineResult is an inline query result chosen by a User
type ChosenInlineResult struct {
// ResultID the unique identifier for the result that was chosen
ResultID string `json:"result_id"`
// From the user that chose the result
From *User `json:"from"`
// Location sender location, only for bots that require user location
//
// optional
Location *Location `json:"location"`
// InlineMessageID identifier of the sent inline message.
// Available only if there is an inline keyboard attached to the message.
// Will be also received in callback queries and can be used to edit the message.
//
// optional
InlineMessageID string `json:"inline_message_id"`
// Query the query that was used to obtain the result
Query string `json:"query"`
2016-01-04 17:15:57 +01:00
}
2016-04-12 15:59:47 +02:00
// InputTextMessageContent contains text for displaying
// as an inline query result.
type InputTextMessageContent struct {
// Text of the message to be sent, 1-4096 characters
Text string `json:"message_text"`
// ParseMode mode for parsing entities in the message text.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode"`
// DisableWebPagePreview disables link previews for links in the sent message
//
// optional
DisableWebPagePreview bool `json:"disable_web_page_preview"`
}
2016-04-12 15:59:47 +02:00
// InputLocationMessageContent contains a location for displaying
// as an inline query result.
type InputLocationMessageContent struct {
// Latitude of the location in degrees
Latitude float64 `json:"latitude"`
// Longitude of the location in degrees
Longitude float64 `json:"longitude"`
}
2016-04-12 15:59:47 +02:00
// InputVenueMessageContent contains a venue for displaying
// as an inline query result.
type InputVenueMessageContent struct {
// Latitude of the venue in degrees
Latitude float64 `json:"latitude"`
// Longitude of the venue in degrees
Longitude float64 `json:"longitude"`
// Title name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// FoursquareID foursquare identifier of the venue, if known
//
// optional
FoursquareID string `json:"foursquare_id"`
}
2016-04-12 15:59:47 +02:00
// InputContactMessageContent contains a contact for displaying
// as an inline query result.
type InputContactMessageContent struct {
// PhoneNumber contact's phone number
PhoneNumber string `json:"phone_number"`
// FirstName contact's first name
FirstName string `json:"first_name"`
// LastName contact's last name
//
// optional
LastName string `json:"last_name"`
}
2017-06-02 22:18:42 +02:00
2017-06-03 08:59:40 +02:00
// Invoice contains basic information about an invoice.
2017-06-02 22:18:42 +02:00
type Invoice struct {
2020-10-24 22:23:18 +02:00
// Title product name
Title string `json:"title"`
// Description product description
Description string `json:"description"`
// StartParameter unique bot deep-linking parameter that can be used to generate this invoice
2017-06-02 22:18:42 +02:00
StartParameter string `json:"start_parameter"`
2020-10-24 22:23:18 +02:00
// Currency three-letter ISO 4217 currency code
// (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
2020-10-24 22:31:18 +02:00
// TotalAmount total price in the smallest units of the currency (integer, not float/double).
2020-10-24 22:23:18 +02:00
// For example, for a price of US$ 1.45 pass amount = 145.
2020-10-24 22:27:45 +02:00
// See the exp parameter in currencies.json
// (https://core.telegram.org/bots/payments/currencies.json),
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies).
2020-10-24 22:23:18 +02:00
TotalAmount int `json:"total_amount"`
2017-06-02 22:18:42 +02:00
}
2017-06-03 08:59:40 +02:00
// LabeledPrice represents a portion of the price for goods or services.
2017-06-02 22:18:42 +02:00
type LabeledPrice struct {
2020-10-24 22:27:45 +02:00
// Label portion label
Label string `json:"label"`
// Amount price of the product in the smallest units of the currency (integer, not float/double).
// For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json
// (https://core.telegram.org/bots/payments/currencies.json),
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies).
Amount int `json:"amount"`
2017-06-02 22:18:42 +02:00
}
2017-06-03 08:59:40 +02:00
// ShippingAddress represents a shipping address.
2017-06-02 22:18:42 +02:00
type ShippingAddress struct {
2020-10-24 22:27:45 +02:00
// CountryCode ISO 3166-1 alpha-2 country code
2017-06-02 22:18:42 +02:00
CountryCode string `json:"country_code"`
2020-10-24 22:27:45 +02:00
// State if applicable
State string `json:"state"`
// City city
City string `json:"city"`
2020-10-24 22:31:18 +02:00
// StreetLine1 first line for the address
2017-06-02 22:18:42 +02:00
StreetLine1 string `json:"street_line1"`
2020-10-24 22:27:45 +02:00
// StreetLine2 second line for the address
2017-06-02 22:18:42 +02:00
StreetLine2 string `json:"street_line2"`
2020-10-24 22:27:45 +02:00
// PostCode address post code
PostCode string `json:"post_code"`
2017-06-02 22:18:42 +02:00
}
2017-06-03 08:59:40 +02:00
// OrderInfo represents information about an order.
2017-06-02 22:18:42 +02:00
type OrderInfo struct {
2020-10-24 22:27:45 +02:00
// Name user name
//
// optional
Name string `json:"name,omitempty"`
// PhoneNumber user's phone number
//
// optional
PhoneNumber string `json:"phone_number,omitempty"`
// Email user email
//
// optional
Email string `json:"email,omitempty"`
// ShippingAddress user shipping address
//
// optional
2017-06-02 22:18:42 +02:00
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
2017-06-03 08:59:40 +02:00
// ShippingOption represents one shipping option.
2017-06-02 22:18:42 +02:00
type ShippingOption struct {
2020-10-24 22:27:45 +02:00
// ID shipping option identifier
ID string `json:"id"`
// Title option title
Title string `json:"title"`
// Prices list of price portions
2017-06-02 22:18:42 +02:00
Prices *[]LabeledPrice `json:"prices"`
}
2017-06-03 08:59:40 +02:00
// SuccessfulPayment contains basic information about a successful payment.
2017-06-02 22:18:42 +02:00
type SuccessfulPayment struct {
2020-10-24 22:31:18 +02:00
// Currency three-letter ISO 4217 currency code
// (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
// TotalAmount total price in the smallest units of the currency (integer, not float/double).
// For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json,
// (https://core.telegram.org/bots/payments/currencies.json)
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies).
TotalAmount int `json:"total_amount"`
// InvoicePayload bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// ShippingOptionID identifier of the shipping option chosen by the user
//
// optional
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// OrderInfo order info provided by the user
//
// optional
OrderInfo *OrderInfo `json:"order_info,omitempty"`
// TelegramPaymentChargeID telegram payment identifier
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
// ProviderPaymentChargeID provider payment identifier
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
2017-06-02 22:18:42 +02:00
}
2017-06-03 08:59:40 +02:00
// ShippingQuery contains information about an incoming shipping query.
2017-06-02 22:18:42 +02:00
type ShippingQuery struct {
// ID unique query identifier
ID string `json:"id"`
// From user who sent the query
From *User `json:"from"`
// InvoicePayload bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// ShippingAddress user specified shipping address
2017-06-02 22:18:42 +02:00
ShippingAddress *ShippingAddress `json:"shipping_address"`
}
2017-06-03 08:59:40 +02:00
// PreCheckoutQuery contains information about an incoming pre-checkout query.
2017-06-02 22:18:42 +02:00
type PreCheckoutQuery struct {
// ID unique query identifier
ID string `json:"id"`
// From user who sent the query
From *User `json:"from"`
// Currency three-letter ISO 4217 currency code
// // (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
// TotalAmount total price in the smallest units of the currency (integer, not float/double).
// // For example, for a price of US$ 1.45 pass amount = 145.
// // See the exp parameter in currencies.json,
// // (https://core.telegram.org/bots/payments/currencies.json)
// // it shows the number of digits past the decimal point
// // for each currency (2 for the majority of currencies).
TotalAmount int `json:"total_amount"`
// InvoicePayload bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// ShippingOptionID identifier of the shipping option chosen by the user
//
// optional
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// OrderInfo order info provided by the user
//
// optional
OrderInfo *OrderInfo `json:"order_info,omitempty"`
2017-06-02 22:18:42 +02:00
}
2018-03-26 18:54:02 +02:00
// Error is an error containing extra information returned by the Telegram API.
type Error struct {
2019-03-01 17:17:35 +01:00
Code int
Message string
ResponseParameters
}
func (e Error) Error() string {
return e.Message
}
2020-09-26 22:55:26 +02:00
// BotCommand represents a bot command.
type BotCommand struct {
// Command text of the command, 1-32 characters.
// Can contain only lowercase English letters, digits and underscores.
Command string `json:"command"`
// Description of the command, 3-256 characters.
2020-09-26 22:55:26 +02:00
Description string `json:"description"`
}