tgbotapi

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2025 License: Apache-2.0, MIT Imports: 16 Imported by: 1

Documentation

Overview

Package tgbotapi has functions and types used for interacting with the Telegram Bot API.

Index

Examples

Constants

View Source
const (
	// APIEndpoint is the endpoint for all API methods,
	// with formatting for Sprintf.
	APIEndpoint = "https://api.telegram.org/bot%s/%s"
	// FileEndpoint is the endpoint for downloading a file from Telegram.
	FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
)

Telegram constants

View Source
const (
	// ChatTyping is chat action
	ChatTyping = "typing"

	// ChatUploadPhoto is chat action
	ChatUploadPhoto = "upload_photo"

	// ChatRecordVideo is chat action
	ChatRecordVideo = "record_video"

	// ChatUploadVideo is chat action
	ChatUploadVideo = "upload_video"

	// ChatRecordAudio is chat action
	ChatRecordAudio = "record_audio"

	// ChatUploadAudio is chat action
	ChatUploadAudio = "upload_audio"

	// ChatUploadDocument is chat action
	ChatUploadDocument = "upload_document"

	// ChatFindLocation is chat action
	ChatFindLocation = "find_location"
)

Constant values for ChatActions

View Source
const (
	// ModeMarkdown indicates markdown mode
	ModeMarkdown = "Markdown"

	// ModeHTML indicates HTML mode
	ModeHTML = "HTML"
)

Constant values for ParseMode in MessageConfig

View Source
const (
	OwnedGiftTypeRegular = OwnedGiftType("regular")
	OwnedGiftTypeUnique  = OwnedGiftType("unique")
)

Variables

View Source
var (
	// ErrBadFileType happens when you pass an unknown type
	ErrBadFileType = errors.New("bad file type")

	// ErrBadURL indicates bad or empty URL
	ErrBadURL = errors.New("bad or empty URL")
)

Library errors

View Source
var ErrNoChatID = errors.New("missing chat_id")

ErrNoChatID is error when chat_id is missing

Functions

func ReplyToResponse

func ReplyToResponse(chattable Sendable, w http.ResponseWriter) (string, error)

ReplyToResponse replies to response

Types

type APIResponse

type APIResponse struct {
	Ok          bool            `json:"ok"`
	Result      json.RawMessage `json:"result"`
	ErrorCode   int             `json:"error_code"`
	Description string          `json:"description"`
}

APIResponse is a response from the Telegram API with the result stored raw.

func (APIResponse) Error

func (r APIResponse) Error() string

type AnswerCallbackQueryConfig

type AnswerCallbackQueryConfig struct {
	CallbackQueryID string `json:"callback_query_id,"`
	Text            string `json:"text,omitempty"`
	ShowAlert       bool   `json:"show_alert,omitempty"`
	URL             string `json:"url,omitempty"`
	CacheTime       int    `json:"cache_time,omitempty"`
}

AnswerCallbackQueryConfig contains information on making a CallbackQuery response.

func NewCallback

func NewCallback(id, text string) AnswerCallbackQueryConfig

NewCallback creates a new callback message.

func NewCallbackWithAlert

func NewCallbackWithAlert(id, text string) AnswerCallbackQueryConfig

NewCallbackWithAlert creates a new callback message that alerts the user.

func NewCallbackWithURL

func NewCallbackWithURL(url string) AnswerCallbackQueryConfig

NewCallbackWithURL creates new callback command with URL

func (AnswerCallbackQueryConfig) TelegramMethod added in v0.12.0

func (j AnswerCallbackQueryConfig) TelegramMethod() string

func (AnswerCallbackQueryConfig) Values

func (j AnswerCallbackQueryConfig) Values() (url.Values, error)

Values returns URL values representation of AnswerCallbackQueryConfig

type AnswerPreCheckoutQueryConfig added in v0.12.0

type AnswerPreCheckoutQueryConfig struct {
	// Unique identifier for the query to be answered
	PreCheckoutQueryID string `json:"pre_checkout_query_id"`

	// Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
	OK bool `json:"ok"`

	// ErrorMessage is optional. Required if ok is False. Error message in human readable form
	// that explains the reason for failure to proceed with the checkout
	// (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your Payment details. Please choose a different color or garment!").
	// Telegram will display this message to the user.
	ErrorMessage string `json:"error_message,omitempty"`
}

func AnswerPreCheckoutQueryWithNotOK added in v0.12.0

func AnswerPreCheckoutQueryWithNotOK(preCheckoutQueryID, errorMessage string) AnswerPreCheckoutQueryConfig

func AnswerPreCheckoutQueryWithOK added in v0.12.0

func AnswerPreCheckoutQueryWithOK(preCheckoutQueryID string) AnswerPreCheckoutQueryConfig

func (AnswerPreCheckoutQueryConfig) TelegramMethod added in v0.12.0

func (AnswerPreCheckoutQueryConfig) TelegramMethod() string

func (AnswerPreCheckoutQueryConfig) Values added in v0.12.0

func (c AnswerPreCheckoutQueryConfig) Values() (values url.Values, err error)

type Audio

type Audio struct {
	FileID    string `json:"file_id"`
	Duration  int    `json:"duration"`
	Performer string `json:"performer"` // optional
	Title     string `json:"title"`     // optional
	MimeType  string `json:"mime_type"` // optional
	FileSize  int    `json:"file_size"` // optional
}

Audio contains information about audio.

type AudioConfig

type AudioConfig struct {
	BaseFile
	Duration  int
	Performer string
	Title     string
}

AudioConfig contains information about a SendAudio request.

func NewAudioShare

func NewAudioShare(chatID int64, fileID string) *AudioConfig

NewAudioShare shares an existing audio file. You may use this to reshare an existing audio file without reuploading it.

chatID is where to send it, fileID is the ID of the audio already uploaded.

func NewAudioUpload

func NewAudioUpload(chatID int64, file interface{}) *AudioConfig

NewAudioUpload creates a new audio uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

func (AudioConfig) TelegramMethod added in v0.12.0

func (j AudioConfig) TelegramMethod() string

method returns Telegram API method name for sending Audio.

func (AudioConfig) Values

func (j AudioConfig) Values() (url.Values, error)

Values returns url.Values representation of AudioConfig.

type BaseChat

type BaseChat struct {
	ChatID              int64  `json:"chat_id,omitempty"`
	ChannelUsername     string `json:"channel_username,omitempty"`
	ReplyToMessageID    int    `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         any    `json:"reply_markup,omitempty"`
	DisableNotification bool   `json:"disable_notification,omitempty"`

	ProtectContent bool `json:"protect_content,omitempty"` // Protects the contents of the sent message from forwarding and saving

	// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
	MessageThreadID    int64  `json:"message_thread_id,omitempty"`
	MessageEffectID    string `json:"message_effect_id,omitempty"`
	AllowPaidBroadcast bool   `json:"allow_paid_broadcast,omitempty"` // Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance

	ReplyParameters *ReplyParameters `json:"reply_parameters,omitempty"` // Description of the message to reply to

	BusinessConnectionID string `json:"business_connection_id,omitempty"` // Unique identifier of the business connection on behalf of which the message will be sent
}

BaseChat is a base type for all chat config types.

func (BaseChat) Values

func (j BaseChat) Values() (url.Values, error)

Values returns url.Values representation of BaseChat

type BaseEdit

type BaseEdit struct {
	ChannelUsername string                `json:",omitempty"`
	InlineMessageID string                `json:"inline_message_id,omitempty"`
	ReplyMarkup     *InlineKeyboardMarkup `json:",omitempty"`
	// contains filtered or unexported fields
}

BaseEdit is base type of all chat edits.

func NewChatMessageEdit

func NewChatMessageEdit(chatID int64, messageID int) BaseEdit

NewChatMessageEdit returns BaseEdit

func (BaseEdit) Values

func (v BaseEdit) Values() (url.Values, error)

Values returns URL values

type BaseFile

type BaseFile struct {
	BaseChat
	File        interface{}
	FileID      string
	UseExisting bool
	MimeType    string
	FileSize    int
}

BaseFile is a base type for all file config types.

type BotAPI

type BotAPI struct {
	Token  string       `json:"token"`
	Self   User         `json:"-"`
	Client *http.Client `json:"-"`
	// contains filtered or unexported fields
}

BotAPI allows you to interact with the Telegram Bot API.

func NewBotAPI

func NewBotAPI(token string) *BotAPI

NewBotAPI creates a new BotAPI instance.

It requires a token, provided by @BotFather on Telegram.

Example
bot := NewBotAPI("MyAwesomeBotToken")

log.Printf("Authorized on account %s", bot.Self.UserName)

u := NewUpdate(0)
u.Timeout = 60

updates, _ := bot.GetUpdatesChan(u)

for update := range updates {
	log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

	msg := NewMessage(update.Message.Chat.ID, update.Message.Text)
	msg.ReplyToMessageID = update.Message.MessageID

	if _, err := bot.Send(msg); err != nil {
		log.Println(err)
	}
}

func NewBotAPIWithClient

func NewBotAPIWithClient(token string, client *http.Client) *BotAPI

NewBotAPIWithClient creates a new BotAPI instance and allows you to pass a http.Client.

It requires a token, provided by @BotFather on Telegram.

func (*BotAPI) AnswerInlineQuery

func (bot *BotAPI) AnswerInlineQuery(config InlineConfig) (APIResponse, error)

AnswerInlineQuery sends a response to an inline query.

Note that you must respond to an inline query within 30 seconds.

func (*BotAPI) DeleteMessage added in v0.9.0

func (bot *BotAPI) DeleteMessage(chatID string, messageID int) (apiResp APIResponse, err error)

func (*BotAPI) EnableDebug

func (bot *BotAPI) EnableDebug(c context.Context)

EnableDebug enables debugging

func (*BotAPI) GetChat

func (bot *BotAPI) GetChat(chatID string) (Chat, error)

func (*BotAPI) GetCommands added in v0.12.0

func (bot *BotAPI) GetCommands(ctx context.Context, config GetMyCommandsConfig) (commands []TelegramBotCommand, err error)

func (*BotAPI) GetFile

func (bot *BotAPI) GetFile(config FileConfig) (File, error)

GetFile returns a File which can download a file from Telegram.

Requires FileID.

func (*BotAPI) GetFileDirectURL

func (bot *BotAPI) GetFileDirectURL(fileID string) (string, error)

GetFileDirectURL returns direct URL to file

It requires the FileID.

func (*BotAPI) GetMe

func (bot *BotAPI) GetMe() (User, error)

GetMe fetches the currently authenticated bot.

This TelegramMethod is called upon creation to validate the token, and so you may get this data from BotAPI.Self without the need for another request.

func (*BotAPI) GetUpdates

func (bot *BotAPI) GetUpdates(config *UpdateConfig) ([]Update, error)

GetUpdates fetches updates. If a WebHook is set, this will not return any data!

Offset, Limit, and Timeout are optional. To avoid stale items, set Offset to one higher than the previous item. Set Timeout to a large number to reduce requests so you can get updates instantly instead of having to wait between requests.

func (*BotAPI) GetUpdatesChan

func (bot *BotAPI) GetUpdatesChan(config *UpdateConfig) (<-chan Update, error)

GetUpdatesChan starts and returns a channel for getting updates.

func (*BotAPI) GetUserProfilePhotos

func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error)

GetUserProfilePhotos gets a user's profile photos.

It requires UserID. Offset and Limit are optional.

func (*BotAPI) IsMessageToMe

func (bot *BotAPI) IsMessageToMe(message Message) bool

IsMessageToMe returns true if message directed to this bot.

It requires the Message.

func (*BotAPI) KickChatMember

func (bot *BotAPI) KickChatMember(config ChatMemberConfig) (APIResponse, error)

KickChatMember kicks a user from a chat. Note that this only will work in supergroups, and requires the bot to be an admin. Also note they will be unable to rejoin until they are unbanned.

func (*BotAPI) ListenForWebhook

func (bot *BotAPI) ListenForWebhook(pattern string) <-chan Update

ListenForWebhook registers a http handler for a webhook.

func (*BotAPI) MakeRequest

func (bot *BotAPI) MakeRequest(telegramMethod string, params url.Values) (apiResp APIResponse, err error)

SendRequest sends a request to a specific endpoint with our token and reads response.

func (*BotAPI) MakeRequestFromChattable

func (bot *BotAPI) MakeRequestFromChattable(m Sendable) (resp APIResponse, err error)

MakeRequestFromChattable makes request from chattable TODO: Is duplicate of Send()?

func (*BotAPI) MakeRequestFromMessageWithValues added in v0.12.0

func (bot *BotAPI) MakeRequestFromMessageWithValues(method string, m WithValues) (resp APIResponse, err error)

MakeRequestFromMessageWithValues makes request from WithValues

func (*BotAPI) RemoveWebhook

func (bot *BotAPI) RemoveWebhook() (APIResponse, error)

RemoveWebhook unsets the webhook.

func (*BotAPI) Send

func (bot *BotAPI) Send(c Sendable) (Message, error)

Send will send a Sendable item to Telegram.

It requires the Sendable to send.

func (*BotAPI) SendCustomMessage added in v0.12.0

func (bot *BotAPI) SendCustomMessage(ctx context.Context, config Sendable, result any) (err error)

func (*BotAPI) SetCommands added in v0.12.0

func (bot *BotAPI) SetCommands(config SetMyCommandsConfig) (APIResponse, error)

func (*BotAPI) SetDescription added in v0.12.0

func (bot *BotAPI) SetDescription(config SetMyDescription) (APIResponse, error)

func (*BotAPI) SetShortDescription added in v0.12.0

func (bot *BotAPI) SetShortDescription(config SetMyShortDescription) (APIResponse, error)

func (*BotAPI) SetWebhook

func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error)

SetWebhook sets a webhook.

If this is set, GetUpdates will not get any data!

If you do not have a legitimate TLS certificate, you need to include your self-signed certificate with the config.

func (*BotAPI) UnbanChatMember

func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error)

UnbanChatMember unbans a user from a chat. Note that this only will work in supergroups, and requires the bot to be an admin.

func (*BotAPI) UploadFile

func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldname string, file interface{}) (apiResp APIResponse, err error)

UploadFile makes a request to the API with a file.

Requires the parameter to hold the file not be in the params. File should be a string to a file path, a FileBytes struct, or a FileReader struct.

Note that if your FileReader has a size set to -1, it will read the file into memory to calculate a size.

type BotCommandScope added in v0.12.0

type BotCommandScope struct {
	Type   BotCommandScopeType `json:"type"`
	ChatID any                 `json:"chatID"`  // Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
	UserID int                 `json:"user_id"` // Unique identifier of the target user
}

BotCommandScope represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported:

- BotCommandScopeDefault - BotCommandScopeAllPrivateChats - BotCommandScopeAllGroupChats - BotCommandScopeAllChatAdministrators - BotCommandScopeChat - BotCommandScopeChatAdministrators - BotCommandScopeChatMember

https://core.telegram.org/bots/api#botcommandscope

func (*BotCommandScope) Validate added in v0.12.0

func (v *BotCommandScope) Validate() error

type BotCommandScopeType added in v0.12.0

type BotCommandScopeType string
const (
	BotCommandScopeDefault               BotCommandScopeType = "default"
	BotCommandScopeAllPrivateChats       BotCommandScopeType = "all_private_chats"
	BotCommandScopeAllGroupChats         BotCommandScopeType = "all_group_chats"
	BotCommandScopeAllChatAdministrators BotCommandScopeType = "all_chat_administrators"
	BotCommandScopeChat                  BotCommandScopeType = "chat"
	BotCommandScopeChatAdministrators    BotCommandScopeType = "chat_administrators"
	BotCommandScopeChatMember            BotCommandScopeType = "chat_member"
)

type CallbackGame added in v0.6.0

type CallbackGame struct {
}

CallbackGame is a placeholder, currently holds no information. Use BotFather to set up your game.

func (CallbackGame) Validate added in v0.10.0

func (v CallbackGame) Validate() error

type CallbackQuery

type CallbackQuery struct {
	ID              string   `json:"id"`
	From            *User    `json:"from"`
	Message         *Message `json:"message,omitempty"`           // optional
	ChatInstance    string   `json:"chat_instance,omitempty"`     // optional
	InlineMessageID string   `json:"inline_message_id,omitempty"` // optional
	Data            string   `json:"data,omitempty"`              // optional
}

CallbackQuery is data sent when a keyboard button with callback data is clicked.

type Chat

type Chat struct {
	ID        int64  `json:"id"`
	Type      string `json:"type"`
	Title     string `json:"title"`      // optional
	UserName  string `json:"username"`   // optional
	FirstName string `json:"first_name"` // optional
	LastName  string `json:"last_name"`  // optional
}

Chat contains information about the place a message was sent.

func (*Chat) IsChannel

func (c *Chat) IsChannel() bool

IsChannel returns if the Chat is a channel.

func (*Chat) IsGroup

func (c *Chat) IsGroup() bool

IsGroup returns if the Chat is a group.

func (*Chat) IsPrivate

func (c *Chat) IsPrivate() bool

IsPrivate returns if the Chat is a private conversation.

func (*Chat) IsSuperGroup

func (c *Chat) IsSuperGroup() bool

IsSuperGroup returns if the Chat is a supergroup.

type ChatActionConfig

type ChatActionConfig struct {
	BaseChat
	Action string // required
}

ChatActionConfig contains information about a SendChatAction request.

func NewChatAction

func NewChatAction(chatID int64, action string) *ChatActionConfig

NewChatAction sets a chat action. Actions last for 5 seconds, or until your next action.

chatID is where to send it, action should be set via Chat constants.

func (ChatActionConfig) TelegramMethod added in v0.12.0

func (config ChatActionConfig) TelegramMethod() string

method returns Telegram API method name for sending ChatAction.

func (ChatActionConfig) Values

func (config ChatActionConfig) Values() (url.Values, error)

Values returns url.Values representation of ChatActionConfig.

type ChatAdministratorRights added in v0.5.0

type ChatAdministratorRights struct {
	// True, if the user's presence in the chat is hidden
	IsAnonymous bool `json:"is_anonymous,omitempty"`
}

type ChatMember

type ChatMember struct {
	User
	IsBot bool `json:"is_bot,omitempty"`
}

ChatMember holds information about chat member

func (ChatMember) IsBotUser

func (chatMember ChatMember) IsBotUser() bool

IsBotUser indicates if chat member is a bot

type ChatMemberConfig

type ChatMemberConfig struct {
	ChatID             int64
	SuperGroupUsername string
	UserID             int
}

ChatMemberConfig contains information about a user in a chat for use with administrative functions such as kicking or unbanning a user.

type ChatShared added in v0.12.0

type ChatShared struct {
	RequestID int         `json:"request_id"`      // Identifier of the request
	ChatID    int         `json:"chat_id"`         // Identifier of the shared chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
	Title     string      `json:"title"`           // Optional. Title of the chat, if the title was requested by the bot.
	Username  string      `json:"username"`        // Optional. Username of the chat, if the username was requested by the bot and available.
	Photo     []PhotoSize `json:"photo,omitempty"` // Optional. Available sizes of the chat photo, if the photo was requested by the bot
}

type ChosenInlineResult

type ChosenInlineResult struct {
	ResultID        string    `json:"result_id"`
	From            *User     `json:"from"`
	Location        *Location `json:"location"`
	InlineMessageID string    `json:"inline_message_id"`
	Query           string    `json:"query"`
}

ChosenInlineResult is an inline query result chosen by a User

type Contact

type Contact struct {

	// PhoneNumber must always be presented
	PhoneNumber string `json:"phone_number"`

	// FirstName must always be presented
	FirstName string `json:"first_name"`

	// Optional
	LastName string `json:"last_name,omitempty"` // optional

	// UserID (optional) is a Contact's user identifier in Telegram.
	// It has at most 52 significant bits,
	// so a 64-bit integer or double-precision float type are safe for storing this identifier.
	UserID int64 `json:"user_id,omitempty"` // optional

	// VCard (optional) additional data about the contact in the form of https://en.wikipedia.org/wiki/VCard
	VCard string `json:"vcard,omitempty"`
}

Contact contains information about a contact. Note that LastName, UserID, VCard may be empty.

type ContactConfig

type ContactConfig struct {
	BaseChat
	PhoneNumber string
	FirstName   string
	LastName    string
}

ContactConfig allows you to send a contact.

func NewContact

func NewContact(chatID int64, phoneNumber, firstName string) *ContactConfig

NewContact allows you to send a shared contact.

func (ContactConfig) TelegramMethod added in v0.12.0

func (j ContactConfig) TelegramMethod() string

func (ContactConfig) Values

func (j ContactConfig) Values() (url.Values, error)

Values returns URL values representation of ContactConfig

type CopyTextButton added in v0.11.0

type CopyTextButton struct {
	Text string `json:"text"`
}

CopyTextButton represents an inline keyboard button that copies specified text to the clipboard.

func (CopyTextButton) Validate added in v0.11.0

func (v CopyTextButton) Validate() error

type CreateInvoiceLinkConfig added in v0.12.0

type CreateInvoiceLinkConfig struct {
	BaseChat

	// Unique identifier of the business connection on behalf of which the message will be sent
	BusinessConnectionID string `json:"business_connection_id,omitempty"`
}

func (*CreateInvoiceLinkConfig) TelegramMethod added in v0.12.0

func (*CreateInvoiceLinkConfig) TelegramMethod() string

func (*CreateInvoiceLinkConfig) Values added in v0.12.0

func (v *CreateInvoiceLinkConfig) Values() (url.Values, error)

Values returns url.Values representation of InvoiceConfig.

type DeleteMessage

type DeleteMessage chatEdit

DeleteMessage is a command to delete a message. It should not be used with SendMessage() Instead use BotAPI.DeleteMessage(chatID string, messageID int)

func (*DeleteMessage) TelegramMethod added in v0.12.0

func (*DeleteMessage) TelegramMethod() string

func (DeleteMessage) Values

func (m DeleteMessage) Values() (url.Values, error)

Values returns URL values representation of DeleteMessage

type Document

type Document struct {
	FileID    string     `json:"file_id"`
	Thumbnail *PhotoSize `json:"thumb,omitempty"`     // optional
	FileName  string     `json:"file_name,omitempty"` // optional
	MimeType  string     `json:"mime_type,omitempty"` // optional
	FileSize  int        `json:"file_size,omitempty"` // optional
}

Document contains information about a document.

type DocumentConfig

type DocumentConfig struct {
	BaseFile
}

DocumentConfig contains information about a SendDocument request.

func NewDocumentShare

func NewDocumentShare(chatID int64, fileID string) *DocumentConfig

NewDocumentShare shares an existing document. You may use this to reshare an existing document without reuploading it.

chatID is where to send it, fileID is the ID of the document already uploaded.

func NewDocumentUpload

func NewDocumentUpload(chatID int64, file interface{}) *DocumentConfig

NewDocumentUpload creates a new document uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

func (DocumentConfig) TelegramMethod added in v0.12.0

func (v DocumentConfig) TelegramMethod() string

method returns Telegram API method name for sending Document.

func (DocumentConfig) Values

func (v DocumentConfig) Values() (url.Values, error)

Values returns url.Values representation of DocumentConfig.

type EditMessageCaptionConfig

type EditMessageCaptionConfig struct {
	BaseEdit
	Caption string
}

EditMessageCaptionConfig allows you to modify the caption of a message.

func NewEditMessageCaption

func NewEditMessageCaption(chatID int64, messageID int, caption string) *EditMessageCaptionConfig

NewEditMessageCaption allows you to edit the caption of a message.

func (EditMessageCaptionConfig) TelegramMethod added in v0.12.0

func (j EditMessageCaptionConfig) TelegramMethod() string

func (EditMessageCaptionConfig) Values

func (j EditMessageCaptionConfig) Values() (url.Values, error)

Values returns URL values representation of EditMessageCaptionConfig

type EditMessageReplyMarkupConfig

type EditMessageReplyMarkupConfig struct {
	BaseEdit
}

EditMessageReplyMarkupConfig allows you to modify the reply markup of a message.

func NewEditMessageReplyMarkup

func NewEditMessageReplyMarkup(chatID int64, messageID int, inlineMessageID string, replyMarkup *InlineKeyboardMarkup) *EditMessageReplyMarkupConfig

NewEditMessageReplyMarkup allows you to edit the inline keyboard markup.

func (EditMessageReplyMarkupConfig) TelegramMethod added in v0.12.0

func (config EditMessageReplyMarkupConfig) TelegramMethod() string

func (EditMessageReplyMarkupConfig) Values

func (config EditMessageReplyMarkupConfig) Values() (url.Values, error)

Values returns URL values representation of EditMessageReplyMarkupConfig

type EditMessageTextConfig

type EditMessageTextConfig struct {
	BaseEdit
	Text                  string
	ParseMode             string
	DisableWebPagePreview bool
}

EditMessageTextConfig allows you to modify the text in a message.

func NewEditMessageText

func NewEditMessageText(chatID int64, messageID int, inlineMessageID, text string) *EditMessageTextConfig

NewEditMessageText allows you to edit the text of a message.

func (EditMessageTextConfig) TelegramMethod added in v0.12.0

func (j EditMessageTextConfig) TelegramMethod() string

func (EditMessageTextConfig) Values

func (j EditMessageTextConfig) Values() (url.Values, error)

Values returns URL values representation of EditMessageTextConfig

type ErrAPIForbidden

type ErrAPIForbidden struct {
}

ErrAPIForbidden is for 'forbidden' API response

func (ErrAPIForbidden) Error

func (err ErrAPIForbidden) Error() string

Error implements error interface

func (ErrAPIForbidden) IsForbidden

func (err ErrAPIForbidden) IsForbidden() bool

IsForbidden indicates is forbidden

type ExportChatInviteLink struct {
	// contains filtered or unexported fields
}

ExportChatInviteLink is message command for exporting chat link

func (ExportChatInviteLink) TelegramMethod added in v0.12.0

func (ExportChatInviteLink) TelegramMethod() string

func (ExportChatInviteLink) Values

func (v ExportChatInviteLink) Values() (url.Values, error)

type File

type File struct {
	FileID   string `json:"file_id"`
	FileSize int    `json:"file_size,omitempty"` // optional
	FilePath string `json:"file_path,omitempty"` // optional
}

File contains information about a file to download from Telegram.

func (f *File) Link(token string) string

Link returns a full path to the download URL for a File.

It requires the Bot Token to create the link.

type FileBytes

type FileBytes struct {
	Name  string
	Bytes []byte
}

FileBytes contains information about a set of bytes to upload as a File.

type FileConfig

type FileConfig struct {
	FileID string
}

FileConfig has information about a file hosted on Telegram.

type FileID added in v0.13.0

type FileID string

func (FileID) PhotoType added in v0.13.0

func (FileID) PhotoType() PhotoType

type FileReader

type FileReader struct {
	Name   string
	Reader io.Reader
	Size   int64
}

FileReader contains information about a reader to upload as a File. If Size is -1, it will read the entire Reader into memory to calculate a Size.

type Fileable

type Fileable interface {
	Sendable
	// contains filtered or unexported methods
}

Fileable is any config type that can be sent that includes a file.

type ForceReply

type ForceReply struct {
	ForceReply bool `json:"force_reply"`
	Selective  bool `json:"selective,omitempty"` // optional
}

ForceReply allows the Bot to have users directly reply to it without additional interaction.

func (ForceReply) KeyboardType

func (ForceReply) KeyboardType() botkb.KeyboardType

KeyboardType returns KeyboardTypeForceReply

type ForwardConfig

type ForwardConfig struct {
	BaseChat
	FromChatID          int64 // required
	FromChannelUsername string
	MessageID           int // required
}

ForwardConfig contains information about a ForwardMessage request.

func NewForward

func NewForward(chatID int64, fromChatID int64, messageID int) *ForwardConfig

NewForward creates a new forward.

chatID is where to send it, fromChatID is the source chat, and messageID is the ID of the original message.

func (ForwardConfig) TelegramMethod added in v0.12.0

func (v ForwardConfig) TelegramMethod() string

method returns Telegram API method name for sending Forward.

func (ForwardConfig) Values

func (v ForwardConfig) Values() (url.Values, error)

Values returns url.Values representation of ForwardConfig.

type FoursquareFields added in v0.10.0

type FoursquareFields struct {

	// Optional. Foursquare identifier of the venue if known
	FoursquareID string `json:"foursquare_id,omitempty"`

	// Optional. Foursquare type of the venue, if known.
	// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
	FoursquareType string `json:"foursquare_type,omitempty"`
}

type GetMyCommandsConfig added in v0.12.0

type GetMyCommandsConfig = MyCommandsBase

func (GetMyCommandsConfig) TelegramMethod added in v0.12.0

func (v GetMyCommandsConfig) TelegramMethod() string

type Gift added in v0.12.0

type Gift struct {
	ID               string  `json:"id"`                           // Unique identifier of the gift
	Sticker          Sticker `json:"sticker"`                      // The sticker that represents the gift
	StarCount        int     `json:"star_count"`                   // The number of Telegram Stars that must be paid to send the sticker
	UpgradeStarCount int     `json:"upgrade_star_count,omitempty"` // Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one
	TotalCount       int     `json:"total_count,omitempty"`        // Optional. The total number of the gifts of this type that can be sent; for limited gifts only
	RemainingCount   int     `json:"remaining_count,omitempty"`    // Optional. The number of remaining gifts of this type that can be sent; for limited gifts only
}

type GiftInfo added in v0.12.0

type GiftInfo struct {
	Gift Gift `json:"gift"` // Information about the gift

	OwnedGiftID string `json:"owned_gift_id,omitempty"` // Optional. Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts

	ConvertStarCount        int `json:"convert_star_count,omitempty"`         // Optional. Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitted if conversion to Telegram Stars is impossible
	PrepaidUpgradeStarCount int `json:"prepaid_upgrade_star_count,omitempty"` // Optional. Number of Telegram Stars that were prepaid by the sender for the ability to upgrade the gift

	CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` // Optional. True, if the gift can be upgraded to a unique gift

	Text string `json:"text,omitempty"` // Optional. Text of the message that was added to the gift

	Entities []MessageEntity `json:"entities,omitempty"` // Optional. Special entities that appear in the text

	IsPrivate bool `json:"is_private,omitempty"` // Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them
}

type GiftOrigin added in v0.12.0

type GiftOrigin string
const (
	GiftOriginUpgrade  GiftOrigin = "upgrade"
	GiftOriginTransfer GiftOrigin = "transfer"
)

type GooglePlaceFields added in v0.10.0

type GooglePlaceFields struct {
	// Optional. Google Places identifier of the venue
	GooglePlaceID string `json:"google_place_id,omitempty"`
	// Optional. Google Places type of the venue.
	// https://developers.google.com/maps/documentation/places/web-service/supported_types
	GooglePlaceType string `json:"google_place_type,omitempty"`
}

type GroupChat

type GroupChat struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

GroupChat is a group chat.

type InlineConfig

type InlineConfig struct {
	InlineQueryID string `json:"inline_query_id"`

	Results []InlineQueryResult `json:"results,omitempty"`

	// Optional.
	// The maximum amount of time in seconds that the result of the inline query may be cached on the server.
	// Defaults to 300.
	CacheTime int `json:"cache_time"`

	// Optional	Pass True if results may be cached on the server side only for the user that sent the query.
	// By default, results may be returned to any user who sends the same query.
	IsPersonal bool `json:"is_personal,omitempty"`

	// Optional.
	// Pass the offset that a client should send in the next query with the same text to receive more results.
	// Pass an empty string if there are no more results or if you don't support pagination.
	// Offset length can't exceed 64 bytes.
	NextOffset string `json:"next_offset,omitempty"`

	Button *InlineQueryResultsButton `json:"button,omitempty"`
}

InlineConfig contains information on making an InlineQuery response.

func (InlineConfig) TelegramMethod added in v0.12.0

func (config InlineConfig) TelegramMethod() string

func (InlineConfig) Values

func (config InlineConfig) Values() (url.Values, error)

Values returns URL values representation of InlineConfig

type InlineKeyboardButton

type InlineKeyboardButton struct {

	// Label text on the button
	Text string `json:"text"`

	// Optional.
	// HTTP or tg:// URL to be opened when the button is pressed.
	// Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username,
	// if this is allowed by their privacy settings.
	URL string `json:"url,omitempty"`

	// Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes
	CallbackData string `json:"callback_data,omitempty"`

	// Optional. Description of the Web App that will be launched when the user presses the button.
	// The Web App will be able to send an arbitrary message on behalf of the user using the TelegramMethod answerWebAppQuery.
	// Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account.
	WebApp *WebAppInfo `json:"web_app,omitempty"`

	// Optional. An HTTPS URL used to automatically authorize the user.
	// Can be used as a replacement for the Telegram Login Widget.
	LoginUrl *LoginUrl `json:"login_url,omitempty"`

	// Optional. 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.
	// May be empty, in which case just the bot's username will be inserted.
	// Not supported for messages sent on behalf of a Telegram Business account.
	SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // we use pointer as empty string is non zero value in this case

	// Optional. If set, pressing the button will insert the bot's username
	// and the specified inline query in the current chat's input field.
	// May 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.
	// Not supported in channels and for messages sent on behalf of a Telegram Business account.
	SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // we use pointer as empty string is non zero value in this case

	// Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type,
	// open that chat and insert the bot's username and the specified inline query in the input field.
	// Not supported for messages sent on behalf of a Telegram Business account.
	SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`

	CopyText *CopyTextButton `json:"copy_text,omitempty"`

	// Optional. Description of the game that will be launched when the user presses the button.
	//
	//NOTE: This type of button must always be the first button in the first row.
	CallbackGame *CallbackGame `json:"callback_game,omitempty"`

	// Optional. Specify True, to send a Pay button.
	//  Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
	//
	// NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
	Pay bool `json:"pay,omitempty"`
}

InlineKeyboardButton represents one button of an inline keyboard. !!Exactly one of the optional fields must be used to specify type of the button. Note that some values are references as even an empty string will change behavior. Documentation: https://core.telegram.org/bots/api#inlinekeyboardbutton

func NewInlineKeyboardButtonData

func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton

NewInlineKeyboardButtonData creates an inline keyboard button with text and data for a callback.

func NewInlineKeyboardButtonSwitchInlineQuery

func NewInlineKeyboardButtonSwitchInlineQuery(text, query string) InlineKeyboardButton

NewInlineKeyboardButtonSwitchInlineQuery creates an inline keyboard button with text which allows the user to switch to a chat or return to a chat.

func NewInlineKeyboardButtonSwitchInlineQueryCurrentChat

func NewInlineKeyboardButtonSwitchInlineQueryCurrentChat(text, query string) InlineKeyboardButton

NewInlineKeyboardButtonSwitchInlineQueryCurrentChat create new command

func NewInlineKeyboardButtonURL

func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton

NewInlineKeyboardButtonURL creates an inline keyboard button with text which goes to a URL.

func NewInlineKeyboardRow

func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton

NewInlineKeyboardRow creates an inline keyboard row with buttons.

func (InlineKeyboardButton) Validate added in v0.10.0

func (v InlineKeyboardButton) Validate() error

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}

InlineKeyboardMarkup is a custom keyboard presented for an inline bot.

func NewInlineKeyboardMarkup

func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) *InlineKeyboardMarkup

NewInlineKeyboardMarkup creates a new inline keyboard.

func (*InlineKeyboardMarkup) KeyboardType

func (*InlineKeyboardMarkup) KeyboardType() botkb.KeyboardType

KeyboardType returns KeyboardTypeInline

func (*InlineKeyboardMarkup) Validate added in v0.10.0

func (v *InlineKeyboardMarkup) Validate() error

type InlineQuery

type InlineQuery struct {
	ID       string    `json:"id"`
	From     *User     `json:"from"`
	Location *Location `json:"location,omitempty"` // optional
	Query    string    `json:"query"`
	Offset   string    `json:"offset"`
}

InlineQuery is a Query from Telegram for an inline request.

type InlineQueryResult added in v0.10.0

type InlineQueryResult interface {
	GetType() InlineQueryResultType
	GetID() string
	Validate() error
}

type InlineQueryResultArticle

type InlineQueryResultArticle struct {
	InlineQueryResultBase
	InputMessageContent interface{} `json:"input_message_content"` // required
	URL                 string      `json:"url,omitempty"`
	HideURL             bool        `json:"hide_url,omitempty"`
	Description         string      `json:"description,omitempty"`
	ThumbURL            string      `json:"thumb_url,omitempty"`
	ThumbWidth          int         `json:"thumb_width,omitempty"`
	ThumbHeight         int         `json:"thumb_height,omitempty"`
}

InlineQueryResultArticle is an inline query response article.

func NewInlineQueryResultArticle

func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle

NewInlineQueryResultArticle creates a new inline query article.

func (InlineQueryResultArticle) Validate added in v0.10.0

func (r InlineQueryResultArticle) Validate() error

type InlineQueryResultAudio

type InlineQueryResultAudio struct {
	InlineQueryResultBase
	URL                 string      `json:"audio_url"` // required
	Performer           string      `json:"performer"`
	Duration            int         `json:"audio_duration"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultAudio is an inline query response audio.

func NewInlineQueryResultAudio

func NewInlineQueryResultAudio(id, url, title string) *InlineQueryResultAudio

NewInlineQueryResultAudio creates a new inline query audio.

func (InlineQueryResultAudio) Validate added in v0.10.0

func (r InlineQueryResultAudio) Validate() error

type InlineQueryResultBase added in v0.10.0

type InlineQueryResultBase struct {
	Type InlineQueryResultType `json:"type"`

	// Unique identifier for this result, 1-64 bytes
	ID string `json:"id"`

	// Title for the result. Few results do not support title.
	Title string `json:"title,omitempty"`

	// Optional. Inline keyboard attached to the message.
	// https://core.telegram.org/bots/features#inline-keyboards
	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

func (InlineQueryResultBase) GetID added in v0.10.0

func (r InlineQueryResultBase) GetID() string

func (InlineQueryResultBase) GetTitle added in v0.10.0

func (r InlineQueryResultBase) GetTitle() string

func (InlineQueryResultBase) GetType added in v0.10.0

func (InlineQueryResultBase) Validate added in v0.10.0

func (r InlineQueryResultBase) Validate() error

type InlineQueryResultCachedSticker added in v0.10.0

type InlineQueryResultCachedSticker struct {
	InlineQueryResultBase

	// A valid file identifier of the sticker
	StickerFileID       string              `json:"sticker_file_id"` // required
	InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}

func (InlineQueryResultCachedSticker) Validate added in v0.10.0

type InlineQueryResultContact added in v0.10.0

type InlineQueryResultContact struct {
	InlineQueryResultBase
	PhoneNumber         string              `json:"phone_number"`
	FirstName           string              `json:"first_name"`
	LastName            string              `json:"last_name,omitempty"`
	Vcard               string              `json:"vcard,omitempty"`
	InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}

func (InlineQueryResultContact) Validate added in v0.10.0

func (r InlineQueryResultContact) Validate() error

type InlineQueryResultDocument

type InlineQueryResultDocument struct {
	InlineQueryResultBase
	Caption             string      `json:"caption"`
	URL                 string      `json:"document_url"` // required
	MimeType            string      `json:"mime_type"`    // required
	Description         string      `json:"description"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
	ThumbURL            string      `json:"thumb_url"`
	ThumbWidth          int         `json:"thumb_width"`
	ThumbHeight         int         `json:"thumb_height"`
}

InlineQueryResultDocument is an inline query response document.

func NewInlineQueryResultDocument

func NewInlineQueryResultDocument(id, url, title, mimeType string) *InlineQueryResultDocument

NewInlineQueryResultDocument creates a new inline query document.

func (InlineQueryResultDocument) Validate added in v0.10.0

func (r InlineQueryResultDocument) Validate() error

type InlineQueryResultGIF

type InlineQueryResultGIF struct {
	InlineQueryResultBase
	URL                 string      `json:"gif_url"` // required
	Width               int         `json:"gif_width,omitempty"`
	Height              int         `json:"gif_height,omitempty"`
	ThumbURL            string      `json:"thumb_url,omitempty"`
	Caption             string      `json:"caption,omitempty"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultGIF is an inline query response GIF.

func NewInlineQueryResultGIF

func NewInlineQueryResultGIF(id, url, title string) InlineQueryResultGIF

NewInlineQueryResultGIF creates a new inline query GIF.

func (InlineQueryResultGIF) Validate added in v0.10.0

func (r InlineQueryResultGIF) Validate() error

type InlineQueryResultGame added in v0.10.0

type InlineQueryResultGame struct {
	InlineQueryResultBase
	// Short name of the game
	GameShortName string `json:"game_short_name"`
}

func (InlineQueryResultGame) Validate added in v0.10.0

func (v InlineQueryResultGame) Validate() error

type InlineQueryResultLocation

type InlineQueryResultLocation struct {
	InlineQueryResultBase
	Latitude            float64     `json:"latitude"`  // required
	Longitude           float64     `json:"longitude"` // required
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
	ThumbURL            string      `json:"thumb_url,omitempty"`
	ThumbWidth          int         `json:"thumb_width,omitempty"`
	ThumbHeight         int         `json:"thumb_height,omitempty"`
}

InlineQueryResultLocation is an inline query response location.

func NewInlineQueryResultLocation

func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) *InlineQueryResultLocation

NewInlineQueryResultLocation creates a new inline query location.

func (InlineQueryResultLocation) Validate added in v0.10.0

func (r InlineQueryResultLocation) Validate() error

type InlineQueryResultMPEG4GIF

type InlineQueryResultMPEG4GIF struct {
	InlineQueryResultBase
	URL                 string      `json:"mpeg4_url"` // required
	Width               int         `json:"mpeg4_width"`
	Height              int         `json:"mpeg4_height"`
	ThumbURL            string      `json:"thumb_url"`
	Caption             string      `json:"caption"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.

func NewInlineQueryResultMPEG4GIF

func NewInlineQueryResultMPEG4GIF(id, url, title string) *InlineQueryResultMPEG4GIF

NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.

func (InlineQueryResultMPEG4GIF) Validate added in v0.10.0

func (r InlineQueryResultMPEG4GIF) Validate() error

type InlineQueryResultPhoto

type InlineQueryResultPhoto struct {
	InlineQueryResultBase
	URL                 string      `json:"photo_url"` // required
	MimeType            string      `json:"mime_type,omitempty"`
	Width               int         `json:"photo_width,omitempty"`
	Height              int         `json:"photo_height,omitempty"`
	ThumbURL            string      `json:"thumb_url,omitempty"`
	Description         string      `json:"description,omitempty"`
	Caption             string      `json:"caption,omitempty"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultPhoto is an inline query response photo.

func NewInlineQueryResultPhoto

func NewInlineQueryResultPhoto(id, url, title string) *InlineQueryResultPhoto

NewInlineQueryResultPhoto creates a new inline query photo.

func (InlineQueryResultPhoto) Validate added in v0.10.0

func (r InlineQueryResultPhoto) Validate() error

type InlineQueryResultType added in v0.10.0

type InlineQueryResultType string
const (
	InlineQueryResultTypeArticle  InlineQueryResultType = "article"
	InlineQueryResultTypeAudio    InlineQueryResultType = "audio"
	InlineQueryResultTypeContact  InlineQueryResultType = "contact"
	InlineQueryResultTypeGame     InlineQueryResultType = "game"
	InlineQueryResultTypeDocument InlineQueryResultType = "document"
	InlineQueryResultTypeGIF      InlineQueryResultType = "gif"
	InlineQueryResultTypeLocation InlineQueryResultType = "location"
	InlineQueryResultTypeMpeg4Gif InlineQueryResultType = "mpeg4_gif"
	InlineQueryResultTypePhoto    InlineQueryResultType = "photo"
	InlineQueryResultTypeVenue    InlineQueryResultType = "venue"
	InlineQueryResultTypeSticker  InlineQueryResultType = "sticker"
	InlineQueryResultTypeVideo    InlineQueryResultType = "video"
	InlineQueryResultTypeVoice    InlineQueryResultType = "voice"
)

type InlineQueryResultVenue added in v0.10.0

type InlineQueryResultVenue struct {
	InlineQueryResultBase
	Latitude  float64 `json:"latitude"`  // required
	Longitude float64 `json:"longitude"` // required
	Address   string  `json:"address"`   // required
	FoursquareFields
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
	ThumbURL            string      `json:"thumb_url,omitempty"`
	ThumbWidth          int         `json:"thumb_width,omitempty"`
	ThumbHeight         int         `json:"thumb_height,omitempty"`
}

func (InlineQueryResultVenue) Validate added in v0.10.0

func (r InlineQueryResultVenue) Validate() error

type InlineQueryResultVideo

type InlineQueryResultVideo struct {
	InlineQueryResultBase
	URL                 string      `json:"video_url"` // required
	MimeType            string      `json:"mime_type"` // required
	ThumbURL            string      `json:"thumb_url"`
	Caption             string      `json:"caption"`
	Width               int         `json:"video_width"`
	Height              int         `json:"video_height"`
	Duration            int         `json:"video_duration"`
	Description         string      `json:"description"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultVideo is an inline query response video.

func NewInlineQueryResultVideo

func NewInlineQueryResultVideo(id, url, title string) *InlineQueryResultVideo

NewInlineQueryResultVideo creates a new inline query video.

func (InlineQueryResultVideo) Validate added in v0.10.0

func (r InlineQueryResultVideo) Validate() error

type InlineQueryResultVoice

type InlineQueryResultVoice struct {
	InlineQueryResultBase
	URL                 string      `json:"voice_url"` // required
	Duration            int         `json:"voice_duration"`
	InputMessageContent interface{} `json:"input_message_content,omitempty"`
}

InlineQueryResultVoice is an inline query response voice.

func NewInlineQueryResultVoice

func NewInlineQueryResultVoice(id, url, title string) *InlineQueryResultVoice

NewInlineQueryResultVoice creates a new inline query voice.

func (InlineQueryResultVoice) Validate added in v0.10.0

func (r InlineQueryResultVoice) Validate() error

type InlineQueryResultsButton added in v0.10.0

type InlineQueryResultsButton struct {

	// Label text on the button
	Text string `json:"text,omitempty"`

	// Optional. Description of the Web App that will be launched when the user presses the button.
	// The Web App will be able to switch back to the inline mode using the TelegramMethod switchInlineQuery inside the Web App.
	WebApp *WebAppInfo `json:"url,omitempty"`

	// Optional. Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
	//
	// Example: An inline bot that sends YouTube videos can ask the user to connect the bot
	// to their YouTube account to adapt search results accordingly.
	// To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any.
	// The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link.
	// Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
	StartParameter string `json:"start_parameter,omitempty"`
}

InlineQueryResultsButton represents a button to be shown above inline query results. You must use exactly one of the optional fields.

func (InlineQueryResultsButton) Validate added in v0.10.0

func (b InlineQueryResultsButton) Validate() error

type InputContactMessageContent

type InputContactMessageContent struct {

	// Contact's phone number
	PhoneNumber string `json:"phone_number"`

	// Contact's first name
	FirstName string `json:"first_name"`

	// Optional. Contact's last name
	LastName string `json:"last_name"`

	// Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
	VCard string `json:"vcard"`
	// contains filtered or unexported fields
}

InputContactMessageContent contains a contact for displaying as an inline query result.

func (InputContactMessageContent) Validate added in v0.10.0

func (v InputContactMessageContent) Validate() error

type InputLocationMessageContent

type InputLocationMessageContent struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	// contains filtered or unexported fields
}

InputLocationMessageContent contains a location for displaying as an inline query result.

func (InputLocationMessageContent) Validate added in v0.10.0

func (v InputLocationMessageContent) Validate() error

type InputMessageContent added in v0.10.0

type InputMessageContent interface {
	Validate() error
	// contains filtered or unexported methods
}

type InputTextMessageContent

type InputTextMessageContent struct {
	MessageText           string          `json:"message_text"`
	ParseMode             string          `json:"parse_mode"`
	Entities              []MessageEntity `json:"entities"`
	DisableWebPagePreview bool            `json:"disable_web_page_preview"`
	// contains filtered or unexported fields
}

InputTextMessageContent contains text for displaying as an inline query result.

func (InputTextMessageContent) Validate added in v0.10.0

func (v InputTextMessageContent) Validate() error

type InputVenueMessageContent

type InputVenueMessageContent struct {
	Latitude     float64 `json:"latitude"`
	Longitude    float64 `json:"longitude"`
	Title        string  `json:"title"`
	Address      string  `json:"address"`
	FoursquareID string  `json:"foursquare_id"`
	// contains filtered or unexported fields
}

InputVenueMessageContent contains a venue for displaying as an inline query result.

func (InputVenueMessageContent) Validate added in v0.10.0

func (v InputVenueMessageContent) Validate() error

type Invoice added in v0.12.0

type Invoice struct {
	Title          string `json:"title"`           // Product name
	Description    string `json:"description"`     // Product description
	StartParameter string `json:"start_parameter"` // Unique bot deep-linking parameter that can be used to generate this invoice
	Currency       string `json:"currency"`        // Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
	TotalAmount    int    `json:"total_amount"`    // 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, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
}

type InvoiceConfig added in v0.12.0

type InvoiceConfig struct {
	BaseChat
	Title               string         `json:"title"`                           // Product name, 1-32 characters
	Description         string         `json:"description"`                     // Product description, 1-255 characters
	Payload             string         `json:"payload"`                         // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
	ProviderToken       string         `json:"provider_token,omitempty"`        // 	Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
	Currency            string         `json:"currency"`                        // Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
	Prices              []LabeledPrice `json:"prices"`                          // Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
	MaxTipAmount        int64          `json:"max_tip_amount,omitempty"`        // The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
	SuggestedTipAmounts []int64        `json:"suggested_tip_amounts,omitempty"` //A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
	StartParameter      string         `json:"start_parameter,omitempty"`       // Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter
	ProviderData        string         `json:"provider_data,omitempty"`         // JSON-serialized data about the invoice, which will be shared with the Payment provider. A detailed description of required fields should be provided by the Payment provider.
	PhotoURL            string         `json:"photo_url,omitempty"`             // URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
	PhotoSize           int            `json:"photo_size,omitempty"`            // Photo size in bytes
	PhotoWidth          int            `json:"photo_width,omitempty"`           // Photo width
	PhotoHeight         int            `json:"photo_height,omitempty"`          // Photo height
	NeedName            bool           `json:"need_name,omitempty"`             // Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
	NeedPhoneNumber     bool           `json:"need_phone_number,omitempty"`     // Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
	NeedEmail           bool           `json:"need_email,omitempty"`            // Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
	NeedShippingAddress bool           `json:"need_shipping_address,omitempty"` // Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.

	SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"` // Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
	SendEmailToProvider       bool `json:"send_email_to_provider,omitempty"`        // Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
	IsFlexible                bool `json:"is_flexible,omitempty"`                   // Pass True if the final price depends on the shipping BotEndpoint. Ignored for payments in Telegram Stars.
}

func (*InvoiceConfig) TelegramMethod added in v0.12.0

func (*InvoiceConfig) TelegramMethod() string

func (*InvoiceConfig) Values added in v0.12.0

func (v *InvoiceConfig) Values() (url.Values, error)

Values returns url.Values representation of InvoiceConfig.

type Keyboard added in v0.14.0

type Keyboard interface {
	botkb.Keyboard
	// contains filtered or unexported methods
}

type KeyboardButton

type KeyboardButton struct {
	Text            string                      `json:"text"`
	RequestUsers    *KeyboardButtonRequestUsers `json:"request_users,omitempty"`
	RequestChat     *KeyboardButtonRequestChat  `json:"request_chat,omitempty"`
	RequestContact  bool                        `json:"request_contact"`
	RequestLocation bool                        `json:"request_location"`
	RequestPoll     *KeyboardButtonPollType     `json:"request_poll,omitempty"`
	Webapp          *WebAppInfo                 `json:"web_app,omitempty"`
}

KeyboardButton is a button within a custom keyboard.

func NewKeyboardButton

func NewKeyboardButton(text string) KeyboardButton

NewKeyboardButton creates a regular keyboard button.

func NewKeyboardButtonContact

func NewKeyboardButtonContact(text string) KeyboardButton

NewKeyboardButtonContact creates a keyboard button that requests user contact information upon click.

func NewKeyboardButtonLocation

func NewKeyboardButtonLocation(text string) KeyboardButton

NewKeyboardButtonLocation creates a keyboard button that requests user location information upon click.

func NewKeyboardButtonRow

func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton

NewKeyboardButtonRow creates a row of keyboard buttons.

func (*KeyboardButton) Validate added in v0.5.0

func (j *KeyboardButton) Validate() error

Validate checks if the keyboard button is valid

type KeyboardButtonPollType added in v0.5.0

type KeyboardButtonPollType struct {
	// Optional.
	// If quiz is passed, the user will be allowed to create only polls in the quiz mode.
	// If regular is passed, only regular polls will be allowed.
	// Otherwise, the user will be allowed to create a poll of any type.
	Type string `json:"type,omitempty"`
}

KeyboardButtonPollType represents the type of poll to be created https://core.telegram.org/bots/api#keyboardbuttonpolltype

type KeyboardButtonRequestChat added in v0.5.0

type KeyboardButtonRequestChat struct {
	// Signed 32-bit identifier of the request, which will be received back in the ChatShared object.
	// Must be unique within the message
	RequestID int `json:"request_id"`

	// Pass True to request a channel chat, pass False to request a group or a supergroup chat.
	ChatIsChannel bool `json:"chat_is_channel"`

	// Pass True to request a forum supergroup, pass False to request a non-forum chat.
	// If not specified, no additional restrictions are applied.
	ChatIsForum bool `json:"chat_is_forum,omitempty"`

	// Pass True to request a supergroup or a channel with a username,
	// pass False to request a chat without a username.
	// If not specified, no additional restrictions are applied.
	ChatHasUsername bool `json:"chat_has_username,omitempty"`

	// Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.
	ChatIsCreated bool `json:"chat_is_created,omitempty"`

	// A JSON-serialized object listing the required administrator rights of the user in the chat.
	// The rights must be a superset of bot_administrator_rights.
	// If not specified, no additional restrictions are applied.
	UserAdministratorRights *ChatAdministratorRights `json:"user_administrator_rights,omitempty"`

	// A JSON-serialized object listing the required administrator rights of the bot in the chat.
	// The rights must be a subset of user_administrator_rights.
	// If not specified, no additional restrictions are applied.
	BotAdministratorRights *ChatAdministratorRights `json:"bot_administrator_rights,omitempty"`

	// Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.
	BotIsMember bool `json:"bot_is_member,omitempty"`

	// Pass True to request the chat's title
	RequestTitle bool `json:"request_title,omitempty"`

	// Pass True to request the chat's username
	RequestUsername bool `json:"request_username,omitempty"`

	// Pass True to request the chat's photo
	RequestPhoto bool `json:"request_photo,omitempty"`
}

KeyboardButtonRequestChat represents a request from the bot to send a chat https://core.telegram.org/bots/api#keyboardbuttonrequestchat

type KeyboardButtonRequestUsers added in v0.5.0

type KeyboardButtonRequestUsers struct {
	// Signed 32-bit identifier of the request, which will be received back in the ChatShared object.
	// Must be unique within the message
	RequestID int `json:"request_id"`

	// Optional.
	// Pass True to request bots, pass False to request regular users.
	// If not specified, no additional restrictions are applied.
	UserIsBot bool `json:"user_is_bot,omitempty"`

	// Optional.
	// Pass True to request premium users, pass False to request non-premium users.
	// If not specified, no additional restrictions are applied.
	UserIsPremium bool `json:"user_is_premium,omitempty"`

	// Optional. The maximum number of users to be selected; 1-10. Defaults to 1.
	MaxQuantity int `json:"max_quantity,omitempty"`

	// Optional. Pass True to request the users' first and last names
	RequestName bool `json:"request_name,omitempty"`

	// Optional. Pass True to request the users' usernames
	RequestUsername bool `json:"request_username,omitempty"`

	// Optional. Pass True to request the users' photos
	RequestPhoto bool `json:"request_photo,omitempty"`
}

KeyboardButtonRequestUsers represents a request from the bot to send users https://core.telegram.org/bots/api#keyboardbuttonrequestusers

type LabeledPrice added in v0.12.0

type LabeledPrice struct {
	Label  string `json:"label"`  // Portion label
	Amount int    `json:"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, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
}

type LeaveChatConfig

type LeaveChatConfig struct {
	// contains filtered or unexported fields
}

LeaveChatConfig is message command for leaving chat

func (LeaveChatConfig) TelegramMethod added in v0.12.0

func (LeaveChatConfig) TelegramMethod() string

func (LeaveChatConfig) Values

func (v LeaveChatConfig) Values() (url.Values, error)

type LinkPreviewOptions added in v0.10.0

type LinkPreviewOptions struct {

	// Optional. True, if the link preview is disabled.
	IsDisabled bool `json:"is_disabled,omitempty"`

	// Optional. URL to use for the link preview.
	// If empty, then the first URL found in the message text will be used.
	Url string `json:"url,omitempty"`

	// Optional. True, if the media in the link preview is supposed to be shrunk;
	// ignored if the URL isn't explicitly specified or media size change isn't supported for the preview.
	PreferSmallMedia bool `json:"prefer_small_media,omitempty"`

	// Optional. True, if the media in the link preview is supposed to be enlarged;
	// ignored if the URL isn't explicitly specified or media size change isn't supported for the preview.
	PreferLargeMedia bool `json:"prefer_large_media,omitempty"`

	// Optional. True, if the link preview must be shown above the message text;
	// otherwise, the link preview will be shown below the message text
	ShowAboveText bool `json:"show_above_text,omitempty"`
}

LinkPreviewOptions Describes the options used for link preview generation.

type Location

type Location struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

Location contains information about a place.

type LocationConfig

type LocationConfig struct {
	BaseChat
	Latitude  float64 // required
	Longitude float64 // required
}

LocationConfig contains information about a SendLocation request.

func NewLocation

func NewLocation(chatID int64, latitude float64, longitude float64) *LocationConfig

NewLocation shares your location.

chatID is where to send it, latitude and longitude are coordinates.

func (LocationConfig) TelegramMethod added in v0.12.0

func (j LocationConfig) TelegramMethod() string

method returns Telegram API method name for sending Location.

func (LocationConfig) Values

func (j LocationConfig) Values() (url.Values, error)

Values returns url.Values representation of LocationConfig.

type LoginUrl added in v0.6.0

type LoginUrl struct {
	// An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed.
	// If the user refuses to provide authorization data,
	// the original URL without information about the user will be opened.
	// The data added is the same as described in Receiving authorization data.
	Url string `json:"url"`

	// Optional. New text of the button in forwarded messages.
	ForwardText string `json:"forward_text,omitempty"`

	// Optional.
	// Username of a bot, which will be used for user authorization.
	// See Setting up a bot for more details.
	// If not specified, the current bot's username will be assumed.
	// The url's domain must be the same as the domain linked with the bot.
	// See Linking your domain to the bot for more details.
	BotUsername string `json:"bot_username,omitempty"`

	// Optional. Pass True to request the permission for your bot to send messages to the user.
	RequestWriteAccess bool `json:"request_write_access,omitempty"`
}

LoginUrl represents a parameter of the inline keyboard button used to automatically authorize a user. https://core.telegram.org/bots/api#loginurl

func (LoginUrl) Validate added in v0.10.0

func (v LoginUrl) Validate() error

type Message

type Message struct {

	// Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
	MessageID int `json:"message_id"`

	// Optional. Unique identifier of a message thread to which the message belongs; for supergroups only
	MessageThreadID int `json:"message_thread_id"`

	// Optional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats
	From *User `json:"from,omitempty"`

	// Optional. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats.
	SenderChat *Chat `json:"sender_chat,omitempty"`

	// Optional. If the sender of the message boosted the chat, the number of boosts added by the user
	SenderBootCount int `json:"sender_boot_count,omitempty"`

	// Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
	SenderBusinessBot *User `json:"sender_business_bot,omitempty"`

	// Date the message was sent in Unix time. It is always a positive number, representing a valid date.
	Date int `json:"date"`

	// Optional. Unique identifier of the business connection from which the message was received.
	// If non-empty, the message belongs to a chat of the corresponding business account
	// that is independent from any potential bot chat which might share the same identifier.
	BusinessConnectionID string `json:"business_connection_id,omitempty"`

	// Chat the message belongs to
	Chat *Chat `json:"chat,omitempty"`

	// Optional. Information about the original message for forwarded messages
	ForwardOrigin *MessageOrigin `json:"forward_origin,omitempty"`

	// Optional. True, if the message is sent to a forum topic
	IsTopicMessage bool `json:"is_topic_message,omitempty"`

	// Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
	IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`

	UserShared            *UserShared      `json:"user_shared,omitempty"`             // optional NON-DOCUMENTED FIELD
	UsersShared           *UsersShared     `json:"users_shared,omitempty"`            // optional
	ForwardFrom           *User            `json:"forward_from,omitempty"`            // optional
	ForwardDate           int              `json:"forward_date,omitempty"`            // optional
	ReplyToMessage        *Message         `json:"reply_to_message,omitempty"`        // optional
	Text                  string           `json:"text,omitempty"`                    // optional
	Entities              *[]MessageEntity `json:"entities,omitempty"`                // optional
	Audio                 *Audio           `json:"audio,omitempty"`                   // optional
	Document              *Document        `json:"document,omitempty"`                // optional
	Photo                 *[]PhotoSize     `json:"photo,omitempty"`                   // optional
	Sticker               *Sticker         `json:"sticker,omitempty"`                 // optional
	Video                 *Video           `json:"video,omitempty"`                   // optional
	Voice                 *Voice           `json:"voice,omitempty"`                   // optional
	Caption               string           `json:"caption,omitempty"`                 // optional
	Contact               *Contact         `json:"contact,omitempty"`                 // optional
	Location              *Location        `json:"location,omitempty"`                // optional
	Venue                 *Venue           `json:"venue,omitempty"`                   // optional
	NewChatParticipant    *ChatMember      `json:"new_chat_participant,omitempty"`    // Obsolete
	NewChatMember         *ChatMember      `json:"new_chat_member,omitempty"`         // Obsolete
	NewChatMembers        []ChatMember     `json:"new_chat_members,omitempty"`        // optional
	LeftChatMember        *ChatMember      `json:"left_chat_member,omitempty"`        // optional
	NewChatTitle          string           `json:"new_chat_title,omitempty"`          // optional
	NewChatPhoto          *[]PhotoSize     `json:"new_chat_photo,omitempty"`          // optional
	DeleteChatPhoto       bool             `json:"delete_chat_photo,omitempty"`       // optional
	GroupChatCreated      bool             `json:"group_chat_created,omitempty"`      // optional
	SuperGroupChatCreated bool             `json:"supergroup_chat_created,omitempty"` // optional
	ChannelChatCreated    bool             `json:"channel_chat_created,omitempty"`    // optional
	MigrateToChatID       int64            `json:"migrate_to_chat_id,omitempty"`      // optional
	MigrateFromChatID     int64            `json:"migrate_from_chat_id,omitempty"`    // optional
	PinnedMessage         *Message         `json:"pinned_message,omitempty"`          // optional

	// Optional. Message is an invoice for a Payment, information about the invoice.
	// https://core.telegram.org/bots/api#payments
	Invoice *InvoiceConfig `json:"invoice"`

	// Optional. Bot through which the message was sent
	ViaBot *User `json:"via_bot"`

	SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"` // optional
	RefundedPayment   *RefundedPayment   `json:"refunded_payment,omitempty"`   //	optional

	ChatShared *ChatShared `json:"chat_shared,omitempty"`

	Gift       *GiftInfo       `json:"gift,omitempty"`
	UniqueGift *UniqueGiftInfo `json:"unique_gift,omitempty"`
}

Message is returned by almost every request and contains data about almost anything.

func (*Message) Command

func (m *Message) Command() string

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 bot syntax, it removes the bot name.

func (*Message) CommandArguments

func (m *Message) CommandArguments() string

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.

func (*Message) GetMessageID added in v0.14.0

func (m *Message) GetMessageID() string

func (*Message) IsCommand

func (m *Message) IsCommand() bool

IsCommand returns true if message starts with '/'.

func (*Message) Time

func (m *Message) Time() time.Time

Time converts the message timestamp into a Time.

type MessageConfig

type MessageConfig struct {
	BaseChat
	Text                  string
	ParseMode             string `json:"parse_mode,omitempty"`
	DisableWebPagePreview bool   `json:"disable_web_page_preview,omitempty"`
}

MessageConfig contains information about a SendMessage request.

func NewMessage

func NewMessage(chatID int64, text string) *MessageConfig

NewMessage creates a new Message.

chatID is where to send it, text is the message text.

func NewMessageToChannel

func NewMessageToChannel(username string, text string) *MessageConfig

NewMessageToChannel creates a new Message that is sent to a channel by username. username is the username of the channel, text is the message text.

func (MessageConfig) TelegramMethod added in v0.12.0

func (v MessageConfig) TelegramMethod() string

method returns Telegram API method name for sending Message.

func (MessageConfig) Values

func (v MessageConfig) Values() (url.Values, error)

Values returns url.Values representation of MessageConfig.

type MessageEntity

type MessageEntity struct {
	Type   string `json:"type"`
	Offset int    `json:"offset"`
	Length int    `json:"length"`
	URL    string `json:"url,omitempty"` // optional
}

MessageEntity contains information about data in a Message.

func (*MessageEntity) ParseURL

func (entity *MessageEntity) ParseURL() (*url.URL, error)

ParseURL attempts to parse a URL contained within a MessageEntity.

func (*MessageEntity) Validate added in v0.10.0

func (entity *MessageEntity) Validate() error

type MessageOrigin added in v0.12.0

type MessageOrigin interface {
	MessageOriginType() MessageOriginType
}

type MessageOriginChannel added in v0.12.0

type MessageOriginChannel struct {

	// Channel chat to which the message was originally sent
	Chat Chat `json:"chat"`

	// Unique message identifier inside the chat
	MessageID int `json:"message_id"`

	// Optional. For messages originally sent by an anonymous chat administrator, original message author signature
	AuthorSignature string `json:"author_signature,omitempty"`
	// contains filtered or unexported fields
}

type MessageOriginChat added in v0.12.0

type MessageOriginChat struct {

	// Chat that sent the message originally
	SenderChat Chat `json:"sender_chat"`
	// Optional. For messages originally sent by an anonymous chat administrator, original message author signature
	AuthorSignature string `json:"author_signature,omitempty"`
	// contains filtered or unexported fields
}

type MessageOriginHiddenUser added in v0.12.0

type MessageOriginHiddenUser struct {

	// Name of the user that sent the message originally
	SenderUserName string `json:"sender_user_name"`
	// contains filtered or unexported fields
}

func (MessageOriginHiddenUser) MessageOriginType added in v0.12.0

func (MessageOriginHiddenUser) MessageOriginType() MessageOriginType

type MessageOriginType added in v0.12.0

type MessageOriginType string
const (
	MessageOriginTypeUser       MessageOriginType = "user"
	MessageOriginTypeHiddenUser MessageOriginType = "hidden_user"
)

type MessageOriginUser added in v0.12.0

type MessageOriginUser struct {

	// User that sent the message originally
	SenderUser *User `json:"sender_user,omitempty"`
	// contains filtered or unexported fields
}

func (MessageOriginUser) MessageOriginType added in v0.12.0

func (MessageOriginUser) MessageOriginType() MessageOriginType

type MyCommandsBase added in v0.12.0

type MyCommandsBase struct {
	// Optional. A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
	Scope *BotCommandScope `json:"scope,omitempty"`

	// Optional. A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
	LanguageCode string `json:"language_code,omitempty"`
}

func (MyCommandsBase) Validate added in v0.12.0

func (s MyCommandsBase) Validate() error

func (MyCommandsBase) Values added in v0.12.0

func (s MyCommandsBase) Values() (values url.Values, err error)

type OrderInfo added in v0.12.0

type OrderInfo struct {
	Name            string           `json:"name,omitempty"`             // Optional. User name
	PhoneNumber     string           `json:"phone_number,omitempty"`     // Optional. User's phone number
	Email           string           `json:"email,omitempty"`            // Optional. User email
	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` // Optional. User shipping address
}

OrderInfo represents information about an order.

type OwnedGift added in v0.12.0

type OwnedGift interface {
	GetType() OwnedGiftType
	GetOwnedGiftID() string
	GetSenderUser() *User
	GetSendDate() int
	GetIsSaved() bool
}

type OwnedGiftRegular added in v0.12.0

type OwnedGiftRegular struct {
	Text                    string          `json:"text,omitempty"`                       // Optional. Text of the message that was added to the gift
	Entities                []MessageEntity `json:"entities,omitempty"`                   // Optional. Special entities that appear in the text
	IsPrivate               bool            `json:"is_private,omitempty"`                 // Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them
	CanBeUpgraded           bool            `json:"can_be_upgraded,omitempty"`            // Optional. True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only
	WasRefunded             bool            `json:"was_refunded,omitempty"`               // Optional. True, if the gift was refunded and isn't available anymore
	ConvertStarCount        int             `json:"convert_star_count,omitempty"`         // Optional. Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars
	PrepaidUpgradeStarCount int             `json:"prepaid_upgrade_star_count,omitempty"` // Optional. Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift
	// contains filtered or unexported fields
}

OwnedGiftRegular https://core.telegram.org/bots/api#ownedgiftregular

func (*OwnedGiftRegular) GetIsSaved added in v0.12.0

func (v *OwnedGiftRegular) GetIsSaved() bool

func (*OwnedGiftRegular) GetOwnedGiftID added in v0.12.0

func (v *OwnedGiftRegular) GetOwnedGiftID() string

func (*OwnedGiftRegular) GetSendDate added in v0.12.0

func (v *OwnedGiftRegular) GetSendDate() int

func (*OwnedGiftRegular) GetSenderUser added in v0.12.0

func (v *OwnedGiftRegular) GetSenderUser() *User

func (*OwnedGiftRegular) GetType added in v0.12.0

func (*OwnedGiftRegular) GetType() OwnedGiftType

type OwnedGiftType added in v0.12.0

type OwnedGiftType string

type OwnedGiftUnique added in v0.12.0

type OwnedGiftUnique struct {
	// contains filtered or unexported fields
}

OwnedGiftUnique https://core.telegram.org/bots/api#ownedgiftunique

func (*OwnedGiftUnique) GetIsSaved added in v0.12.0

func (v *OwnedGiftUnique) GetIsSaved() bool

func (*OwnedGiftUnique) GetOwnedGiftID added in v0.12.0

func (v *OwnedGiftUnique) GetOwnedGiftID() string

func (*OwnedGiftUnique) GetSendDate added in v0.12.0

func (v *OwnedGiftUnique) GetSendDate() int

func (*OwnedGiftUnique) GetSenderUser added in v0.12.0

func (v *OwnedGiftUnique) GetSenderUser() *User

func (*OwnedGiftUnique) GetType added in v0.12.0

func (*OwnedGiftUnique) GetType() OwnedGiftType

type OwnedGifts added in v0.12.0

type OwnedGifts struct {
	TotalCount int         `json:"total_count"`           // The total number of gifts owned by the user or the chat
	Gifts      []OwnedGift `json:"gifts"`                 // The list of gifts
	NextOffset string      `json:"next_offset,omitempty"` // Optional. Offset for the next request. If empty, then there are no more results
}

type Payment added in v0.12.0

type Payment struct {
	// Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
	Currency string `json:"currency"`

	// 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, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
	TotalAmount int `json:"total_amount"`

	// Bot-specified invoice payload
	InvoicePayload string `json:"invoice_payload"`

	// Telegram Payment identifier
	TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`

	// Provider Payment identifier
	ProviderPaymentChargeID string `json:"provider_payment_charge_id,omitempty"`
}

Payment due to limitations of FFJSON can't be unexported.

type Photo added in v0.13.0

type Photo interface {
	PhotoType() PhotoType
}

type PhotoConfig

type PhotoConfig struct {
	BaseChat

	// Photo should be PhotoUrl, FileID or InputFile
	Photo                 Photo  `json:"photo"`
	Caption               string `json:"caption,omitempty"`
	ParseMode             string `json:"parse_mode,omitempty"`
	ShowCaptionAboveMedia bool   `json:"show_caption_above_media,omitempty"`
	HasSpoiler            bool   `json:"has_spoiler,omitempty"`
}

PhotoConfig contains information about a SendPhoto request.

func NewPhotoShare

func NewPhotoShare(chatID int64, fileID FileID) *PhotoConfig

NewPhotoShare shares an existing photo. You may use this to reshare an existing photo without reuploading it.

chatID is where to send it, fileID is the ID of the file already uploaded.

func NewPhotoUpload

func NewPhotoUpload(chatID int64, file interface{}) *PhotoConfig

NewPhotoUpload creates a new photo uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

Note that you must send animated GIFs as a document.

func (PhotoConfig) TelegramMethod added in v0.12.0

func (PhotoConfig) TelegramMethod() string

TelegramMethod returns Telegram API method name for sending Photo.

func (PhotoConfig) Values

func (v PhotoConfig) Values() (url.Values, error)

Values returns url.Values representation of PhotoConfig.

type PhotoSize

type PhotoSize struct {
	// Identifier for this file, which can be used to download or reuse the file
	FileID string `json:"file_id"`

	// 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,omitempty"` // optional

	Width    int `json:"width,omitempty"`     // Photo width
	Height   int `json:"height,omitempty"`    // Photo height
	FileSize int `json:"file_size,omitempty"` // Optional. File size in bytes
}

PhotoSize contains information about photos.

func (*PhotoSize) String added in v0.8.1

func (v *PhotoSize) String() string

type PhotoType added in v0.13.0

type PhotoType int
const (
	PhotoTypeInputFile PhotoType = 1
	PhotoTypeFileID    PhotoType = 2
	PhotoTypeUrl       PhotoType = 3
)

type PhotoUrl added in v0.13.0

type PhotoUrl string

func (PhotoUrl) PhotoType added in v0.13.0

func (PhotoUrl) PhotoType() PhotoType

type PreCheckoutQuery added in v0.12.0

type PreCheckoutQuery struct {
	ID               string     `json:"id"`                           // Unique query identifier
	From             *User      `json:"from"`                         // User who sent the query
	Currency         string     `json:"currency"`                     // Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
	TotalAmount      int        `json:"total_amount"`                 // 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, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
	InvoicePayload   string     `json:"invoice_payload"`              // Bot-specified invoice payload
	ShippingOptionID string     `json:"shipping_option_id,omitempty"` // Optional. Identifier of the shipping option chosen by the user
	OrderInfo        *OrderInfo `json:"order_info,omitempty"`         // Optional. Order information provided by the user
}

PreCheckoutQuery contains information about an incoming pre-checkout query. https://core.telegram.org/bots/api#precheckoutquery

type RefundedPayment added in v0.12.0

type RefundedPayment struct {
	Payment
}

RefundedPayment contains basic information about a refunded Payment. https://core.telegram.org/bots/api#refundedpayment

type ReplyKeyboardHide

type ReplyKeyboardHide struct {
	HideKeyboard bool `json:"hide_keyboard"`
	Selective    bool `json:"selective,omitempty"` // optional
}

ReplyKeyboardHide allows the Bot to hide a custom keyboard.

func NewHideKeyboard

func NewHideKeyboard(selective bool) *ReplyKeyboardHide

NewHideKeyboard hides the keyboard, with the option for being selective or hiding for everyone.

func (*ReplyKeyboardHide) KeyboardType

func (*ReplyKeyboardHide) KeyboardType() botkb.KeyboardType

KeyboardType returns KeyboardTypeHide

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	// Array of button rows, each represented by an Array of KeyboardButton objects
	Keyboard [][]KeyboardButton `json:"keyboard"`

	// Optional. Requests clients to always show the keyboard when the regular keyboard is hidden.
	// Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.
	IsPersistent bool `json:"is_persistent,omitempty"`

	// Optional. 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.
	ResizeKeyboard bool `json:"resize_keyboard,omitempty"` // optional

	// Optional. 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.
	OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"` // optional

	// Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters
	InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`

	// Optional. 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 to a message in the same chat and forum topic, 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.
	Selective bool `json:"selective,omitempty"` // optional
}

ReplyKeyboardMarkup allows the Bot to set a custom keyboard.

func NewReplyKeyboard

func NewReplyKeyboard(rows ...[]KeyboardButton) *ReplyKeyboardMarkup

NewReplyKeyboard creates a new regular keyboard with sane defaults.

func NewReplyKeyboardUsingStrings

func NewReplyKeyboardUsingStrings(buttons [][]string) *ReplyKeyboardMarkup

NewReplyKeyboardUsingStrings creates reply keyboard from strings arrays

func (*ReplyKeyboardMarkup) KeyboardType

func (*ReplyKeyboardMarkup) KeyboardType() botkb.KeyboardType

KeyboardType returns KeyboardTypeBottom

type ReplyParameters added in v0.12.0

type ReplyParameters struct {
	MessageID int64 `json:"message_id"`

	// Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account.
	ChatIDInt int64
	ChatIDStr string

	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply,omitempty"` // Optional. Pass True if the message should be sent even if the specified message to be replied to is not found. Always False for replies in another chat or forum topic. Always True for messages sent on behalf of a business account.
	Quote                    string          `json:"quote,omitempty"`                       // Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn't found in the original message.
	QuoteParseMode           string          `json:"quote_parse_mode,omitempty"`            // Optional. Mode for parsing entities in the quote. See formatting options for more details.
	QuoteEntities            []MessageEntity `json:"quote_entities,omitempty"`              // Optional. A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode.
	QuotePosition            int64           `json:"quote_position,omitempty"`              // Optional. Position of the quote in the original message in UTF-16 code units

}

ReplyParameters describes reply parameters for the message that is being sent.

type Sendable added in v0.12.0

type Sendable interface {
	WithValues
	TelegramMethod() string
}

Sendable is any config type that can be sent to an endpoint returned by BotEndpoint().

type SetMyCommandsConfig added in v0.12.0

type SetMyCommandsConfig struct {
	MyCommandsBase

	// A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
	Commands []TelegramBotCommand `json:"commands"`
}

func (SetMyCommandsConfig) TelegramMethod added in v0.12.0

func (s SetMyCommandsConfig) TelegramMethod() string

func (SetMyCommandsConfig) Validate added in v0.12.0

func (s SetMyCommandsConfig) Validate() error

func (SetMyCommandsConfig) Values added in v0.12.0

func (s SetMyCommandsConfig) Values() (values url.Values, err error)

type SetMyDescription added in v0.12.0

type SetMyDescription struct {
	//  New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
	Description string `json:"description"`

	// Optional. A two-letter ISO 639-1 language code.
	// If empty, the description will be applied to all users for whose language there is no dedicated description.
	LanguageCode string `json:"language_code,omitempty"`
}

SetMyDescription - Use this BotEndpoint to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. https://core.telegram.org/bots/api#setmydescription

func (SetMyDescription) TelegramMethod added in v0.12.0

func (s SetMyDescription) TelegramMethod() string

func (SetMyDescription) Validate added in v0.12.0

func (s SetMyDescription) Validate() error

func (SetMyDescription) Values added in v0.12.0

func (s SetMyDescription) Values() (values url.Values, err error)

type SetMyShortDescription added in v0.12.0

type SetMyShortDescription struct {
	// New short description for the bot; 0-120 characters.
	//Pass an empty string to remove the dedicated short description for the given language.
	ShortDescription string `json:"short_description"`

	// Optional. A two-letter ISO 639-1 language code.
	// If empty, the short description will be applied to all users for whose language there is no dedicated short description.
	LanguageCode string `json:"language_code,omitempty"`
}

SetMyShortDescription - Use this BotEndpoint to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. https://core.telegram.org/bots/api#setmyshortdescription

func (SetMyShortDescription) TelegramMethod added in v0.12.0

func (s SetMyShortDescription) TelegramMethod() string

func (SetMyShortDescription) Validate added in v0.12.0

func (s SetMyShortDescription) Validate() error

func (SetMyShortDescription) Values added in v0.12.0

func (s SetMyShortDescription) Values() (values url.Values, err error)

type SharedUser added in v0.8.0

type SharedUser struct {
	UserID int `json:"user_id"`

	// Optional. First name of the user, if the name was requested by the bot
	FirstName string `json:"first_name,omitempty"`

	// Optional. Last name of the user, if the name was requested by the bot
	LastName string `json:"last_name,omitempty"`

	// Optional. Username of the user, if the name was requested by the bot
	Username string `json:"username,omitempty"`

	Photo []PhotoSize `json:"photo,omitempty"`
}

SharedUser contains information about a user that was shared with the bot using a KeyboardButtonRequestUsers button. https://core.telegram.org/bots/api#shareduser

type ShippingAddress added in v0.12.0

type ShippingAddress struct {
	CountryCode string `json:"country_code"`    // Two-letter ISO 3166-1 alpha-2 country code
	State       string `json:"state,omitempty"` // State, if applicable
	City        string `json:"city"`
	StreetLine1 string `json:"street_line1"` // First line for the address
	StreetLine2 string `json:"street_line2"` // Second line for the address
	PostCode    string `json:"post_code"`    // Address post code
}

type Sticker

type Sticker struct {
	FileID    string     `json:"file_id"`
	Width     int        `json:"width"`
	Height    int        `json:"height"`
	Thumbnail *PhotoSize `json:"thumb,omitempty"`     // optional
	FileSize  int        `json:"file_size,omitempty"` // optional
}

Sticker contains information about a sticker.

type StickerConfig

type StickerConfig struct {
	BaseFile
}

StickerConfig contains information about a SendSticker request.

func NewStickerShare

func NewStickerShare(chatID int64, fileID string) *StickerConfig

NewStickerShare shares an existing sticker. You may use this to reshare an existing sticker without reuploading it.

chatID is where to send it, fileID is the ID of the sticker already uploaded.

func NewStickerUpload

func NewStickerUpload(chatID int64, file interface{}) *StickerConfig

NewStickerUpload creates a new sticker uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

func (StickerConfig) TelegramMethod added in v0.12.0

func (v StickerConfig) TelegramMethod() string

method returns Telegram API method name for sending Sticker.

func (StickerConfig) Values

func (v StickerConfig) Values() (url.Values, error)

Values returns url.Values representation of StickerConfig.

type SuccessfulPayment added in v0.12.0

type SuccessfulPayment struct {
	Payment

	// Optional. Expiration date of the subscription, in Unix time; for recurring payments only
	SubscriptionExpirationDate int64 `json:"subscription_expiration_date"`

	// Optional. True, if the Payment is a recurring Payment for a subscription
	IsRecurring bool `json:"is_recurring,omitempty"`

	// Optional. True, if the Payment is the first Payment for a subscription
	IsFirstRecurring bool `json:"is_first_recurring,omitempty"`

	// Optional. Identifier of the shipping option chosen by the user
	ShippingOptionID string `json:"shipping_option_id,omitempty"`

	// Optional. Order information provided by the user
	OrderInfo *OrderInfo `json:"order_info,omitempty"`
}

type SwitchInlineQueryChosenChat added in v0.6.0

type SwitchInlineQueryChosenChat struct {
	// Optional.
	//The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted
	Query string `json:"query,omitempty"`

	// Optional. True, if private chats with users can be chosen
	AllowUserChats bool `json:"allow_user_chats,omitempty"`

	// Optional. True, if private chats with bots can be chosen
	AllowBotChats bool `json:"allow_bot_chats,omitempty"`

	// Optional. True, if group and supergroup chats can be chosen
	AllowGroupChats bool `json:"allow_group_chats,omitempty"`

	// Optional. True, if channel chats can be chosen
	AllowChannelChats bool `json:"allow_channel_chats,omitempty"`
}

SwitchInlineQueryChosenChat represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. Documentation: https://core.telegram.org/bots/api#switchinlinequerychosenchat

func (SwitchInlineQueryChosenChat) Validate added in v0.10.0

func (v SwitchInlineQueryChosenChat) Validate() error

type TelegramBotCommand added in v0.12.0

type TelegramBotCommand struct {
	Command     string `json:"command"`     // Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
	Description string `json:"description"` // Description of the command; 1-256 characters.
}

func (TelegramBotCommand) Validate added in v0.12.0

func (v TelegramBotCommand) Validate() error

type UniqueGift added in v0.12.0

type UniqueGift struct {
	BaseName string             `json:"base_name"` // Human-readable name of the regular gift from which this unique gift was upgraded
	Name     string             `json:"name"`      // Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas
	Number   int                `json:"number"`    // Unique number of the upgraded gift among gifts upgraded from the same regular gift
	Model    UniqueGiftModel    `json:"model"`     // Model of the gift
	Symbol   UniqueGiftSymbol   `json:"symbol"`    // Symbol of the gift
	Backdrop UniqueGiftBackdrop `json:"backdrop"`  // Backdrop of the gift
}

UniqueGift https://core.telegram.org/bots/api#uniquegift

type UniqueGiftBackdrop added in v0.12.0

type UniqueGiftBackdrop struct {
	Name   string                   `json:"name"` // Name of the backdrop
	Colors UniqueGiftBackdropColors // Colors of the backdrop

	// The number of unique gifts that receive this backdrop for every 1000 gifts upgraded
	RarityPerMille int `json:"rarity_per_mille,omitempty"`
}

UniqueGiftBackdrop https://core.telegram.org/bots/api#uniquegiftbackdrop

type UniqueGiftBackdropColors added in v0.12.0

type UniqueGiftBackdropColors struct {
	CenterColor int `json:"center_color"` // The color in the center of the backdrop in RGB format
	EdgeColor   int `json:"edge_color"`   // The color on the edges of the backdrop in RGB format
	SymbolColor int `json:"symbol_color"` // The color to be applied to the symbol in RGB format
	TextColor   int `json:"text_color"`   // The color for the text on the backdrop in RGB format
}

UniqueGiftBackdropColors https://core.telegram.org/bots/api#uniquegiftbackdropcolors

type UniqueGiftInfo added in v0.12.0

type UniqueGiftInfo struct {
	Gift UniqueGift `json:"gift"` // Information about the gift

	// Origin of the gift. Currently, either “upgrade” or “transfer”
	Origin GiftOrigin `json:"origin,omitempty"`

	// Optional. Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts
	OwnedGiftID string `json:"owned_gift_id,omitempty"`

	// Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift
	TransferStarCount int `json:"transfer_star_count,omitempty"`
}

type UniqueGiftModel added in v0.12.0

type UniqueGiftModel struct {
	Name           string  `json:"name"`             // Name of the model
	Sticker        Sticker `json:"sticker"`          // The sticker that represents the unique gift
	RarityPerMille int     `json:"rarity_per_mille"` // The number of unique gifts that receive this model for every 1000 gifts upgraded
}

UniqueGiftModel https://core.telegram.org/bots/api#uniquegiftmodel

type UniqueGiftSymbol added in v0.12.0

type UniqueGiftSymbol struct {
	Name           string  `json:"name"`             // Name of the symbol
	Sticker        Sticker `json:"sticker"`          // The sticker that represents the unique gift
	RarityPerMille int     `json:"rarity_per_mille"` // The number of unique gifts that receive this model for every 1000 gifts upgraded
}

UniqueGiftSymbol https://core.telegram.org/bots/api#uniquegiftsymbol

type Update

type Update struct {
	UpdateID           int                 `json:"update_id"`
	Message            *Message            `json:"message,omitempty"`
	EditedMessage      *Message            `json:"edited_message,omitempty"`
	ChannelPost        *Message            `json:"channel_post,omitempty"`
	EditedChannelPost  *Message            `json:"edited_channel_post,omitempty"`
	InlineQuery        *InlineQuery        `json:"inline_query,omitempty"`
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
	CallbackQuery      *CallbackQuery      `json:"callback_query,omitempty"`
	PreCheckoutQuery   *PreCheckoutQuery   `json:"pre_checkout_query,omitempty"`
}

Update is an update response, from GetUpdates.

func (Update) Chat

func (update Update) Chat() *Chat

Chat provides chat struct for the update

type UpdateConfig

type UpdateConfig struct {
	Offset  int
	Limit   int
	Timeout int
}

UpdateConfig contains information about a GetUpdates request.

func NewUpdate

func NewUpdate(offset int) *UpdateConfig

NewUpdate gets updates since the last Offset.

offset is the last Update ID to include. You likely want to set this to the last Update ID plus 1.

type User

type User struct {
	ID           int    `json:"id"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`     // optional
	UserName     string `json:"username,omitempty"`      // optional
	LanguageCode string `json:"language_code,omitempty"` // optional
}

User is a user on Telegram.

func (User) GetFirstName

func (u User) GetFirstName() string

GetFirstName returns first name of the user

func (User) GetFullName

func (u User) GetFullName() string

GetFullName returns full name of the user

func (User) GetID

func (u User) GetID() interface{}

GetID returns Telegram user ID

func (User) GetLanguage

func (u User) GetLanguage() string

GetLanguage returns preferred language of the user

func (User) GetLastName

func (u User) GetLastName() string

GetLastName returns last name of the user

func (User) GetUserName

func (u User) GetUserName() string

GetUserName returns user name of the user

func (User) Platform

func (u User) Platform() string

Platform returns 'Telegram'

func (*User) String

func (u *User) String() string

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.

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int           `json:"total_count"`
	Photos     [][]PhotoSize `json:"photos"`
}

UserProfilePhotos contains a set of user profile photos.

type UserProfilePhotosConfig

type UserProfilePhotosConfig struct {
	UserID int
	Offset int
	Limit  int
}

UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.

func NewUserProfilePhotos

func NewUserProfilePhotos(userID int) *UserProfilePhotosConfig

NewUserProfilePhotos gets user profile photos.

userID is the ID of the user you wish to get profile photos from.

type UserShared added in v0.8.2

type UserShared struct {
	UserID    int `json:"userID"`
	RequestID int `json:"request_id"`
}

UserShared is a NON-DOCUMENTED TELEGRAM MESSAGE FIELD

type UsersShared added in v0.8.0

type UsersShared struct {
	RequestID int          `json:"request_id"`
	UserIDs   []int        `json:"user_ids"`
	Users     []SharedUser `json:"users"`
}

UsersShared contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button. https://core.telegram.org/bots/api#usersshared

type Venue

type Venue struct {
	Location     Location `json:"location"`
	Title        string   `json:"title"`
	Address      string   `json:"address"`
	FoursquareID string   `json:"foursquare_id,omitempty"` // optional
}

Venue contains information about a venue, including its Location.

type VenueConfig

type VenueConfig struct {
	BaseChat
	Latitude     float64 // required
	Longitude    float64 // required
	Title        string  // required
	Address      string  // required
	FoursquareID string
}

VenueConfig contains information about a SendVenue request.

func NewVenue

func NewVenue(chatID int64, title, address string, latitude, longitude float64) *VenueConfig

NewVenue allows you to send a venue and its location.

func (VenueConfig) TelegramMethod added in v0.12.0

func (v VenueConfig) TelegramMethod() string

func (VenueConfig) Values

func (v VenueConfig) Values() (url.Values, error)

Values returns URL values representation of VenueConfig

type Video

type Video struct {
	FileID    string     `json:"file_id"`
	Width     int        `json:"width"`
	Height    int        `json:"height"`
	Duration  int        `json:"duration"`
	Thumbnail *PhotoSize `json:"thumb,omitempty"`     // optional
	MimeType  string     `json:"mime_type,omitempty"` // optional
	FileSize  int        `json:"file_size,omitempty"` // optional
}

Video contains information about a video.

type VideoConfig

type VideoConfig struct {
	BaseFile
	Duration int
	Caption  string
}

VideoConfig contains information about a SendVideo request.

func NewVideoShare

func NewVideoShare(chatID int64, fileID string) *VideoConfig

NewVideoShare shares an existing video. You may use this to reshare an existing video without reuploading it.

chatID is where to send it, fileID is the ID of the video already uploaded.

func NewVideoUpload

func NewVideoUpload(chatID int64, file interface{}) *VideoConfig

NewVideoUpload creates a new video uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

func (VideoConfig) TelegramMethod added in v0.12.0

func (v VideoConfig) TelegramMethod() string

method returns Telegram API method name for sending Video.

func (VideoConfig) Values

func (v VideoConfig) Values() (url.Values, error)

Values returns a url.Values representation of VideoConfig.

type Voice

type Voice struct {
	FileID   string `json:"file_id"`
	Duration int    `json:"duration"`
	MimeType string `json:"mime_type,omitempty"` // optional
	FileSize int    `json:"file_size,omitempty"` // optional
}

Voice contains information about a voice.

type VoiceConfig

type VoiceConfig struct {
	BaseFile
	Duration int
}

VoiceConfig contains information about a SendVoice request.

func NewVoiceShare

func NewVoiceShare(chatID int64, fileID string) *VoiceConfig

NewVoiceShare shares an existing voice. You may use this to reshare an existing voice without reuploading it.

chatID is where to send it, fileID is the ID of the video already uploaded.

func NewVoiceUpload

func NewVoiceUpload(chatID int64, file interface{}) *VoiceConfig

NewVoiceUpload creates a new voice uploader.

chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.

func (VoiceConfig) TelegramMethod added in v0.12.0

func (v VoiceConfig) TelegramMethod() string

method returns Telegram API method name for sending Voice.

func (VoiceConfig) Values

func (v VoiceConfig) Values() (url.Values, error)

Values returns a url.Values representation of VoiceConfig.

type WebAppInfo added in v0.10.0

type WebAppInfo struct {

	// An HTTPS URL of a Web App to be opened with additional data
	// as specified in https://core.telegram.org/bots/webapps#initializing-mini-apps
	Url string `json:"url"`
}

WebAppInfo represents a web app to be opened with the button https://core.telegram.org/bots/api#webappinfo

func (WebAppInfo) Validate added in v0.10.0

func (v WebAppInfo) Validate() error

type WebhookConfig

type WebhookConfig struct {

	// URL - HTTPS url to send updates to. Use an empty string to remove webhook integration
	URL *url.URL `json:"url"` // REQUIRED!

	// Certificate - 	Upload your public key certificate so that the root certificate in use can be checked.
	// See https://core.telegram.org/bots/self-signed guide for details.
	Certificate interface{} `json:"certificate,omitempty"`

	// IPAddress - The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
	IPAddress string `json:"ip_address,omitempty"`

	// MaxConnections - 	The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100.
	// Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
	MaxConnections int `json:"max_connections,omitempty"`

	// AllowedUpdates - Optional
	// A JSON-serialized list of the update types you want your bot to receive.
	// For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types.
	// See Update for a complete list of available update types.
	// Specify an empty list to receive all update types except:
	//	 chat_member, message_reaction, and message_reaction_count (default).
	// If not specified, the previous setting will be used.
	// Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
	AllowedUpdates []string `json:"allowed_updates,omitempty"`

	// DropPendingUpdates - Pass True to drop all pending updates
	DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`

	// SecretToken - A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
	// Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.
	SecretToken string `json:"secret_token,omitempty"`
}

WebhookConfig contains information about a SetWebhook request.

func NewWebhook

func NewWebhook(link string) *WebhookConfig

NewWebhook creates a new webhook.

link is the url parsable link you wish to get the updates.

Example
bot := NewBotAPI("MyAwesomeBotToken")

log.Printf("Authorized on account %s", bot.Self.UserName)

_, err := bot.SetWebhook(*NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem"))
if err != nil {
	log.Fatal(err)
}

updates := bot.ListenForWebhook("/" + bot.Token)
go func() {
	err := http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)
	if err != nil {
		log.Fatal(err)
	}
}()

for update := range updates {
	log.Printf("%+v\n", update)
}

func NewWebhookWithCert

func NewWebhookWithCert(link string, file interface{}) *WebhookConfig

NewWebhookWithCert creates a new webhook with a certificate.

link is the url you wish to get webhooks, file contains a string to a file, FileReader, or FileBytes.

func (WebhookConfig) Validate added in v0.2.0

func (j WebhookConfig) Validate() error

Validate returns an error if the WebhookConfig struct is invalid.

func (WebhookConfig) Values added in v0.2.0

func (j WebhookConfig) Values() (url.Values, error)

Values returns url.Values representation of WebhookConfig.

type WithValues added in v0.12.0

type WithValues interface {
	Values() (values url.Values, err error)
}

type WriteAccessAllowed added in v0.12.0

type WriteAccessAllowed struct {
	// Optional. True, if the access was granted after the user accepted an explicit request
	// from a Web App sent by the TelegramMethod requestWriteAccess
	FromRequest bool `json:"from_request,omitempty"`

	// Optional. Name of the Web App, if the access was granted when the Web App was launched from a link
	WebAppName string `json:"web_app_name,omitempty"`

	// Optional. True, if the access was granted when the bot was added to the attachment or side menu
	FromAttachmentMenu bool `json:"from_attachment_menu,omitempty"`
}

WriteAccessAllowed https://core.telegram.org/bots/api#writeaccessallowed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL