tgbotapi

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0, MIT Imports: 17 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 (
	// BotSubscriptionStateCanceled indicates the user canceled the subscription.
	BotSubscriptionStateCanceled = "canceled"

	// BotSubscriptionStateActive indicates the user re-enabled a previously canceled subscription.
	BotSubscriptionStateActive = "active"

	// BotSubscriptionStateFailed indicates payment for the subscription failed.
	BotSubscriptionStateFailed = "failed"
)

Bot subscription state constants for BotSubscriptionUpdated.State. https://core.telegram.org/bots/api#botsubscriptionupdated

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")
)
View Source
const (
	RichBlockTypeParagraph              = "paragraph"
	RichBlockTypeSectionHeading         = "heading"
	RichBlockTypePreformatted           = "pre"
	RichBlockTypeFooter                 = "footer"
	RichBlockTypeDivider                = "divider"
	RichBlockTypeMathematicalExpression = "mathematical_expression"
	RichBlockTypeAnchor                 = "anchor"
	RichBlockTypeList                   = "list"
	RichBlockTypeBlockQuotation         = "blockquote"
	RichBlockTypePullQuotation          = "pullquote"
	RichBlockTypeCollage                = "collage"
	RichBlockTypeSlideshow              = "slideshow"
	RichBlockTypeTable                  = "table"
	RichBlockTypeDetails                = "details"
	RichBlockTypeMap                    = "map"
	RichBlockTypeAnimation              = "animation"
	RichBlockTypeAudio                  = "audio"
	RichBlockTypePhoto                  = "photo"
	RichBlockTypeVideo                  = "video"
	RichBlockTypeVoiceNote              = "voice_note"
	RichBlockTypeThinking               = "thinking"
)

Rich block type discriminators for RichBlock.Type. https://core.telegram.org/bots/api#richblock

View Source
const (
	RichTextTypeBold                   = "bold"
	RichTextTypeItalic                 = "italic"
	RichTextTypeUnderline              = "underline"
	RichTextTypeStrikethrough          = "strikethrough"
	RichTextTypeSpoiler                = "spoiler"
	RichTextTypeDateTime               = "date_time"
	RichTextTypeTextMention            = "text_mention"
	RichTextTypeSubscript              = "subscript"
	RichTextTypeSuperscript            = "superscript"
	RichTextTypeMarked                 = "marked"
	RichTextTypeCode                   = "code"
	RichTextTypeCustomEmoji            = "custom_emoji"
	RichTextTypeMathematicalExpression = "mathematical_expression"
	RichTextTypeUrl                    = "url"
	RichTextTypeEmailAddress           = "email_address"
	RichTextTypePhoneNumber            = "phone_number"
	RichTextTypeBankCardNumber         = "bank_card_number"
	RichTextTypeMention                = "mention"
	RichTextTypeHashtag                = "hashtag"
	RichTextTypeCashtag                = "cashtag"
	RichTextTypeBotCommand             = "bot_command"
	RichTextTypeAnchor                 = "anchor"
	RichTextTypeAnchorLink             = "anchor_link"
	RichTextTypeReference              = "reference"
	RichTextTypeReferenceLink          = "reference_link"
)

Rich text type discriminators for RichText.Type. https://core.telegram.org/bots/api#richtext

View Source
const (
	ButtonStylePrimary = "primary"
	ButtonStyleSuccess = "success"
	ButtonStyleDanger  = "danger"
)

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 Animation added in v0.14.7

type Animation struct {
	FileID       string     `json:"file_id"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	Width        int        `json:"width"`
	Height       int        `json:"height"`
	Duration     int        `json:"duration"`
	Thumbnail    *PhotoSize `json:"thumbnail,omitempty"`
	FileName     string     `json:"file_name,omitempty"`
	MimeType     string     `json:"mime_type,omitempty"`
	FileSize     int        `json:"file_size,omitempty"`
}

Animation represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). https://core.telegram.org/bots/api#animation

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"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	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,omitempty"` // optional
	Thumbnail    *PhotoSize `json:"thumbnail,omitempty"` // optional
}

Audio contains information about audio. https://core.telegram.org/bots/api#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"`
	DirectMessagesTopicID int64  `json:"direct_messages_topic_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

	SuggestedPostParameters *SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`

	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

	// ReceiverUserID: for outgoing ephemeral messages, unique identifier of the user who will receive
	// the message; for group and supergroup chats only. It is not guaranteed that the user will receive
	// the message, especially if they are offline. Bot API 10.2+
	ReceiverUserID int64 `json:"receiver_user_id,omitempty"`

	// CallbackQueryID: for outgoing ephemeral messages, identifier of the callback query which
	// triggered the message, if any. Bot API 10.2+
	CallbackQueryID string `json:"callback_query_id,omitempty"`
}

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 {
	BusinessConnectionID string                `json:"business_connection_id,omitempty"`
	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) AnswerChatJoinRequestQuery added in v0.14.9

func (bot *BotAPI) AnswerChatJoinRequestQuery(chatJoinRequestQueryID string, result ChatJoinRequestQueryResult) (APIResponse, error)

AnswerChatJoinRequestQuery processes a received chat join request query. Bot API 10.1+

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

func (*BotAPI) AnswerGuestQuery added in v0.14.9

func (bot *BotAPI) AnswerGuestQuery(guestQueryID string, result InlineQueryResult) (sent SentGuestMessage, err error)

AnswerGuestQuery sends a reply, on behalf of the bot, to a message received via Guest Mode in a chat the bot is not a member of.

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

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) DeleteAllMessageReactions added in v0.14.9

func (bot *BotAPI) DeleteAllMessageReactions(chatID int64, messageID int) (APIResponse, error)

DeleteAllMessageReactions removes all reactions from a message. Requires the can_restrict_members administrator right.

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

func (*BotAPI) DeleteEphemeralMessage added in v0.14.9

func (bot *BotAPI) DeleteEphemeralMessage(config DeleteEphemeralMessageConfig) (APIResponse, error)

DeleteEphemeralMessage deletes an ephemeral message. Bot API 10.2+

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

func (*BotAPI) DeleteMessage added in v0.9.0

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

func (*BotAPI) DeleteMessageReaction added in v0.14.9

func (bot *BotAPI) DeleteMessageReaction(chatID int64, messageID int, userID int64) (APIResponse, error)

DeleteMessageReaction removes a specific user's reaction from a message. Requires the can_restrict_members administrator right.

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

func (*BotAPI) EditEphemeralMessageCaption added in v0.14.9

func (bot *BotAPI) EditEphemeralMessageCaption(config EditEphemeralMessageCaptionConfig) (APIResponse, error)

EditEphemeralMessageCaption edits the caption of an ephemeral message. Bot API 10.2+

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

func (*BotAPI) EditEphemeralMessageMedia added in v0.14.9

func (bot *BotAPI) EditEphemeralMessageMedia(config EditEphemeralMessageMediaConfig) (APIResponse, error)

EditEphemeralMessageMedia edits the media of an ephemeral message. Bot API 10.2+

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

func (*BotAPI) EditEphemeralMessageReplyMarkup added in v0.14.9

func (bot *BotAPI) EditEphemeralMessageReplyMarkup(config EditEphemeralMessageReplyMarkupConfig) (APIResponse, error)

EditEphemeralMessageReplyMarkup edits only the reply markup of an ephemeral message. Bot API 10.2+

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

func (*BotAPI) EditEphemeralMessageText added in v0.14.9

func (bot *BotAPI) EditEphemeralMessageText(config EditEphemeralMessageTextConfig) (APIResponse, error)

EditEphemeralMessageText edits an ephemeral text message. Bot API 10.2+

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

func (*BotAPI) EnableDebug

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

EnableDebug enables metadata-only debugging. Request parameters, bot tokens, response bodies, and decoded provider objects are intentionally never logged.

func (*BotAPI) GetChat

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

func (*BotAPI) GetChatAdministrators added in v0.15.5

func (bot *BotAPI) GetChatAdministrators(chatID string, includeBots ...bool) (members []ChatMember, err error)

GetChatAdministrators returns chat administrators. Set returnBots to include administrator bots other than the current bot.

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

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) GetManagedBotAccessSettings added in v0.14.9

func (bot *BotAPI) GetManagedBotAccessSettings(userID int64) (settings BotAccessSettings, err error)

GetManagedBotAccessSettings returns the current access settings of a bot managed by the current bot.

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

func (*BotAPI) GetManagedBotToken added in v0.14.9

func (bot *BotAPI) GetManagedBotToken(userID int64) (token string, err error)

GetManagedBotToken returns the token of a managed bot.

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

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) GetUserPersonalChatMessages added in v0.14.9

func (bot *BotAPI) GetUserPersonalChatMessages(userID int64, requestedLimit ...int) (messages []Message, err error)

GetUserPersonalChatMessages returns recent messages posted to a user's personal chat, as shown on their profile page.

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

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) ReplaceManagedBotToken added in v0.14.9

func (bot *BotAPI) ReplaceManagedBotToken(userID int64) (token string, err error)

ReplaceManagedBotToken revokes the current token of a managed bot and generates a new one.

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

func (*BotAPI) SavePreparedKeyboardButton added in v0.14.9

func (bot *BotAPI) SavePreparedKeyboardButton(userID int64, button KeyboardButton) (prepared PreparedKeyboardButton, err error)

SavePreparedKeyboardButton stores a keyboard button that can be used by a user within a Mini App.

The button must be of type request_users, request_chat, or request_managed_bot.

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

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) SendChatJoinRequestWebApp added in v0.14.9

func (bot *BotAPI) SendChatJoinRequestWebApp(chatJoinRequestQueryID, webAppURL string) (APIResponse, error)

SendChatJoinRequestWebApp processes a received chat join request query by showing a Mini App to the user before deciding the outcome. Call AnswerChatJoinRequestQuery to resolve the join request query based on the user interaction with the Mini App. Bot API 10.1+

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

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) SetManagedBotAccessSettings added in v0.14.9

func (bot *BotAPI) SetManagedBotAccessSettings(userID int64, isAccessRestricted bool, addedUserIDs []int64) (APIResponse, error)

SetManagedBotAccessSettings updates the access settings of a bot managed by the current bot.

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

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 BotAccessSettings added in v0.14.9

type BotAccessSettings struct {
	// True if only selected users can access the bot. The owner always has access.
	IsAccessRestricted bool `json:"is_access_restricted"`

	// Optional. Users who have access in addition to the owner.
	AddedUsers []User `json:"added_users,omitempty"`
}

BotAccessSettings describes who can access a managed bot.

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

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 BotSubscriptionUpdated added in v0.14.9

type BotSubscriptionUpdated struct {
	// User who subscribed for payments toward the bot
	User User `json:"user"`

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

	// The new state of the subscription. Currently, it can be one of BotSubscriptionStateCanceled if the
	// user canceled the subscription, BotSubscriptionStateActive if the user re-enabled a previously
	// canceled subscription, or BotSubscriptionStateFailed if payment for the subscription failed.
	State string `json:"state"`
}

BotSubscriptionUpdated contains information about changes to a user payment subscription toward the current bot (Bot API 10.2 General).

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

type BusinessConnection added in v0.14.7

type BusinessConnection struct {
	ID         string `json:"id"`
	User       User   `json:"user"`
	UserChatID int64  `json:"user_chat_id"`
	Date       int    `json:"date"`
	CanReply   bool   `json:"can_reply"`
	IsEnabled  bool   `json:"is_enabled"`
}

BusinessConnection describes the connection of the bot with a business account. https://core.telegram.org/bots/api#businessconnection

type BusinessMessagesDeleted added in v0.14.7

type BusinessMessagesDeleted struct {
	BusinessConnectionID string `json:"business_connection_id"`
	Chat                 Chat   `json:"chat"`
	MessageIDs           []int  `json:"message_ids"`
}

BusinessMessagesDeleted is received when messages are deleted from a connected business account. https://core.telegram.org/bots/api#businessmessagesdeleted

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,omitempty"`      // optional
	UserName  string `json:"username,omitempty"`   // optional
	FirstName string `json:"first_name,omitempty"` // optional
	LastName  string `json:"last_name,omitempty"`  // optional

	// Optional. True, if the supergroup chat is a forum (has topics enabled)
	IsForum bool `json:"is_forum,omitempty"`

	// Optional. True, if the chat is the direct messages chat of a channel
	IsDirectMessages bool `json:"is_direct_messages,omitempty"`

	// Optional. Bot assigned to process join request queries. Bot API 10.1+
	GuardBot *User `json:"guard_bot,omitempty"`

	// Optional. Community to which the chat belongs. Bot API 10.2+
	Community *Community `json:"community,omitempty"`
}

Chat contains information about the place a message was sent. https://core.telegram.org/bots/api#chat

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"`

	// True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode
	CanManageChat bool `json:"can_manage_chat,omitempty"`

	// True, if the administrator can delete messages of other users
	CanDeleteMessages bool `json:"can_delete_messages,omitempty"`

	// True, if the administrator can manage video chats
	CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`

	// True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics
	CanRestrictMembers bool `json:"can_restrict_members,omitempty"`

	// True, if the administrator can add new administrators with a subset of their own privileges or demote administrators
	CanPromoteMembers bool `json:"can_promote_members,omitempty"`

	// True, if the user is allowed to change the chat title, photo and other settings
	CanChangeInfo bool `json:"can_change_info,omitempty"`

	// True, if the user is allowed to invite new users to the chat
	CanInviteUsers bool `json:"can_invite_users,omitempty"`

	// Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only
	CanPostMessages bool `json:"can_post_messages,omitempty"`

	// Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only
	CanEditMessages bool `json:"can_edit_messages,omitempty"`

	// Optional. True, if the user is allowed to pin messages; for groups and supergroups only
	CanPinMessages bool `json:"can_pin_messages,omitempty"`

	// Optional. True, if the administrator can post stories to the chat
	CanPostStories bool `json:"can_post_stories,omitempty"`

	// Optional. True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive
	CanEditStories bool `json:"can_edit_stories,omitempty"`

	// Optional. True, if the administrator can delete stories posted by other users
	CanDeleteStories bool `json:"can_delete_stories,omitempty"`

	// Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only
	CanManageTopics bool `json:"can_manage_topics,omitempty"`

	// Optional. True, if the administrator can manage direct messages of a channel
	CanManageDirectMessages bool `json:"can_manage_direct_messages,omitempty"`

	// Optional. True, if the administrator can manage tags in a supergroup
	CanManageTags bool `json:"can_manage_tags,omitempty"`
}

type ChatBackground added in v0.14.7

type ChatBackground struct {
	Type interface{} `json:"type"`
}

ChatBackground represents a chat background. https://core.telegram.org/bots/api#chatbackground

type ChatBoost added in v0.14.7

type ChatBoost struct {
	BoostID        string          `json:"boost_id"`
	AddDate        int             `json:"add_date"`
	ExpirationDate int             `json:"expiration_date"`
	Source         ChatBoostSource `json:"source"`
}

ChatBoost contains information about a chat boost. https://core.telegram.org/bots/api#chatboost

type ChatBoostAdded added in v0.14.7

type ChatBoostAdded struct {
	BoostCount int `json:"boost_count"`
}

ChatBoostAdded represents a service message about a user boosting a chat. https://core.telegram.org/bots/api#chatboostadded

type ChatBoostRemoved added in v0.14.7

type ChatBoostRemoved struct {
	Chat       Chat            `json:"chat"`
	BoostID    string          `json:"boost_id"`
	RemoveDate int             `json:"remove_date"`
	Source     ChatBoostSource `json:"source"`
}

ChatBoostRemoved represents a boost removed from a chat. https://core.telegram.org/bots/api#chatboostremoved

type ChatBoostSource added in v0.14.7

type ChatBoostSource struct {
	// Source of the boost: "premium", "gift_code", or "giveaway"
	Source string `json:"source"`

	// For "premium" and "gift_code": the user that boosted the chat
	User *User `json:"user,omitempty"`

	// For "giveaway": identifier of a message in the chat with the giveaway; 0 if the message is not yet available
	GiveawayMessageID int `json:"giveaway_message_id,omitempty"`

	// For "giveaway": True, if the giveaway was completed but no user won the boost
	IsUnclaimed bool `json:"is_unclaimed,omitempty"`
}

ChatBoostSource describes the source of a chat boost. https://core.telegram.org/bots/api#chatboostsource

type ChatBoostUpdated added in v0.14.7

type ChatBoostUpdated struct {
	Chat  Chat      `json:"chat"`
	Boost ChatBoost `json:"boost"`
}

ChatBoostUpdated represents a boost added to a chat or changed. https://core.telegram.org/bots/api#chatboostupdated

type ChatFullInfo added in v0.15.5

type ChatFullInfo = Chat

ChatFullInfo is the object returned by getChat. This package historically modeled the same fields directly on Chat, so the alias preserves source compatibility while exposing the current Bot API name.

type ChatJoinRequest added in v0.14.7

type ChatJoinRequest struct {
	Chat       Chat        `json:"chat"`
	From       User        `json:"from"`
	UserChatID int64       `json:"user_chat_id"`
	Date       int         `json:"date"`
	Bio        string      `json:"bio,omitempty"`
	InviteLink interface{} `json:"invite_link,omitempty"`

	// Optional. Identifier of the join request query; for bots assigned to process join requests only.
	// If present, then the bot must call SendChatJoinRequestWebApp or directly call
	// AnswerChatJoinRequestQuery within 10 seconds. Bot API 10.1+
	// https://core.telegram.org/bots/api#chatjoinrequest
	QueryID string `json:"query_id,omitempty"`
}

ChatJoinRequest represents a join request sent to a chat. https://core.telegram.org/bots/api#chatjoinrequest

type ChatJoinRequestQueryResult added in v0.14.9

type ChatJoinRequestQueryResult string

ChatJoinRequestQueryResult is the result to answer a chat join request query with, via BotAPI.AnswerChatJoinRequestQuery. Bot API 10.1+

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

const (
	// ChatJoinRequestQueryResultApprove allows the user to join the chat.
	ChatJoinRequestQueryResultApprove ChatJoinRequestQueryResult = "approve"

	// ChatJoinRequestQueryResultDecline disallows the user to join the chat.
	ChatJoinRequestQueryResultDecline ChatJoinRequestQueryResult = "decline"

	// ChatJoinRequestQueryResultQueue leaves the decision to other administrators.
	ChatJoinRequestQueryResultQueue ChatJoinRequestQueryResult = "queue"
)

type ChatMember

type ChatMember struct {
	// Deprecated: use MemberUser. Kept for source compatibility with the
	// framework's earlier, incomplete representation.
	User
	Status     string `json:"status,omitempty"`
	MemberUser *User  `json:"user,omitempty"`
	IsBot      bool   `json:"is_bot,omitempty"`

	// Permission fields are populated for restricted members and administrators.
	CanSendMessages       bool `json:"can_send_messages,omitempty"`
	CanSendAudios         bool `json:"can_send_audios,omitempty"`
	CanSendDocuments      bool `json:"can_send_documents,omitempty"`
	CanSendPhotos         bool `json:"can_send_photos,omitempty"`
	CanSendVideos         bool `json:"can_send_videos,omitempty"`
	CanSendVideoNotes     bool `json:"can_send_video_notes,omitempty"`
	CanSendVoiceNotes     bool `json:"can_send_voice_notes,omitempty"`
	CanSendPolls          bool `json:"can_send_polls,omitempty"`
	CanSendOtherMessages  bool `json:"can_send_other_messages,omitempty"`
	CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
	CanReactToMessages    bool `json:"can_react_to_messages,omitempty"`
	CanEditTag            bool `json:"can_edit_tag,omitempty"`
	CanChangeInfo         bool `json:"can_change_info,omitempty"`
	CanInviteUsers        bool `json:"can_invite_users,omitempty"`
	CanPinMessages        bool `json:"can_pin_messages,omitempty"`
	CanManageTopics       bool `json:"can_manage_topics,omitempty"`
	UntilDate             int  `json:"until_date,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 ChatMemberStatus added in v0.14.7

type ChatMemberStatus string

ChatMemberStatus represents the status of a chat member.

const (
	ChatMemberStatusCreator       ChatMemberStatus = "creator"
	ChatMemberStatusAdministrator ChatMemberStatus = "administrator"
	ChatMemberStatusMember        ChatMemberStatus = "member"
	ChatMemberStatusRestricted    ChatMemberStatus = "restricted"
	ChatMemberStatusLeft          ChatMemberStatus = "left"
	ChatMemberStatusKicked        ChatMemberStatus = "kicked"
)

type ChatMemberUpdated added in v0.14.7

type ChatMemberUpdated struct {
	Chat                    Chat        `json:"chat"`
	From                    User        `json:"from"`
	Date                    int         `json:"date"`
	OldChatMember           interface{} `json:"old_chat_member"`
	NewChatMember           interface{} `json:"new_chat_member"`
	InviteLink              interface{} `json:"invite_link,omitempty"`
	ViaJoinRequest          bool        `json:"via_join_request,omitempty"`
	ViaChatFolderInviteLink bool        `json:"via_chat_folder_invite_link,omitempty"`
}

ChatMemberUpdated represents changes in the status of a chat member. https://core.telegram.org/bots/api#chatmemberupdated

type ChatOwnerChanged added in v0.14.7

type ChatOwnerChanged struct {
	OldOwner User `json:"old_owner"`
	NewOwner User `json:"new_owner"`
}

ChatOwnerChanged represents a service message: chat ownership has been transferred. https://core.telegram.org/bots/api#chatownerchanged

type ChatOwnerLeft added in v0.14.7

type ChatOwnerLeft struct{}

ChatOwnerLeft represents a service message: chat owner has left the chat. https://core.telegram.org/bots/api#chatownerleft

type ChatPermissions added in v0.15.5

type ChatPermissions struct {
	CanSendMessages       bool `json:"can_send_messages,omitempty"`
	CanSendAudios         bool `json:"can_send_audios,omitempty"`
	CanSendDocuments      bool `json:"can_send_documents,omitempty"`
	CanSendPhotos         bool `json:"can_send_photos,omitempty"`
	CanSendVideos         bool `json:"can_send_videos,omitempty"`
	CanSendVideoNotes     bool `json:"can_send_video_notes,omitempty"`
	CanSendVoiceNotes     bool `json:"can_send_voice_notes,omitempty"`
	CanSendPolls          bool `json:"can_send_polls,omitempty"`
	CanSendOtherMessages  bool `json:"can_send_other_messages,omitempty"`
	CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
	CanReactToMessages    bool `json:"can_react_to_messages,omitempty"`
	CanEditTag            bool `json:"can_edit_tag,omitempty"`
	CanChangeInfo         bool `json:"can_change_info,omitempty"`
	CanInviteUsers        bool `json:"can_invite_users,omitempty"`
	CanPinMessages        bool `json:"can_pin_messages,omitempty"`
	CanManageTopics       bool `json:"can_manage_topics,omitempty"`
}

ChatPermissions describes actions that a non-administrator user may perform in a chat.

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 Checklist added in v0.14.7

type Checklist struct {
	Title         string          `json:"title"`
	TitleEntities []MessageEntity `json:"title_entities,omitempty"`
	Tasks         []ChecklistTask `json:"tasks"`
	OthersCanAdd  bool            `json:"others_can_add,omitempty"`
	OthersCanMark bool            `json:"others_can_mark,omitempty"`
}

Checklist represents a checklist message. https://core.telegram.org/bots/api#checklist

type ChecklistTask added in v0.14.7

type ChecklistTask struct {
	ID              int             `json:"id"`
	Text            string          `json:"text"`
	TextEntities    []MessageEntity `json:"text_entities,omitempty"`
	CompletedByUser *User           `json:"completed_by_user,omitempty"`
	CompletedByChat *Chat           `json:"completed_by_chat,omitempty"`
	CompletionDate  int             `json:"completion_date,omitempty"`
}

ChecklistTask represents a task in a checklist. https://core.telegram.org/bots/api#checklisttask

type ChecklistTasksAdded added in v0.14.7

type ChecklistTasksAdded struct {
	ChecklistMessageID int             `json:"checklist_message_id"`
	Tasks              []ChecklistTask `json:"tasks"`
}

ChecklistTasksAdded represents a service message about tasks added to a checklist. https://core.telegram.org/bots/api#checklisttasksadded

type ChecklistTasksDone added in v0.14.7

type ChecklistTasksDone struct {
	ChecklistMessageID int   `json:"checklist_message_id"`
	MarkedAsDone       []int `json:"marked_as_done,omitempty"`
	MarkedAsNotDone    []int `json:"marked_as_not_done,omitempty"`
}

ChecklistTasksDone represents a service message about tasks in a checklist marked as done or not done. https://core.telegram.org/bots/api#checklisttasksdone

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 Community added in v0.14.9

type Community struct {
	// Unique identifier for this community. 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 signed 64-bit integer or double-precision float type are safe for storing
	// this identifier.
	ID int64 `json:"id"`

	// Name of the community
	Name string `json:"name"`
}

Community represents a community: several supergroups, channels, and bots linked together around a shared topic or audience (Bot API 10.2 Communities).

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

type CommunityChatAdded added in v0.14.9

type CommunityChatAdded struct {
	// The new community to which the chat belongs
	Community Community `json:"community"`
}

CommunityChatAdded describes a service message about a chat being added to a community (Bot API 10.2 Communities).

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

type CommunityChatRemoved added in v0.14.9

type CommunityChatRemoved struct {
}

CommunityChatRemoved describes a service message about a chat being removed from a community. Currently holds no information (Bot API 10.2 Communities).

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

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 {
	// BusinessConnectionID: unique identifier of the business connection on
	// behalf of which the link will be created.
	BusinessConnectionID string `json:"business_connection_id,omitempty"`

	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. Not shown to the user.
	ProviderToken      string         `json:"provider_token,omitempty"`      // Payment provider token; empty string for Telegram Stars.
	Currency           string         `json:"currency"`                      // Three-letter ISO 4217 currency code; "XTR" for Telegram Stars.
	Prices             []LabeledPrice `json:"prices"`                        // Price breakdown. Exactly one item for Telegram Stars.
	SubscriptionPeriod int64          `json:"subscription_period,omitempty"` // Seconds the subscription stays active before the next payment. Must be 2592000 (30 days) if used.

	MaxTipAmount        int64   `json:"max_tip_amount,omitempty"`        // Maximum accepted tip in the smallest currency units. Not supported for Telegram Stars.
	SuggestedTipAmounts []int64 `json:"suggested_tip_amounts,omitempty"` // Up to 4 suggested tip amounts, strictly increasing, not exceeding MaxTipAmount.
	ProviderData        string  `json:"provider_data,omitempty"`         // JSON-serialized data about the invoice, shared with the payment provider.
	PhotoURL            string  `json:"photo_url,omitempty"`             // URL of the product photo for the invoice.
	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"`             // Require the user's full name. Ignored for Telegram Stars.
	NeedPhoneNumber     bool    `json:"need_phone_number,omitempty"`     // Require the user's phone number. Ignored for Telegram Stars.
	NeedEmail           bool    `json:"need_email,omitempty"`            // Require the user's email. Ignored for Telegram Stars.
	NeedShippingAddress bool    `json:"need_shipping_address,omitempty"` // Require the user's shipping address. Ignored for Telegram Stars.

	SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"` // Send the phone number to the provider. Ignored for Telegram Stars.
	SendEmailToProvider       bool `json:"send_email_to_provider,omitempty"`        // Send the email to the provider. Ignored for Telegram Stars.
	IsFlexible                bool `json:"is_flexible,omitempty"`                   // Final price depends on the shipping method. Ignored for Telegram Stars.
}

CreateInvoiceLinkConfig creates a link for an invoice. https://core.telegram.org/bots/api#createinvoicelink

Unlike sendInvoice this method is NOT tied to a chat: it returns a t.me invoice URL the payer can open anywhere. It therefore does NOT embed BaseChat (there is no chat_id) and carries the invoice product fields directly. Pass an empty ProviderToken and Currency "XTR" for payments in Telegram Stars.

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 the url.Values representation of CreateInvoiceLinkConfig.

type DeleteEphemeralMessageConfig added in v0.14.9

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

DeleteEphemeralMessageConfig deletes an ephemeral message (Bot API 10.2 Ephemeral Messages).

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

func NewDeleteEphemeralMessage added in v0.15.5

func NewDeleteEphemeralMessage(chatID, receiverUserID, ephemeralMessageID int64) DeleteEphemeralMessageConfig

NewDeleteEphemeralMessage constructs an ephemeral-message deletion.

func (DeleteEphemeralMessageConfig) TelegramMethod added in v0.14.9

func (DeleteEphemeralMessageConfig) TelegramMethod() string

func (DeleteEphemeralMessageConfig) Values added in v0.14.9

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 Dice added in v0.14.7

type Dice struct {
	Emoji string `json:"emoji"`
	Value int    `json:"value"`
}

Dice represents an animated emoji that displays a random value. https://core.telegram.org/bots/api#dice

type DirectMessagePriceChanged added in v0.14.7

type DirectMessagePriceChanged struct {
	DirectMessageStarCount int `json:"direct_message_star_count"`
}

DirectMessagePriceChanged represents a service message about the price change for paid messages. https://core.telegram.org/bots/api#directmessagepricechanged

type DirectMessagesTopic added in v0.14.7

type DirectMessagesTopic struct {
	TopicID int64 `json:"topic_id"`
	User    *User `json:"user,omitempty"`
}

DirectMessagesTopic represents information about a direct messages chat topic. https://core.telegram.org/bots/api#directmessagestopic

type Document

type Document struct {
	FileID       string     `json:"file_id"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	Thumbnail    *PhotoSize `json:"thumbnail,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. https://core.telegram.org/bots/api#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 EditEphemeralMessageCaptionConfig added in v0.14.9

type EditEphemeralMessageCaptionConfig struct {

	// Optional. New caption of the message, 0-1024 characters after entities parsing
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the message caption
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the caption, which can be
	// specified instead of ParseMode
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
	// contains filtered or unexported fields
}

EditEphemeralMessageCaptionConfig allows you to modify the caption of an ephemeral message (Bot API 10.2 Ephemeral Messages).

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

func NewEditEphemeralMessageCaption added in v0.15.5

func NewEditEphemeralMessageCaption(chatID, receiverUserID, ephemeralMessageID int64, caption string) EditEphemeralMessageCaptionConfig

NewEditEphemeralMessageCaption constructs an ephemeral caption edit.

func (EditEphemeralMessageCaptionConfig) TelegramMethod added in v0.14.9

func (EditEphemeralMessageCaptionConfig) TelegramMethod() string

func (EditEphemeralMessageCaptionConfig) Values added in v0.14.9

Values returns URL values representation of EditEphemeralMessageCaptionConfig

type EditEphemeralMessageMediaConfig added in v0.14.9

type EditEphemeralMessageMediaConfig struct {

	// A JSON-serialized object for the new media content of the message. Must be one of
	// *InputMediaAnimation, *InputMediaAudio, *InputMediaPhoto, or *InputMediaVideo.
	Media any `json:"media"`
	// contains filtered or unexported fields
}

EditEphemeralMessageMediaConfig allows you to modify the media of an ephemeral message (Bot API 10.2 Ephemeral Messages). A new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL.

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

func NewEditEphemeralMessageMedia added in v0.15.5

func NewEditEphemeralMessageMedia(chatID, receiverUserID, ephemeralMessageID int64, media any) EditEphemeralMessageMediaConfig

NewEditEphemeralMessageMedia constructs an ephemeral media edit.

func (EditEphemeralMessageMediaConfig) TelegramMethod added in v0.14.9

func (EditEphemeralMessageMediaConfig) TelegramMethod() string

func (EditEphemeralMessageMediaConfig) Values added in v0.14.9

Values returns URL values representation of EditEphemeralMessageMediaConfig

type EditEphemeralMessageReplyMarkupConfig added in v0.14.9

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

EditEphemeralMessageReplyMarkupConfig allows you to modify the reply markup of an ephemeral message (Bot API 10.2 Ephemeral Messages).

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

func NewEditEphemeralMessageReplyMarkup added in v0.15.5

func NewEditEphemeralMessageReplyMarkup(chatID, receiverUserID, ephemeralMessageID int64, replyMarkup *InlineKeyboardMarkup) EditEphemeralMessageReplyMarkupConfig

NewEditEphemeralMessageReplyMarkup constructs an ephemeral keyboard edit.

func (EditEphemeralMessageReplyMarkupConfig) TelegramMethod added in v0.14.9

func (EditEphemeralMessageReplyMarkupConfig) Values added in v0.14.9

type EditEphemeralMessageTextConfig added in v0.14.9

type EditEphemeralMessageTextConfig struct {

	// New text of the message, 1-4096 characters after entity parsing
	Text string `json:"text"`

	// Optional. Mode for parsing entities in the message text
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in message text, which can be
	// specified instead of ParseMode
	Entities []MessageEntity `json:"entities,omitempty"`

	// Optional. Link preview generation options for the message
	LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
	// contains filtered or unexported fields
}

EditEphemeralMessageTextConfig allows you to modify the text of an ephemeral message (Bot API 10.2 Ephemeral Messages).

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

func NewEditEphemeralMessageText added in v0.15.5

func NewEditEphemeralMessageText(chatID, receiverUserID, ephemeralMessageID int64, text string) EditEphemeralMessageTextConfig

NewEditEphemeralMessageText constructs an externally usable ephemeral text edit without exposing the package's shared addressing implementation.

func (EditEphemeralMessageTextConfig) TelegramMethod added in v0.14.9

func (EditEphemeralMessageTextConfig) TelegramMethod() string

func (EditEphemeralMessageTextConfig) Values added in v0.14.9

Values returns URL values representation of EditEphemeralMessageTextConfig

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

	// Optional. A JSON-serialized rich message to replace the message content with. Bot API 10.1+
	// https://core.telegram.org/bots/api#editmessagetext
	RichMessage *InputRichMessage
}

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 ExternalReplyInfo added in v0.14.7

type ExternalReplyInfo struct {
	Origin             MessageOrigin       `json:"origin"`
	Chat               *Chat               `json:"chat,omitempty"`
	MessageID          int                 `json:"message_id,omitempty"`
	LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
	Animation          *Animation          `json:"animation,omitempty"`
	Audio              *Audio              `json:"audio,omitempty"`
	Document           *Document           `json:"document,omitempty"`
	PaidMedia          *PaidMediaInfo      `json:"paid_media,omitempty"`
	Photo              []PhotoSize         `json:"photo,omitempty"`
	LivePhoto          *LivePhoto          `json:"live_photo,omitempty"` // Bot API 10.0+
	Sticker            *Sticker            `json:"sticker,omitempty"`
	Story              *Story              `json:"story,omitempty"`
	Video              *Video              `json:"video,omitempty"`
	VideoNote          *VideoNote          `json:"video_note,omitempty"`
	Voice              *Voice              `json:"voice,omitempty"`
	HasMediaSpoiler    bool                `json:"has_media_spoiler,omitempty"`
	Contact            *Contact            `json:"contact,omitempty"`
	Dice               *Dice               `json:"dice,omitempty"`
	Game               interface{}         `json:"game,omitempty"`
	Giveaway           *Giveaway           `json:"giveaway,omitempty"`
	GiveawayWinners    *GiveawayWinners    `json:"giveaway_winners,omitempty"`
	Invoice            *InvoiceConfig      `json:"invoice,omitempty"`
	Location           *Location           `json:"location,omitempty"`
	Poll               *Poll               `json:"poll,omitempty"`
	Venue              *Venue              `json:"venue,omitempty"`
}

ExternalReplyInfo contains information about a message being replied to from another chat. https://core.telegram.org/bots/api#externalreplyinfo

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 ForumTopic added in v0.14.7

type ForumTopic struct {
	MessageThreadID   int    `json:"message_thread_id"`
	Name              string `json:"name"`
	IconColor         int    `json:"icon_color"`
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
	IsNameImplicit    bool   `json:"is_name_implicit,omitempty"`
}

ForumTopic represents a forum topic. https://core.telegram.org/bots/api#forumtopic

type ForumTopicClosed added in v0.14.7

type ForumTopicClosed struct{}

ForumTopicClosed represents a service message about a closed forum topic. https://core.telegram.org/bots/api#forumtopicclosed

type ForumTopicCreated added in v0.14.7

type ForumTopicCreated struct {
	Name              string `json:"name"`
	IconColor         int    `json:"icon_color"`
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
	IsNameImplicit    bool   `json:"is_name_implicit,omitempty"`
}

ForumTopicCreated represents a service message about a new forum topic. https://core.telegram.org/bots/api#forumtopiccreated

type ForumTopicEdited added in v0.14.7

type ForumTopicEdited struct {
	Name              string `json:"name,omitempty"`
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}

ForumTopicEdited represents a service message about an edited forum topic. https://core.telegram.org/bots/api#forumtopicedited

type ForumTopicReopened added in v0.14.7

type ForumTopicReopened struct{}

ForumTopicReopened represents a service message about a reopened forum topic. https://core.telegram.org/bots/api#forumtopicreopened

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 GeneralForumTopicHidden added in v0.14.7

type GeneralForumTopicHidden struct{}

GeneralForumTopicHidden represents a service message about the General forum topic hidden in a chat. https://core.telegram.org/bots/api#generalforumtopichidden

type GeneralForumTopicUnhidden added in v0.14.7

type GeneralForumTopicUnhidden struct{}

GeneralForumTopicUnhidden represents a service message about the General forum topic unhidden in a chat. https://core.telegram.org/bots/api#generalforumtopicunhidden

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 Giveaway added in v0.14.7

type Giveaway struct {
	Chats                         []Chat   `json:"chats"`
	WinnersSelectionDate          int      `json:"winners_selection_date"`
	WinnerCount                   int      `json:"winner_count"`
	OnlyNewMembers                bool     `json:"only_new_members,omitempty"`
	HasPublicWinners              bool     `json:"has_public_winners,omitempty"`
	PrizeDescription              string   `json:"prize_description,omitempty"`
	CountryCodes                  []string `json:"country_codes,omitempty"`
	PrizeStarCount                int      `json:"prize_star_count,omitempty"`
	PremiumSubscriptionMonthCount int      `json:"premium_subscription_month_count,omitempty"`
}

Giveaway represents a message about a scheduled giveaway. https://core.telegram.org/bots/api#giveaway

type GiveawayCompleted added in v0.14.7

type GiveawayCompleted struct {
	WinnerCount         int      `json:"winner_count"`
	UnclaimedPrizeCount int      `json:"unclaimed_prize_count,omitempty"`
	GiveawayMessage     *Message `json:"giveaway_message,omitempty"`
	IsStarGiveaway      bool     `json:"is_star_giveaway,omitempty"`
}

GiveawayCompleted represents a service message about the completion of a giveaway without public winners. https://core.telegram.org/bots/api#giveawaycompleted

type GiveawayCreated added in v0.14.7

type GiveawayCreated struct {
	PrizeStarCount int `json:"prize_star_count,omitempty"`
}

GiveawayCreated represents a service message about the creation of a scheduled giveaway. https://core.telegram.org/bots/api#giveawaycreated

type GiveawayWinners added in v0.14.7

type GiveawayWinners struct {
	Chat                          Chat   `json:"chat"`
	GiveawayMessageID             int    `json:"giveaway_message_id"`
	WinnersSelectionDate          int    `json:"winners_selection_date"`
	WinnerCount                   int    `json:"winner_count"`
	Winners                       []User `json:"winners"`
	AdditionalChatCount           int    `json:"additional_chat_count,omitempty"`
	PrizeStarCount                int    `json:"prize_star_count,omitempty"`
	PremiumSubscriptionMonthCount int    `json:"premium_subscription_month_count,omitempty"`
	UnclaimedPrizeCount           int    `json:"unclaimed_prize_count,omitempty"`
	OnlyNewMembers                bool   `json:"only_new_members,omitempty"`
	WasRefunded                   bool   `json:"was_refunded,omitempty"`
	PrizeDescription              string `json:"prize_description,omitempty"`
}

GiveawayWinners represents a message about the completion of a giveaway with public winners. https://core.telegram.org/bots/api#giveawaywinners

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 InaccessibleMessage added in v0.14.7

type InaccessibleMessage struct {
	Chat      Chat `json:"chat"`
	MessageID int  `json:"message_id"`
	Date      int  `json:"date"` // Always 0
}

InaccessibleMessage describes a message that was deleted or is otherwise inaccessible. https://core.telegram.org/bots/api#inaccessiblemessage

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"`

	// Optional. Custom emoji identifier of the emoji that should appear on the button.
	// Available if the bot is allowed to use custom emoji in messages. Bot API 9.4+
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`

	// Optional. The color of the button. One of "primary", "success", "danger". Bot API 9.4+
	Style string `json:"style,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 InputMediaAnimation added in v0.14.9

type InputMediaAnimation struct {
	// Type of the media, must be "animation"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
	// supported server-side.
	Thumbnail string `json:"thumbnail,omitempty"`

	// Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing. Ignored
	// when this InputMediaAnimation is used as InputRichBlockAnimation.Animation; use
	// InputRichBlockAnimation.Caption instead.
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the animation caption.
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. List of special entities that appear in the caption, which can be specified instead of
	// ParseMode.
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Pass True if the caption must be shown above the message media.
	ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`

	// Optional. Animation width.
	Width int `json:"width,omitempty"`

	// Optional. Animation height.
	Height int `json:"height,omitempty"`

	// Optional. Animation duration in seconds.
	Duration int `json:"duration,omitempty"`

	// Optional. Pass True if the animation needs to be covered with a spoiler animation.
	HasSpoiler bool `json:"has_spoiler,omitempty"`
}

InputMediaAnimation represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.

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

type InputMediaAudio added in v0.14.9

type InputMediaAudio struct {
	// Type of the media, must be "audio"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
	// supported server-side.
	Thumbnail string `json:"thumbnail,omitempty"`

	// Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing. Ignored when
	// this InputMediaAudio is used as InputRichBlockAudio.Audio; use InputRichBlockAudio.Caption instead.
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the audio caption.
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. List of special entities that appear in the caption, which can be specified instead of
	// ParseMode.
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Duration of the audio in seconds.
	Duration int `json:"duration,omitempty"`

	// Optional. Performer of the audio.
	Performer string `json:"performer,omitempty"`

	// Optional. Title of the audio.
	Title string `json:"title,omitempty"`
}

InputMediaAudio represents an audio file to be treated as music to be sent.

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

type InputMediaDocument added in v0.15.5

type InputMediaDocument struct {
	Type                        string          `json:"type"`
	Media                       string          `json:"media"`
	Thumbnail                   string          `json:"thumbnail,omitempty"`
	Caption                     string          `json:"caption,omitempty"`
	ParseMode                   string          `json:"parse_mode,omitempty"`
	CaptionEntities             []MessageEntity `json:"caption_entities,omitempty"`
	DisableContentTypeDetection bool            `json:"disable_content_type_detection,omitempty"`
}

InputMediaDocument represents a general file to be sent.

type InputMediaLink struct {
	// Type of the media, must be "link"
	Type string `json:"type"`

	// HTTP URL of the link
	URL string `json:"url"`
}

InputMediaLink represents an HTTP link to be sent. It can be used as an InputPollOptionMedia. Bot API 10.1+

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

type InputMediaLivePhoto added in v0.14.9

type InputMediaLivePhoto struct {
	// Type of the result, must be "live_photo"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Caption of the live photo to be sent, 0-1024 characters after entities parsing
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the live photo caption
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the caption,
	// which can be specified instead of ParseMode
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Pass True, if the caption must be shown above the message media
	ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`

	// Optional. Pass True if the live photo needs to be covered with a spoiler animation
	HasSpoiler bool `json:"has_spoiler,omitempty"`
}

InputMediaLivePhoto represents a live photo to be sent as part of a media group or used to edit the media of a message.

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

type InputMediaLocation added in v0.15.5

type InputMediaLocation struct {
	Type               string  `json:"type"`
	Latitude           float64 `json:"latitude"`
	Longitude          float64 `json:"longitude"`
	HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
}

InputMediaLocation represents a location to be sent.

type InputMediaPhoto added in v0.14.9

type InputMediaPhoto struct {
	// Type of the media, must be "photo"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing. Ignored when
	// this InputMediaPhoto is used as InputRichBlockPhoto.Photo; use InputRichBlockPhoto.Caption instead.
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the photo caption.
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. List of special entities that appear in the caption, which can be specified instead of
	// ParseMode.
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Pass True if the caption must be shown above the message media.
	ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`

	// Optional. Pass True if the photo needs to be covered with a spoiler animation.
	HasSpoiler bool `json:"has_spoiler,omitempty"`
}

InputMediaPhoto represents a photo to be sent.

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

type InputMediaSticker added in v0.15.5

type InputMediaSticker struct {
	Type  string `json:"type"`
	Media string `json:"media"`
	Emoji string `json:"emoji,omitempty"`
}

InputMediaSticker represents a sticker file to be sent.

type InputMediaVenue added in v0.15.5

type InputMediaVenue struct {
	Type            string  `json:"type"`
	Latitude        float64 `json:"latitude"`
	Longitude       float64 `json:"longitude"`
	Title           string  `json:"title"`
	Address         string  `json:"address"`
	FoursquareID    string  `json:"foursquare_id,omitempty"`
	FoursquareType  string  `json:"foursquare_type,omitempty"`
	GooglePlaceID   string  `json:"google_place_id,omitempty"`
	GooglePlaceType string  `json:"google_place_type,omitempty"`
}

InputMediaVenue represents a venue to be sent.

type InputMediaVideo added in v0.14.9

type InputMediaVideo struct {
	// Type of the media, must be "video"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
	// supported server-side.
	Thumbnail string `json:"thumbnail,omitempty"`

	// Optional. Cover for the video in the message.
	Cover string `json:"cover,omitempty"`

	// Optional. Start timestamp for the video in the message.
	StartTimestamp int `json:"start_timestamp,omitempty"`

	// Optional. Caption of the video to be sent, 0-1024 characters after entities parsing. Ignored when
	// this InputMediaVideo is used as InputRichBlockVideo.Video; use InputRichBlockVideo.Caption instead.
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the video caption.
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. List of special entities that appear in the caption, which can be specified instead of
	// ParseMode.
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Pass True if the caption must be shown above the message media.
	ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`

	// Optional. Video width.
	Width int `json:"width,omitempty"`

	// Optional. Video height.
	Height int `json:"height,omitempty"`

	// Optional. Video duration in seconds.
	Duration int `json:"duration,omitempty"`

	// Optional. Pass True if the uploaded video is suitable for streaming.
	SupportsStreaming bool `json:"supports_streaming,omitempty"`

	// Optional. Pass True if the video needs to be covered with a spoiler animation.
	HasSpoiler bool `json:"has_spoiler,omitempty"`
}

InputMediaVideo represents a video to be sent.

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

type InputMediaVoiceNote added in v0.14.9

type InputMediaVoiceNote struct {
	// Type of the media, must be "voice_note"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`

	// Optional. Caption of the voice message to be sent, 0-1024 characters after entities parsing.
	// Ignored when this InputMediaVoiceNote is used as InputRichBlockVoiceNote.VoiceNote; use
	// InputRichBlockVoiceNote.Caption instead.
	Caption string `json:"caption,omitempty"`

	// Optional. Mode for parsing entities in the voice message caption.
	ParseMode string `json:"parse_mode,omitempty"`

	// Optional. List of special entities that appear in the caption, which can be specified instead of
	// ParseMode.
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. Duration of the voice message in seconds.
	Duration int `json:"duration,omitempty"`
}

InputMediaVoiceNote represents a voice message file to be sent (Bot API 10.2).

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

type InputMessageContent added in v0.10.0

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

type InputPaidMediaLivePhoto added in v0.14.9

type InputPaidMediaLivePhoto struct {
	// Type of the media, must be "live_photo"
	Type string `json:"type"`

	// File to send. Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL
	// for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new
	// one using multipart/form-data under <file_attach_name> name.
	Media string `json:"media"`
}

InputPaidMediaLivePhoto describes a live photo to be sent as paid media.

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

type InputPollMedia added in v0.14.9

type InputPollMedia struct {
	// Input is an optional fully typed InputMedia* union member. When set, it is
	// serialized directly and the legacy flattened fields below are ignored.
	Input any `json:"-"`

	// Type of the media, one of "animation", "audio", "document", "live_photo", "location", "photo",
	// "venue", "video"
	Type string `json:"type"`

	// File to send, required for file-based types ("animation", "audio", "document", "live_photo",
	// "photo", "sticker", "video"). Pass a file_id to send a file that exists on the Telegram servers,
	// pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>"
	// to upload a new one using multipart/form-data.
	Media string `json:"media,omitempty"`

	// Location to attach, required when Type is "location"
	Location *Location `json:"location,omitempty"`

	// Venue to attach, required when Type is "venue"
	Venue *Venue `json:"venue,omitempty"`
}

InputPollMedia describes media to attach to a poll or its quiz explanation.

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

func NewInputPollMedia added in v0.15.5

func NewInputPollMedia(input any) InputPollMedia

NewInputPollMedia constructs a full-fidelity InputPollMedia union.

func (InputPollMedia) MarshalJSON added in v0.15.5

func (v InputPollMedia) MarshalJSON() ([]byte, error)

type InputPollOption added in v0.14.9

type InputPollOption struct {
	// Option text, 1-100 characters
	Text string `json:"text"`

	// Optional. Mode for parsing entities in the text. See formatting options for more details.
	// Currently, only custom emoji entities are allowed.
	TextParseMode string `json:"text_parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the option text.
	// It can be specified instead of text_parse_mode.
	TextEntities []MessageEntity `json:"text_entities,omitempty"`

	// Optional. Media to attach to the option. Bot API 10.0+
	Media *InputPollOptionMedia `json:"media,omitempty"`
}

InputPollOption contains information about one answer option in a poll to be sent. https://core.telegram.org/bots/api#inputpolloption

type InputPollOptionMedia added in v0.14.9

type InputPollOptionMedia struct {
	// Input is an optional fully typed InputMedia* union member. When set, it is
	// serialized directly and the legacy flattened fields below are ignored.
	Input any `json:"-"`

	// Type of the media, one of "animation", "link", "live_photo", "location", "photo", "sticker",
	// "venue", "video". "link" added in Bot API 10.1
	Type string `json:"type"`

	// File to send, required for file-based types ("animation", "live_photo", "photo", "sticker", "video").
	// Pass a file_id to send a file that exists on the Telegram servers, pass an HTTP URL for Telegram to
	// get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using
	// multipart/form-data.
	Media string `json:"media,omitempty"`

	// HTTP URL of the link, required when Type is "link". Bot API 10.1+
	URL string `json:"url,omitempty"`

	// Location to attach, required when Type is "location"
	Location *Location `json:"location,omitempty"`

	// Venue to attach, required when Type is "venue"
	Venue *Venue `json:"venue,omitempty"`
}

InputPollOptionMedia describes media to attach to a poll option.

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

func NewInputPollOptionMedia added in v0.15.5

func NewInputPollOptionMedia(input any) InputPollOptionMedia

NewInputPollOptionMedia constructs a full-fidelity InputPollOptionMedia union.

func (InputPollOptionMedia) MarshalJSON added in v0.15.5

func (v InputPollOptionMedia) MarshalJSON() ([]byte, error)

type InputRichBlock added in v0.14.9

type InputRichBlock struct {
	// Type of the block, e.g. "paragraph", "heading", "list", etc. Reuse the RichBlockType* constants.
	Type string `json:"type,omitempty"`

	// Text: for InputRichBlockParagraph, InputRichBlockSectionHeading, InputRichBlockPreformatted,
	// InputRichBlockFooter, InputRichBlockPullQuotation, InputRichBlockThinking - text of the block.
	Text *RichText `json:"text,omitempty"`

	// Size: for InputRichBlockSectionHeading, the relative size of the text font; 1-6, 1 is the largest,
	// 6 is the smallest.
	Size int `json:"size,omitempty"`

	// Language: for InputRichBlockPreformatted, the programming language of the text.
	Language string `json:"language,omitempty"`

	// Expression: for InputRichBlockMathematicalExpression, the mathematical expression in LaTeX format.
	Expression string `json:"expression,omitempty"`

	// Name: for InputRichBlockAnchor, the name of the anchor.
	Name string `json:"name,omitempty"`

	// Items: for InputRichBlockList, the items of the list.
	Items []InputRichBlockListItem `json:"items,omitempty"`

	// Blocks: for InputRichBlockBlockQuotation, InputRichBlockCollage, InputRichBlockSlideshow,
	// InputRichBlockDetails - content/elements of the block.
	Blocks []InputRichBlock `json:"blocks,omitempty"`

	// Credit: for InputRichBlockBlockQuotation, InputRichBlockPullQuotation - credit of the block.
	Credit *RichText `json:"credit,omitempty"`

	// Caption: for InputRichBlockCollage, InputRichBlockSlideshow, InputRichBlockMap,
	// InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo,
	// InputRichBlockVoiceNote - caption of the block. Not used by InputRichBlockTable, which uses
	// TableCaption instead (see type doc comment).
	Caption *RichBlockCaption `json:"-"`

	// TableCaption: for InputRichBlockTable only, the caption of the table. See Caption for every other
	// captioned block.
	TableCaption *RichText `json:"-"`

	// Cells: for InputRichBlockTable, the cells of the table.
	Cells [][]RichBlockTableCell `json:"cells,omitempty"`

	// IsBordered: for InputRichBlockTable, pass True if the table has borders.
	IsBordered bool `json:"is_bordered,omitempty"`

	// IsStriped: for InputRichBlockTable, pass True if the table is striped.
	IsStriped bool `json:"is_striped,omitempty"`

	// Summary: for InputRichBlockDetails, the always-shown summary of the block.
	Summary *RichText `json:"summary,omitempty"`

	// IsOpen: for InputRichBlockDetails, pass True if the content of the block is visible by default.
	IsOpen bool `json:"is_open,omitempty"`

	// Location: for InputRichBlockMap, the location of the center of the map.
	Location *Location `json:"location,omitempty"`

	// Zoom: for InputRichBlockMap, the map zoom level; 0-24.
	Zoom int `json:"zoom,omitempty"`

	// Width: for InputRichBlockMap, the map width; 0-10000.
	Width int `json:"width,omitempty"`

	// Height: for InputRichBlockMap, the map height; 0-10000.
	Height int `json:"height,omitempty"`

	// Animation: for InputRichBlockAnimation, the animation. Its Caption/ParseMode/CaptionEntities/
	// ShowCaptionAboveMedia fields are ignored; use Caption on this struct instead.
	Animation *InputMediaAnimation `json:"animation,omitempty"`

	// Audio: for InputRichBlockAudio, the audio. Its Caption/ParseMode/CaptionEntities fields are
	// ignored; use Caption on this struct instead.
	Audio *InputMediaAudio `json:"audio,omitempty"`

	// Photo: for InputRichBlockPhoto, the photo. Its Caption/ParseMode/CaptionEntities/
	// ShowCaptionAboveMedia fields are ignored; use Caption on this struct instead.
	Photo *InputMediaPhoto `json:"photo,omitempty"`

	// Video: for InputRichBlockVideo, the video. Its Caption/ParseMode/CaptionEntities/
	// ShowCaptionAboveMedia fields are ignored; use Caption on this struct instead.
	Video *InputMediaVideo `json:"video,omitempty"`

	// VoiceNote: for InputRichBlockVoiceNote, the voice note. Its Caption/ParseMode/CaptionEntities
	// fields are ignored; use Caption on this struct instead.
	VoiceNote *InputMediaVoiceNote `json:"voice_note,omitempty"`
}

InputRichBlock represents a block in a rich formatted message to be sent (Bot API 10.2 Rich Messages). It is the send-side mirror of RichBlock and is a union over InputRichBlockParagraph, InputRichBlockSectionHeading, InputRichBlockPreformatted, InputRichBlockFooter, InputRichBlockDivider, InputRichBlockMathematicalExpression, InputRichBlockAnchor, InputRichBlockList, InputRichBlockBlockQuotation, InputRichBlockPullQuotation, InputRichBlockCollage, InputRichBlockSlideshow, InputRichBlockTable, InputRichBlockDetails, InputRichBlockMap, InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo, InputRichBlockVoiceNote, InputRichBlockThinking, following the same single-flattened-struct-with- Type-discriminator convention used by RichBlock (see rich_block.go). The Type discriminator values are shared with RichBlock; reuse the RichBlockType* constants (RichBlockTypeParagraph, RichBlockTypeSectionHeading, etc.) when constructing an InputRichBlock.

Being outgoing-only, InputRichBlock does not need a custom UnmarshalJSON. It does need a custom MarshalJSON for the same reason as RichBlock: the "caption" field is a RichBlockCaption for every captioned block except InputRichBlockTable, whose "caption" is a plain RichText. See Caption and TableCaption below.

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

func (InputRichBlock) MarshalJSON added in v0.14.9

func (b InputRichBlock) MarshalJSON() ([]byte, error)

MarshalJSON projects Caption/TableCaption onto the single "caption" wire field, based on Type. See RichBlock.MarshalJSON for the receive-side counterpart of this projection.

func (InputRichBlock) Validate added in v0.15.5

func (b InputRichBlock) Validate() error

Validate checks a persistent InputRichBlock. Thinking blocks are only valid through InputRichMessage.ValidateDraft.

type InputRichBlockListItem added in v0.14.9

type InputRichBlockListItem struct {
	// The content of the item
	Blocks []InputRichBlock `json:"blocks"`

	// Optional. Pass True if the item has a checkbox
	HasCheckbox bool `json:"has_checkbox,omitempty"`

	// Optional. Pass True if the item has a checked checkbox
	IsChecked bool `json:"is_checked,omitempty"`

	// Optional. For ordered lists, the numeric value of the item label
	Value int `json:"value,omitempty"`

	// Optional. For ordered lists, the type of the item label; must be one of "a" for lowercase letters,
	// "A" for uppercase letters, "i" for lowercase Roman numerals, "I" for uppercase Roman numerals, or
	// "1" for decimal numbers
	Type string `json:"type,omitempty"`
}

InputRichBlockListItem represents an item of an InputRichBlockList to be sent (Bot API 10.2 Rich Messages).

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

type InputRichMessage added in v0.14.9

type InputRichMessage struct {
	// Optional. Content of the rich message to send described as a list of blocks. Bot API 10.2+
	Blocks []InputRichBlock `json:"blocks,omitempty"`

	// Optional. Content of the rich message to send described using HTML formatting. See rich message
	// formatting options for more details. Use Media to specify the media used in the message.
	HTML string `json:"html,omitempty"`

	// Optional. Content of the rich message to send described using Markdown formatting. See rich
	// message formatting options for more details. Use Media to specify the media used in the message.
	Markdown string `json:"markdown,omitempty"`

	// Optional. List of media referenced in HTML or Markdown using tg://photo?id=, tg://video?id=, and
	// tg://audio?id= links. Bot API 10.2+
	Media []InputRichMessageMedia `json:"media,omitempty"`

	// Optional. Pass True if the rich message must be shown right-to-left
	IsRTL bool `json:"is_rtl,omitempty"`

	// Optional. Pass True to skip automatic detection of entities (e.g., URLs, email addresses,
	// username mentions, hashtags, cashtags, bot commands, or phone numbers) in the text
	SkipEntityDetection bool `json:"skip_entity_detection,omitempty"`
}

InputRichMessage describes a rich message to be sent (Bot API 10.1 Rich Messages, extended in Bot API 10.2 with Blocks and Media). Exactly one of HTML, Markdown, or Blocks must be used.

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

func (InputRichMessage) Validate added in v0.14.9

func (v InputRichMessage) Validate() error

Validate checks the persistent-message constraints recursively.

func (InputRichMessage) ValidateDraft added in v0.15.5

func (v InputRichMessage) ValidateDraft() error

ValidateDraft checks rich-message constraints while allowing the outgoing-only InputRichBlockThinking block.

type InputRichMessageContent added in v0.14.9

type InputRichMessageContent struct {

	// The message to be sent
	RichMessage InputRichMessage `json:"rich_message"`
	// contains filtered or unexported fields
}

InputRichMessageContent represents the content of a rich message to be sent as the result of an inline, guest, or Web App query (Bot API 10.1 Rich Messages).

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

func (InputRichMessageContent) Validate added in v0.14.9

func (v InputRichMessageContent) Validate() error

type InputRichMessageMedia added in v0.14.9

type InputRichMessageMedia struct {
	// Unique identifier of the media used in a tg://photo?id=, tg://video?id=, or tg://audio?id= link.
	// 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
	ID string `json:"id"`

	// The media to be sent. Must be one of *InputMediaAnimation, *InputMediaAudio, *InputMediaPhoto,
	// *InputMediaVideo, or *InputMediaVoiceNote. Everything except the media file itself and its
	// type-specific properties (e.g. width/height/duration) is ignored - in particular, any caption set
	// on the referenced InputMedia* value is ignored.
	Media any `json:"media"`
}

InputRichMessageMedia describes a media element embedded in an outgoing rich message, referenced from InputRichMessage's HTML or Markdown content via a tg://photo?id=, tg://video?id=, or tg://audio?id= link (Bot API 10.2 Rich Messages).

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

func (InputRichMessageMedia) Validate added in v0.15.5

func (v InputRichMessageMedia) Validate() error

Validate checks the media identifier and the allowed InputMedia variant.

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,omitempty"`
	RequestLocation bool                        `json:"request_location,omitempty"`
	RequestPoll     *KeyboardButtonPollType     `json:"request_poll,omitempty"`
	Webapp          *WebAppInfo                 `json:"web_app,omitempty"`

	// Optional. If specified, pressing the button will open a list of suitable bots.
	// Tapping on any of them will create a managed bot with the corresponding data. Bot API 9.6+
	RequestManagedBot *KeyboardButtonRequestManagedBot `json:"request_managed_bot,omitempty"`

	// Optional. Custom emoji identifier of the emoji that should appear on the button.
	// Available if the bot is allowed to use custom emoji in messages. Bot API 9.4+
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`

	// Optional. The color of the button. One of "primary", "success", "danger". Bot API 9.4+
	Style string `json:"style,omitempty"`
}

KeyboardButton is a button within a custom keyboard. KeyboardButton is a button within a custom keyboard. https://core.telegram.org/bots/api#keyboardbutton

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 KeyboardButtonRequestManagedBot added in v0.14.9

type KeyboardButtonRequestManagedBot struct {
	// Signed 32-bit identifier of the request. Must be unique within the message.
	RequestID int `json:"request_id"`

	// Optional. Suggested name for the bot
	SuggestedName string `json:"suggested_name,omitempty"`

	// Optional. Suggested username for the bot
	SuggestedUsername string `json:"suggested_username,omitempty"`
}

KeyboardButtonRequestManagedBot defines the parameters for the creation of a managed bot. Information about the created bot will be shared with the bot using the update managed_bot and a Message with the field managed_bot_created.

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

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 Link struct {
	// URL of the link
	URL string `json:"url"`
}

Link represents an HTTP link.

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

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 LivePhoto added in v0.14.9

type LivePhoto struct {
	// Photo, in different sizes, that is shown as the still frame of the live photo
	Photo []PhotoSize `json:"photo,omitempty"`

	// Identifier for the video part of the live photo, which can be used to download or reuse the file
	FileID string `json:"file_id"`

	// Unique identifier for the video part of the live photo, 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"`

	// Video width as defined by the sender
	Width int `json:"width,omitempty"`

	// Video height as defined by the sender
	Height int `json:"height,omitempty"`

	// Duration of the video in seconds as defined by the sender
	Duration int `json:"duration,omitempty"`

	// Optional. MIME type of the video, as defined by the sender
	MimeType string `json:"mime_type,omitempty"`

	// Optional. File size in bytes
	FileSize int `json:"file_size,omitempty"`
}

LivePhoto represents a photo with an accompanying short video, played back automatically alongside the photo.

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

type LivePhotoConfig added in v0.14.9

type LivePhotoConfig struct {
	BaseChat

	// LivePhoto should be PhotoUrl, FileID or InputFile
	Photo                 Photo  `json:"live_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"`
}

LivePhotoConfig contains information about a sendLivePhoto request.

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

func (LivePhotoConfig) TelegramMethod added in v0.14.9

func (LivePhotoConfig) TelegramMethod() string

TelegramMethod returns Telegram API method name for sending a LivePhoto.

func (LivePhotoConfig) Values added in v0.14.9

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

Values returns url.Values representation of LivePhotoConfig.

type Location

type Location struct {
	Longitude          float64 `json:"longitude"`
	Latitude           float64 `json:"latitude"`
	HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
}

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 ManagedBotCreated added in v0.14.9

type ManagedBotCreated struct {
	// Information about the bot. The bot's token can be fetched using the method getManagedBotToken.
	Bot User `json:"bot"`
}

ManagedBotCreated contains information about the bot that was created to be managed by the current bot.

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

type ManagedBotUpdated added in v0.14.9

type ManagedBotUpdated struct {
	// User that created the bot
	User User `json:"user"`

	// Information about the bot. Token of the bot can be fetched using the method getManagedBotToken.
	Bot User `json:"bot"`
}

ManagedBotUpdated contains information about the creation, token update, or owner update of a bot that is managed by the current bot.

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

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 or forum topic to which the message belongs; for supergroups and private chats only
	MessageThreadID int `json:"message_thread_id,omitempty"`

	// Optional. Information about the direct messages chat topic that contains the message
	DirectMessagesTopic *DirectMessagesTopic `json:"direct_messages_topic,omitempty"`

	// Optional. Sender of the message; may be empty for messages sent to channels
	From *User `json:"from,omitempty"`

	// Optional. Sender of the message when sent on behalf of a chat
	SenderChat *Chat `json:"sender_chat,omitempty"`

	// Optional. In Guest Mode, the user that caused the bot to receive the message and be able
	// to reply within a chat it is not a member of. Bot API 10.0+
	GuestBotCallerUser *User `json:"guest_bot_caller_user,omitempty"`

	// Optional. In Guest Mode, the chat that caused the bot to receive the message and be able
	// to reply within a chat it is not a member of. Bot API 10.0+
	GuestBotCallerChat *Chat `json:"guest_bot_caller_chat,omitempty"`

	// Optional. Unique identifier of the guest query, to be used to reply to it with answerGuestQuery. Bot API 10.0+
	GuestQueryID string `json:"guest_query_id,omitempty"`

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

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

	// Optional. Tag or custom title of the sender of the message; for supergroups only
	SenderTag string `json:"sender_tag,omitempty"`

	// Optional. For ephemeral messages, the user who received the message. Bot API 10.2+
	ReceiverUser *User `json:"receiver_user,omitempty"`

	// Optional. For ephemeral messages, identifier of the ephemeral message inside this chat. The
	// identifier may be reused for another ephemeral message after the message is deleted or expires.
	// Bot API 10.2+
	EphemeralMessageID int `json:"ephemeral_message_id,omitempty"`

	// Date the message was sent in Unix time
	Date int `json:"date"`

	// Optional. Unique identifier of the business connection from which the message was received
	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 or a private chat with the bot
	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"`

	// Optional. For replies in the same chat and message thread, the original message
	ReplyToMessage *Message `json:"reply_to_message,omitempty"`

	// Optional. Information about the message being replied to, from another chat or forum topic
	ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"`

	// Optional. For replies that quote part of the original message, the quoted part of the message
	Quote *TextQuote `json:"quote,omitempty"`

	// Optional. For replies to a story, the original story
	ReplyToStory *Story `json:"reply_to_story,omitempty"`

	// Optional. Identifier of the specific checklist task that is being replied to
	ReplyToChecklistTaskID int `json:"reply_to_checklist_task_id,omitempty"`

	// Optional. Persistent identifier of the poll option that is being replied to. Bot API 9.6+
	ReplyToPollOptionID string `json:"reply_to_poll_option_id,omitempty"`

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

	// Optional. Date the message was last edited in Unix time
	EditDate int `json:"edit_date,omitempty"`

	// Optional. True, if the message can't be forwarded
	HasProtectedContent bool `json:"has_protected_content,omitempty"`

	// Optional. True, if the message was sent by an implicit action (away or greeting business message, or scheduled)
	IsFromOffline bool `json:"is_from_offline,omitempty"`

	// Optional. True, if the message is a paid post
	IsPaidPost bool `json:"is_paid_post,omitempty"`

	// Optional. The unique identifier of a media message group this message belongs to
	MediaGroupID string `json:"media_group_id,omitempty"`

	// Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
	AuthorSignature string `json:"author_signature,omitempty"`

	// Optional. The number of Telegram Stars paid by the sender to send the message
	PaidStarCount int `json:"paid_star_count,omitempty"`

	// Optional. For text messages, the actual UTF-8 text of the message
	Text string `json:"text,omitempty"`

	// Optional. For text messages, special entities like usernames, URLs, bot commands, etc.
	Entities *[]MessageEntity `json:"entities,omitempty"`

	// Optional. Options used for link preview generation for the message
	LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`

	// Optional. Information about suggested post parameters if the message is a suggested post
	SuggestedPostInfo *SuggestedPostInfo `json:"suggested_post_info,omitempty"`

	// Optional. Message is a rich message. Bot API 10.1+
	RichMessage *RichMessage `json:"rich_message,omitempty"`

	// Optional. Unique identifier of the message effect added to the message
	EffectID string `json:"effect_id,omitempty"`

	// Optional. Message is an animation, information about the animation
	Animation *Animation `json:"animation,omitempty"`

	// Optional. Message is an audio file
	Audio *Audio `json:"audio,omitempty"`

	// Optional. Message is a general file
	Document *Document `json:"document,omitempty"`

	// Optional. Message contains paid media
	PaidMedia *PaidMediaInfo `json:"paid_media,omitempty"`

	// Optional. Message is a photo
	Photo *[]PhotoSize `json:"photo,omitempty"`

	// Optional. Message is a live photo. Bot API 10.0+
	LivePhoto *LivePhoto `json:"live_photo,omitempty"`

	// Optional. Message is a sticker
	Sticker *Sticker `json:"sticker,omitempty"`

	// Optional. Message is a forwarded story
	Story *Story `json:"story,omitempty"`

	// Optional. Message is a video
	Video *Video `json:"video,omitempty"`

	// Optional. Message is a video note
	VideoNote *VideoNote `json:"video_note,omitempty"`

	// Optional. Message is a voice message
	Voice *Voice `json:"voice,omitempty"`

	// Optional. Caption for the animation, audio, document, paid media, photo, video or voice
	Caption string `json:"caption,omitempty"`

	// Optional. For messages with a caption, special entities in the caption
	CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

	// Optional. True, if the caption must be shown above the message media
	ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`

	// Optional. True, if the message media is covered by a spoiler animation
	HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"`

	// Optional. Message is a checklist
	Checklist *Checklist `json:"checklist,omitempty"`

	// Optional. Message is a shared contact
	Contact *Contact `json:"contact,omitempty"`

	// Optional. Message is a dice with random value
	Dice *Dice `json:"dice,omitempty"`

	// Optional. Message is a game
	Game interface{} `json:"game,omitempty"`

	// Optional. Message is a native poll
	Poll *Poll `json:"poll,omitempty"`

	// Optional. Service message: a new option was added to a poll. Bot API 9.6+
	PollOptionAdded *PollOptionAdded `json:"poll_option_added,omitempty"`

	// Optional. Service message: an option was deleted from a poll. Bot API 9.6+
	PollOptionDeleted *PollOptionDeleted `json:"poll_option_deleted,omitempty"`

	// Optional. Message is a venue
	Venue *Venue `json:"venue,omitempty"`

	// Optional. Message is a shared location
	Location *Location `json:"location,omitempty"`

	// New members added to the group or supergroup
	NewChatMembers []User `json:"new_chat_members,omitempty"`

	// Optional. A member was removed from the group
	LeftChatMember *User `json:"left_chat_member,omitempty"`

	// Optional. Service message: chat owner has left
	ChatOwnerLeft *ChatOwnerLeft `json:"chat_owner_left,omitempty"`

	// Optional. Service message: chat owner has changed
	ChatOwnerChanged *ChatOwnerChanged `json:"chat_owner_changed,omitempty"`

	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

	// Optional. Service message: auto-delete timer settings changed
	MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`

	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
	// https://core.telegram.org/bots/api#payments
	Invoice *InvoiceConfig `json:"invoice,omitempty"`

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

	UserShared  *UserShared  `json:"user_shared,omitempty"`  // deprecated NON-DOCUMENTED FIELD
	UsersShared *UsersShared `json:"users_shared,omitempty"` // optional
	ChatShared  *ChatShared  `json:"chat_shared,omitempty"`

	// Optional. The domain name of the website on which the user has logged in
	ConnectedWebsite string `json:"connected_website,omitempty"`

	// Optional. Service message: the user allowed the bot to write messages
	WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"`

	// Optional. Service message. A user triggered another user's proximity alert
	ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`

	// Optional. Service message: user boosted the chat
	BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"`

	// Optional. Service message: chat background set
	ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"`

	// Optional. Service message: some tasks in a checklist were marked as done or not done
	ChecklistTasksDone *ChecklistTasksDone `json:"checklist_tasks_done,omitempty"`

	// Optional. Service message: tasks were added to a checklist
	ChecklistTasksAdded *ChecklistTasksAdded `json:"checklist_tasks_added,omitempty"`

	// Optional. Service message: chat added to a Community. Bot API 10.2+
	CommunityChatAdded *CommunityChatAdded `json:"community_chat_added,omitempty"`

	// Optional. Service message: chat removed from a Community. Bot API 10.2+
	CommunityChatRemoved *CommunityChatRemoved `json:"community_chat_removed,omitempty"`

	// Optional. Service message: the price for paid messages in the direct messages chat has changed
	DirectMessagePriceChanged *DirectMessagePriceChanged `json:"direct_message_price_changed,omitempty"`

	// Optional. Service message: forum topic created
	ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"`

	// Optional. Service message: forum topic edited
	ForumTopicEdited *ForumTopicEdited `json:"forum_topic_edited,omitempty"`

	// Optional. Service message: forum topic closed
	ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"`

	// Optional. Service message: forum topic reopened
	ForumTopicReopened *ForumTopicReopened `json:"forum_topic_reopened,omitempty"`

	// Optional. Service message: the 'General' forum topic hidden
	GeneralForumTopicHidden *GeneralForumTopicHidden `json:"general_forum_topic_hidden,omitempty"`

	// Optional. Service message: the 'General' forum topic unhidden
	GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"`

	// Optional. Service message: a scheduled giveaway was created
	GiveawayCreated *GiveawayCreated `json:"giveaway_created,omitempty"`

	// Optional. The message is a scheduled giveaway message
	Giveaway *Giveaway `json:"giveaway,omitempty"`

	// Optional. A giveaway with public winners was completed
	GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`

	// Optional. Service message: a giveaway without public winners was completed
	GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"`

	// Optional. Service message: the price for paid messages has changed in the chat
	PaidMessagePriceChanged *PaidMessagePriceChanged `json:"paid_message_price_changed,omitempty"`

	// Optional. Service message: a suggested post was approved
	SuggestedPostApproved *SuggestedPostApproved `json:"suggested_post_approved,omitempty"`

	// Optional. Service message: approval of a suggested post has failed
	SuggestedPostApprovalFailed *SuggestedPostApprovalFailed `json:"suggested_post_approval_failed,omitempty"`

	// Optional. Service message: a suggested post was declined
	SuggestedPostDeclined *SuggestedPostDeclined `json:"suggested_post_declined,omitempty"`

	// Optional. Service message: payment for a suggested post was received
	SuggestedPostPaid *SuggestedPostPaid `json:"suggested_post_paid,omitempty"`

	// Optional. Service message: payment for a suggested post was refunded
	SuggestedPostRefunded *SuggestedPostRefunded `json:"suggested_post_refunded,omitempty"`

	// Optional. Service message: video chat scheduled
	VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"`

	// Optional. Service message: video chat started
	VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"`

	// Optional. Service message: video chat ended
	VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"`

	// Optional. Service message: new participants invited to a video chat
	VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited,omitempty"`

	// Optional. Service message: data sent by a Web App
	WebAppData *WebAppData `json:"web_app_data,omitempty"`

	// Optional. Service message: upgrade of a gift was purchased
	GiftUpgradeSent *GiftInfo `json:"gift_upgrade_sent,omitempty"`

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

	// Optional. Service message: a managed bot was created. Bot API 9.6+
	ManagedBotCreated *ManagedBotCreated `json:"managed_bot_created,omitempty"`

	// Optional. Inline keyboard attached to the message
	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`

	// Deprecated: use ForwardOrigin instead
	ForwardFrom *User `json:"forward_from,omitempty"`
	// Deprecated: use ForwardOrigin instead
	ForwardDate int `json:"forward_date,omitempty"`
}

Message is returned by almost every request and contains data about almost anything. https://core.telegram.org/bots/api#message

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 MessageAutoDeleteTimerChanged added in v0.14.7

type MessageAutoDeleteTimerChanged struct {
	MessageAutoDeleteTime int `json:"message_auto_delete_time"`
}

MessageAutoDeleteTimerChanged represents a service message about a change in auto-delete timer settings. https://core.telegram.org/bots/api#messageautodeletetimerchanged

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 MessageDraftConfig added in v0.15.5

type MessageDraftConfig struct {
	ChatID          int64           `json:"chat_id"`
	MessageThreadID int64           `json:"message_thread_id,omitempty"`
	DraftID         int64           `json:"draft_id"`
	Text            string          `json:"text,omitempty"`
	ParseMode       string          `json:"parse_mode,omitempty"`
	Entities        []MessageEntity `json:"entities,omitempty"`
}

MessageDraftConfig streams a temporary text preview while a response is generated. Text may be empty to display Telegram's native “Thinking…” placeholder.

func (MessageDraftConfig) TelegramMethod added in v0.15.5

func (MessageDraftConfig) TelegramMethod() string

func (MessageDraftConfig) Values added in v0.15.5

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

type MessageEntity

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

	// Optional. For "text_mention" only, the mentioned user
	User *User `json:"user,omitempty"`

	// Optional. For "pre" only, the programming language of the entity text
	Language string `json:"language,omitempty"`

	// Optional. For "custom_emoji" only, unique identifier of the custom emoji
	CustomEmojiID string `json:"custom_emoji_id,omitempty"`

	// Optional. For "date_time" only, the Unix time associated with the entity
	UnixTime int `json:"unix_time,omitempty"`

	// Optional. For "date_time" only, the string that defines the formatting of the date and time
	DateTimeFormat string `json:"date_time_format,omitempty"`
}

MessageEntity contains information about data in a Message. https://core.telegram.org/bots/api#messageentity

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 MessageReactionCountUpdated added in v0.14.7

type MessageReactionCountUpdated struct {
	Chat      Chat            `json:"chat"`
	MessageID int             `json:"message_id"`
	Date      int             `json:"date"`
	Reactions []ReactionCount `json:"reactions"`
}

MessageReactionCountUpdated represents reaction changes on a message with anonymous reactions. https://core.telegram.org/bots/api#messagereactioncountupdated

type MessageReactionUpdated added in v0.14.7

type MessageReactionUpdated struct {
	Chat        Chat           `json:"chat"`
	MessageID   int            `json:"message_id"`
	User        *User          `json:"user,omitempty"`
	ActorChat   *Chat          `json:"actor_chat,omitempty"`
	Date        int            `json:"date"`
	OldReaction []ReactionType `json:"old_reaction"`
	NewReaction []ReactionType `json:"new_reaction"`
}

MessageReactionUpdated represents a change of a reaction on a message performed by a user. https://core.telegram.org/bots/api#messagereactionupdated

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 PaidMedia added in v0.14.7

type PaidMedia struct {
	// Type of the paid media — "preview", "photo", or "video"
	Type string `json:"type"`

	// For "preview": media width if known
	Width int `json:"width,omitempty"`

	// For "preview": media height if known
	Height int `json:"height,omitempty"`

	// For "preview": duration of the media in seconds if known
	Duration int `json:"duration,omitempty"`

	// For "photo": the photo
	Photo []PhotoSize `json:"photo,omitempty"`

	// For "video": the video
	Video *Video `json:"video,omitempty"`

	// For "live_photo": the live photo. Bot API 10.0+
	LivePhoto *LivePhoto `json:"live_photo,omitempty"`
}

PaidMedia describes paid media. It can be one of: - PaidMediaPreview - PaidMediaPhoto - PaidMediaVideo - PaidMediaLivePhoto (Bot API 10.0+) https://core.telegram.org/bots/api#paidmedia

type PaidMediaInfo added in v0.14.7

type PaidMediaInfo struct {
	StarCount int         `json:"star_count"`
	PaidMedia []PaidMedia `json:"paid_media"`
}

PaidMediaInfo describes the paid media added to a message. https://core.telegram.org/bots/api#paidmediainfo

type PaidMediaLivePhoto added in v0.14.9

type PaidMediaLivePhoto struct {
	// Type of the paid media, always "live_photo"
	Type string `json:"type"`

	// The live photo
	LivePhoto LivePhoto `json:"live_photo"`
}

PaidMediaLivePhoto describes a paid media that is a live photo.

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

type PaidMediaPurchased added in v0.14.7

type PaidMediaPurchased struct {
	From             User   `json:"from"`
	PaidMediaPayload string `json:"paid_media_payload"`
}

PaidMediaPurchased contains information about a paid media purchase. https://core.telegram.org/bots/api#paidmediapurchased

type PaidMessagePriceChanged added in v0.14.7

type PaidMessagePriceChanged struct {
	PaidMessageStarCount int `json:"paid_message_star_count"`
}

PaidMessagePriceChanged represents a service message about a change in the price of paid messages. https://core.telegram.org/bots/api#paidmessagepricechanged

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 Poll added in v0.14.7

type Poll struct {
	ID                    string          `json:"id"`
	Question              string          `json:"question"`
	QuestionEntities      []MessageEntity `json:"question_entities,omitempty"`
	Options               []PollOption    `json:"options"`
	TotalVoterCount       int             `json:"total_voter_count"`
	IsClosed              bool            `json:"is_closed"`
	IsAnonymous           bool            `json:"is_anonymous"`
	Type                  string          `json:"type"`
	AllowsMultipleAnswers bool            `json:"allows_multiple_answers"`

	// 0-based identifiers of correct answer options. Optional, returned only for polls in quiz mode
	// and only to the chat member who created the poll if the poll is not closed.
	// Replaces the deprecated single-value CorrectOptionID. Bot API 9.6+
	CorrectOptionIDs []int `json:"correct_option_ids,omitempty"`

	Explanation         string          `json:"explanation,omitempty"`
	ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
	OpenPeriod          int             `json:"open_period,omitempty"`
	CloseDate           int             `json:"close_date,omitempty"`

	// Optional. True, if the poll allows to change the chosen answer options. Bot API 9.6+
	AllowsRevoting bool `json:"allows_revoting,omitempty"`

	// Optional. Description of the poll. Bot API 9.6+
	Description string `json:"description,omitempty"`

	// Optional. Special entities that appear in the poll description. Bot API 9.6+
	DescriptionEntities []MessageEntity `json:"description_entities,omitempty"`

	// Optional. Media attached to the poll. Bot API 10.0+
	Media *PollMedia `json:"media,omitempty"`

	// Optional. Media attached to the quiz explanation. Bot API 10.0+
	ExplanationMedia *PollMedia `json:"explanation_media,omitempty"`

	// Optional. True, if the poll can be voted only by members of the chat it was sent to. Bot API 10.0+
	MembersOnly bool `json:"members_only,omitempty"`

	// Optional. A list of two-letter ISO 3166-1 alpha-2 country codes the poll is restricted to. Bot API 10.0+
	CountryCodes []string `json:"country_codes,omitempty"`
}

Poll contains information about a poll. https://core.telegram.org/bots/api#poll

type PollAnswer added in v0.14.7

type PollAnswer struct {
	PollID    string `json:"poll_id"`
	VoterChat *Chat  `json:"voter_chat,omitempty"`
	User      *User  `json:"user,omitempty"`
	OptionIDs []int  `json:"option_ids"`

	// Optional. Persistent identifiers of the chosen options. Bot API 9.6+
	OptionPersistentIDs []string `json:"option_persistent_ids,omitempty"`
}

PollAnswer represents an answer of a user in a non-anonymous poll. https://core.telegram.org/bots/api#pollanswer

type PollConfig added in v0.14.9

type PollConfig struct {
	BaseChat

	// Poll question, 1-300 characters
	Question string `json:"question"`

	// Optional. Mode for parsing entities in the question. Currently, only custom emoji entities are allowed.
	QuestionParseMode string `json:"question_parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the poll question.
	// It can be specified instead of question_parse_mode.
	QuestionEntities []MessageEntity `json:"question_entities,omitempty"`

	// A JSON-serialized list of 1-12 answer options
	Options []InputPollOption `json:"options"`

	// Optional. Media to attach to the poll. Bot API 10.0+
	Media *InputPollMedia `json:"media,omitempty"`

	// Optional. True, if the poll needs to be anonymous, defaults to True.
	// NOTE: because the zero value of bool is false, this config can't distinguish
	// "not set" from "explicitly false"; leaving it unset sends nothing to Telegram
	// and the anonymous default applies. To send a non-anonymous poll, this field
	// must be explicitly set to true when marshalling is not desired - see Values().
	IsAnonymous bool `json:"is_anonymous,omitempty"`

	// Optional. Poll type, "quiz" or "regular", defaults to "regular"
	Type string `json:"type,omitempty"`

	// Optional. Pass True if the poll allows multiple answers, defaults to False.
	// Bot API 9.6 allows this to be combined with quiz-mode polls that have multiple correct answers.
	AllowsMultipleAnswers bool `json:"allows_multiple_answers,omitempty"`

	// Optional. Pass True if the poll allows to change the chosen answer options,
	// defaults to False for quizzes and to True for regular polls. Bot API 9.6+
	AllowsRevoting bool `json:"allows_revoting,omitempty"`

	// Optional. Pass True if the poll options must be shown in random order. Bot API 9.6+
	ShuffleOptions bool `json:"shuffle_options,omitempty"`

	// Optional. Pass True if answer options can be added to the poll after creation;
	// not supported for anonymous polls and quizzes. Bot API 9.6+
	AllowAddingOptions bool `json:"allow_adding_options,omitempty"`

	// Optional. Pass True if poll results must be shown only after the poll closes. Bot API 9.6+
	HideResultsUntilCloses bool `json:"hide_results_until_closes,omitempty"`

	// Optional. 0-based identifiers of the correct answer options, required for polls in quiz mode.
	// Supports multiple correct answers as of Bot API 9.6.
	CorrectOptionIDs []int `json:"correct_option_ids,omitempty"`

	// Optional. Text shown when a user chooses an incorrect answer or taps the lamp icon in a quiz
	Explanation string `json:"explanation,omitempty"`

	// Optional. Mode for parsing entities in the explanation.
	ExplanationParseMode string `json:"explanation_parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the poll explanation.
	ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`

	// Optional. Media to attach to the quiz explanation. Bot API 10.0+
	ExplanationMedia *InputPollMedia `json:"explanation_media,omitempty"`

	// Optional. Amount of time in seconds the poll will be active after creation, 5-2628000.
	// Can't be used together with CloseDate.
	OpenPeriod int `json:"open_period,omitempty"`

	// Optional. Point in time (Unix timestamp) when the poll will be automatically closed.
	// Can't be used together with OpenPeriod.
	CloseDate int `json:"close_date,omitempty"`

	// Optional. Pass True if the poll needs to be immediately closed.
	IsClosed bool `json:"is_closed,omitempty"`

	// Optional. Description of the poll to be sent, 0-1024 characters after entities parsing. Bot API 9.6+
	Description string `json:"description,omitempty"`

	// Optional. Mode for parsing entities in the poll description. Bot API 9.6+
	DescriptionParseMode string `json:"description_parse_mode,omitempty"`

	// Optional. A JSON-serialized list of special entities that appear in the poll description,
	// which can be specified instead of DescriptionParseMode. Bot API 9.6+
	DescriptionEntities []MessageEntity `json:"description_entities,omitempty"`

	// Optional. Pass True if the poll can be voted only by members of the chat it is sent to. Bot API 10.0+
	MembersOnly bool `json:"members_only,omitempty"`

	// Optional. A JSON-serialized list of two-letter ISO 3166-1 alpha-2 country codes the poll is
	// restricted to. Bot API 10.0+
	CountryCodes []string `json:"country_codes,omitempty"`
}

PollConfig contains information about a sendPoll request. https://core.telegram.org/bots/api#sendpoll

func (*PollConfig) TelegramMethod added in v0.14.9

func (*PollConfig) TelegramMethod() string

TelegramMethod returns Telegram API method name for sending a Poll.

func (*PollConfig) Values added in v0.14.9

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

Values returns url.Values representation of PollConfig.

type PollMedia added in v0.14.9

type PollMedia struct {
	// Optional. Media is an animation
	Animation *Animation `json:"animation,omitempty"`

	// Optional. Media is an audio file
	Audio *Audio `json:"audio,omitempty"`

	// Optional. Media is a general file
	Document *Document `json:"document,omitempty"`

	// Optional. The HTTP link attached to the poll option. Bot API 10.1+
	Link *Link `json:"link,omitempty"`

	// Optional. Media is a live photo
	LivePhoto *LivePhoto `json:"live_photo,omitempty"`

	// Optional. Media is a shared location
	Location *Location `json:"location,omitempty"`

	// Optional. Media is a photo
	Photo []PhotoSize `json:"photo,omitempty"`

	// Optional. Media is a sticker
	Sticker *Sticker `json:"sticker,omitempty"`

	// Optional. Media is a venue
	Venue *Venue `json:"venue,omitempty"`

	// Optional. Media is a video
	Video *Video `json:"video,omitempty"`
}

PollMedia describes media attached to a poll, a poll's quiz explanation, or a poll option. At most one of the fields is expected to be set.

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

type PollOption added in v0.14.7

type PollOption struct {
	// Unique persistent identifier of the option. Bot API 9.6+
	PersistentID string          `json:"persistent_id"`
	Text         string          `json:"text"`
	TextEntities []MessageEntity `json:"text_entities,omitempty"`
	VoterCount   int             `json:"voter_count"`

	// Optional. User that added the option, if it was added after the poll was created. Bot API 9.6+
	AddedByUser *User `json:"added_by_user,omitempty"`

	// Optional. Chat that added the option, if it was added after the poll was created. Bot API 9.6+
	AddedByChat *Chat `json:"added_by_chat,omitempty"`

	// Optional. Date when the option was added, in Unix time. Bot API 9.6+
	AdditionDate int `json:"addition_date,omitempty"`

	// Optional. Media attached to the option. Bot API 10.0+
	Media *PollMedia `json:"media,omitempty"`
}

PollOption contains information about one answer option in a poll. https://core.telegram.org/bots/api#polloption

type PollOptionAdded added in v0.14.9

type PollOptionAdded struct {
	// Optional. Message containing the poll
	PollMessage *Message `json:"poll_message,omitempty"`

	// Unique identifier of the added option
	OptionPersistentID string `json:"option_persistent_id"`

	// Option text
	OptionText string `json:"option_text"`

	// Optional. Special entities that appear in the option text
	OptionTextEntities []MessageEntity `json:"option_text_entities,omitempty"`
}

PollOptionAdded describes a service message about a new option being added to a poll.

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

type PollOptionDeleted added in v0.14.9

type PollOptionDeleted struct {
	// Optional. Message containing the poll
	PollMessage *Message `json:"poll_message,omitempty"`

	// Unique identifier of the deleted option
	OptionPersistentID string `json:"option_persistent_id"`

	// Option text
	OptionText string `json:"option_text"`

	// Optional. Special entities that appear in the option text
	OptionTextEntities []MessageEntity `json:"option_text_entities,omitempty"`
}

PollOptionDeleted describes a service message about an option being deleted from a poll.

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

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 PreparedKeyboardButton added in v0.14.9

type PreparedKeyboardButton struct {
	// Unique identifier of the keyboard button
	ID string `json:"id"`
}

PreparedKeyboardButton describes a keyboard button to be used by a user of a Mini App.

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

type ProximityAlertTriggered added in v0.14.7

type ProximityAlertTriggered struct {
	Traveler User `json:"traveler"`
	Watcher  User `json:"watcher"`
	Distance int  `json:"distance"`
}

ProximityAlertTriggered represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user. https://core.telegram.org/bots/api#proximityalerttriggered

type ReactionCount added in v0.14.7

type ReactionCount struct {
	Type       ReactionType `json:"type"`
	TotalCount int          `json:"total_count"`
}

ReactionCount represents a reaction added to a message along with the number of times it was added. https://core.telegram.org/bots/api#reactioncount

type ReactionType added in v0.14.7

type ReactionType struct {
	// Type of the reaction — "emoji", "custom_emoji", or "paid"
	Type string `json:"type"`

	// For "emoji": the emoji itself
	Emoji string `json:"emoji,omitempty"`

	// For "custom_emoji": custom emoji identifier
	CustomEmojiID string `json:"custom_emoji_id,omitempty"`
}

ReactionType describes a reaction type. Currently, it can be one of: - ReactionTypeEmoji - ReactionTypeCustomEmoji - ReactionTypePaid https://core.telegram.org/bots/api#reactiontype

type RefundStarPaymentConfig added in v0.15.0

type RefundStarPaymentConfig struct {
	UserID                  int64  `json:"user_id"`                    // Identifier of the user whose payment will be refunded.
	TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` // Telegram payment identifier of the charge to refund.
}

RefundStarPaymentConfig refunds a successful payment in Telegram Stars. https://core.telegram.org/bots/api#refundstarpayment

Refunding needs BOTH the payer's user id and the telegram_payment_charge_id from the successful_payment update (there is no retrieve-charge API to recover one from the other). Returns True on success.

func (*RefundStarPaymentConfig) TelegramMethod added in v0.15.0

func (*RefundStarPaymentConfig) TelegramMethod() string

func (*RefundStarPaymentConfig) Values added in v0.15.0

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

Values returns the url.Values representation of RefundStarPaymentConfig.

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 {
	// Optional. Identifier of the message that will be replied to in the current chat, or in the chat
	// ChatIDInt/ChatIDStr if specified. Required if EphemeralMessageID isn't specified.
	MessageID int64 `json:"message_id,omitempty"`

	// 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  `json:"-"`
	ChatIDStr string `json:"-"`

	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

	// Optional. Persistent identifier of the poll option to reply to. Bot API 9.6+
	PollOptionID string `json:"poll_option_id,omitempty"`

	// Optional. Identifier of the incoming ephemeral message that will be replied to in the current
	// chat. A reply to an ephemeral message must itself be an ephemeral message. An ephemeral message
	// may only be replied to within 15 seconds of being sent. Required if MessageID isn't specified;
	// MessageID and EphemeralMessageID are mutually exclusive - set exactly one. Bot API 10.2+
	EphemeralMessageID int64 `json:"ephemeral_message_id,omitempty"`
}

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

func (ReplyParameters) MarshalJSON added in v0.12.0

func (v ReplyParameters) MarshalJSON() ([]byte, error)

MarshalJSON emits the polymorphic chat_id field under Telegram's exact wire name while retaining the historical typed ChatIDInt/ChatIDStr Go API.

func (ReplyParameters) Validate added in v0.15.5

func (v ReplyParameters) Validate() error

Validate checks the mutually exclusive reply target and formatting fields.

type RichBlock added in v0.14.9

type RichBlock struct {
	// Type of the block, e.g. "paragraph", "heading", "list", etc.
	Type string `json:"type,omitempty"`

	// Text: for RichBlockParagraph, RichBlockSectionHeading, RichBlockPreformatted, RichBlockFooter,
	// RichBlockPullQuotation, RichBlockThinking - text of the block.
	Text *RichText `json:"text,omitempty"`

	// Size: for RichBlockSectionHeading, the relative size of the text font; 1-6, 1 is the largest,
	// 6 is the smallest.
	Size int `json:"size,omitempty"`

	// Language: for RichBlockPreformatted, the programming language of the text.
	Language string `json:"language,omitempty"`

	// Expression: for RichBlockMathematicalExpression, the mathematical expression in LaTeX format.
	Expression string `json:"expression,omitempty"`

	// Name: for RichBlockAnchor, the name of the anchor.
	Name string `json:"name,omitempty"`

	// Items: for RichBlockList, the items of the list.
	Items []RichBlockListItem `json:"items,omitempty"`

	// Blocks: for RichBlockBlockQuotation, RichBlockCollage, RichBlockSlideshow, RichBlockDetails -
	// content/elements of the block.
	Blocks []RichBlock `json:"blocks,omitempty"`

	// Credit: for RichBlockBlockQuotation, RichBlockPullQuotation - credit of the block.
	Credit *RichText `json:"credit,omitempty"`

	// Caption: for RichBlockCollage, RichBlockSlideshow, RichBlockMap, RichBlockAnimation, RichBlockAudio,
	// RichBlockPhoto, RichBlockVideo, RichBlockVoiceNote - caption of the block. Not used by
	// RichBlockTable, which uses TableCaption instead (see type doc comment).
	Caption *RichBlockCaption `json:"-"`

	// TableCaption: for RichBlockTable only, the caption of the table. See Caption for every other
	// captioned block.
	TableCaption *RichText `json:"-"`

	// Cells: for RichBlockTable, the cells of the table.
	Cells [][]RichBlockTableCell `json:"cells,omitempty"`

	// IsBordered: for RichBlockTable, true if the table has borders.
	IsBordered bool `json:"is_bordered,omitempty"`

	// IsStriped: for RichBlockTable, true if the table is striped.
	IsStriped bool `json:"is_striped,omitempty"`

	// Summary: for RichBlockDetails, the always-shown summary of the block.
	Summary *RichText `json:"summary,omitempty"`

	// IsOpen: for RichBlockDetails, true if the content of the block is visible by default.
	IsOpen bool `json:"is_open,omitempty"`

	// Location: for RichBlockMap, the location of the center of the map.
	Location *Location `json:"location,omitempty"`

	// Zoom: for RichBlockMap, the map zoom level; 13-20.
	Zoom int `json:"zoom,omitempty"`

	// Width: for RichBlockMap, the expected width of the map.
	Width int `json:"width,omitempty"`

	// Height: for RichBlockMap, the expected height of the map.
	Height int `json:"height,omitempty"`

	// Animation: for RichBlockAnimation, the animation.
	Animation *Animation `json:"animation,omitempty"`

	// HasSpoiler: for RichBlockAnimation, RichBlockPhoto, RichBlockVideo - true if the media preview is
	// covered by a spoiler animation.
	HasSpoiler bool `json:"has_spoiler,omitempty"`

	// Audio: for RichBlockAudio, the audio.
	Audio *Audio `json:"audio,omitempty"`

	// Photo: for RichBlockPhoto, the available sizes of the photo.
	Photo []PhotoSize `json:"photo,omitempty"`

	// Video: for RichBlockVideo, the video.
	Video *Video `json:"video,omitempty"`

	// VoiceNote: for RichBlockVoiceNote, the voice note.
	VoiceNote *Voice `json:"voice_note,omitempty"`
}

RichBlock represents a block in a rich formatted message (Bot API 10.1 Rich Messages). It is a union over RichBlockParagraph, RichBlockSectionHeading, RichBlockPreformatted, RichBlockFooter, RichBlockDivider, RichBlockMathematicalExpression, RichBlockAnchor, RichBlockList, RichBlockBlockQuotation, RichBlockPullQuotation, RichBlockCollage, RichBlockSlideshow, RichBlockTable, RichBlockDetails, RichBlockMap, RichBlockAnimation, RichBlockAudio, RichBlockPhoto, RichBlockVideo, RichBlockVoiceNote, RichBlockThinking, following the same single-flattened-struct-with-Type- discriminator convention used elsewhere in this package for unions (see PaidMedia, PollMedia).

The "caption" field is the one exception: RichBlockTable's caption is a RichText, while every other captioned block's caption is a RichBlockCaption. Since a single Go field can't carry both wire shapes under the same "caption" JSON key, this struct keeps them as two distinct fields (Caption and TableCaption) and a custom MarshalJSON/UnmarshalJSON pair projects whichever one applies, based on Type, onto the single "caption" key on the wire.

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

func (RichBlock) MarshalJSON added in v0.14.9

func (b RichBlock) MarshalJSON() ([]byte, error)

MarshalJSON projects Caption/TableCaption onto the single "caption" wire field, based on Type.

func (*RichBlock) UnmarshalJSON added in v0.14.9

func (b *RichBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON extracts the "caption" wire field into Caption or TableCaption, based on Type.

type RichBlockCaption added in v0.14.9

type RichBlockCaption struct {
	// Block caption
	Text RichText `json:"text"`

	// Optional. Block credit which corresponds to the HTML tag <cite>
	Credit *RichText `json:"credit,omitempty"`
}

RichBlockCaption describes the caption of a rich formatted block (Bot API 10.1 Rich Messages).

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

type RichBlockListItem added in v0.14.9

type RichBlockListItem struct {
	// Label of the item
	Label string `json:"label"`

	// The content of the item
	Blocks []RichBlock `json:"blocks"`

	// Optional. True, if the item has a checkbox
	HasCheckbox bool `json:"has_checkbox,omitempty"`

	// Optional. True, if the item has a checked checkbox
	IsChecked bool `json:"is_checked,omitempty"`

	// Optional. For ordered lists, the numeric value of the item label
	Value int `json:"value,omitempty"`

	// Optional. For ordered lists, the type of the item label; must be one of "a" for lowercase letters,
	// "A" for uppercase letters, "i" for lowercase Roman numerals, "I" for uppercase Roman numerals, or
	// "1" for decimal numbers
	Type string `json:"type,omitempty"`
}

RichBlockListItem represents an item of a RichBlockList (Bot API 10.1 Rich Messages).

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

type RichBlockTableCell added in v0.14.9

type RichBlockTableCell struct {
	// Optional. Text in the cell. If omitted, the cell is invisible.
	Text *RichText `json:"text,omitempty"`

	// Optional. True, if the cell is a header cell
	IsHeader bool `json:"is_header,omitempty"`

	// Optional. The number of columns the cell spans if it is bigger than 1
	Colspan int `json:"colspan,omitempty"`

	// Optional. The number of rows the cell spans if it is bigger than 1
	Rowspan int `json:"rowspan,omitempty"`

	// Horizontal cell content alignment. Currently, must be one of "left", "center", or "right".
	Align string `json:"align,omitempty"`

	// Vertical cell content alignment. Currently, must be one of "top", "middle", or "bottom".
	Valign string `json:"valign,omitempty"`
}

RichBlockTableCell represents a cell in a RichBlockTable (Bot API 10.1 Rich Messages).

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

type RichMessage added in v0.14.9

type RichMessage struct {
	// Content of the message
	Blocks []RichBlock `json:"blocks"`

	// Optional. True, if the rich message must be shown right-to-left
	IsRTL bool `json:"is_rtl,omitempty"`
}

RichMessage represents a rich formatted message (Bot API 10.1 Rich Messages).

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

type RichMessageConfig added in v0.14.9

type RichMessageConfig struct {
	BaseChat

	// The message to be sent
	RichMessage InputRichMessage `json:"rich_message"`
}

RichMessageConfig contains information about a sendRichMessage request.

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

func (RichMessageConfig) TelegramMethod added in v0.14.9

func (RichMessageConfig) TelegramMethod() string

TelegramMethod returns Telegram API method name for sending a RichMessage.

func (RichMessageConfig) Values added in v0.14.9

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

Values returns url.Values representation of RichMessageConfig.

type RichMessageDraftConfig added in v0.14.9

type RichMessageDraftConfig struct {
	// Unique identifier for the target private chat
	ChatID int64 `json:"chat_id"`

	// Optional. Unique identifier for the target message thread
	MessageThreadID int64 `json:"message_thread_id,omitempty"`

	// Unique identifier of the message draft; must be non-zero. Changes to drafts with the same
	// identifier are animated.
	DraftID int64 `json:"draft_id"`

	// The partial message to be streamed. Direct upload of new files isn't supported.
	RichMessage InputRichMessage `json:"rich_message"`
}

RichMessageDraftConfig contains information about a sendRichMessageDraft request, used to stream a partial rich message to a user while it is being generated. The streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, RichMessageConfig must be sent with the complete message to persist it in the user's chat. Returns True on success, so this should be sent via BotAPI.SendCustomMessage rather than BotAPI.Send.

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

func (RichMessageDraftConfig) TelegramMethod added in v0.14.9

func (RichMessageDraftConfig) TelegramMethod() string

TelegramMethod returns Telegram API method name for streaming a RichMessage draft.

func (RichMessageDraftConfig) Values added in v0.14.9

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

Values returns url.Values representation of RichMessageDraftConfig.

type RichText added in v0.14.9

type RichText struct {
	// Type of the rich text, e.g. "bold", "italic", "url", etc. Empty when this RichText is plain text
	// (see PlainText) or a list of nested rich texts (see Items).
	Type string `json:"type,omitempty"`

	// PlainText holds the value when this RichText is encoded on the wire as a bare JSON string rather
	// than an object or array. Not itself a Bot API JSON field; see MarshalJSON/UnmarshalJSON.
	PlainText string `json:"-"`

	// Items holds the value when this RichText is encoded on the wire as a JSON array of RichText.
	// Not itself a Bot API JSON field; see MarshalJSON/UnmarshalJSON.
	Items []RichText `json:"-"`

	// Text is the nested rich text wrapped by most format variants: RichTextBold, RichTextItalic,
	// RichTextUnderline, RichTextStrikethrough, RichTextSpoiler, RichTextDateTime, RichTextTextMention,
	// RichTextSubscript, RichTextSuperscript, RichTextMarked, RichTextCode, RichTextUrl,
	// RichTextEmailAddress, RichTextPhoneNumber, RichTextBankCardNumber, RichTextMention, RichTextHashtag,
	// RichTextCashtag, RichTextBotCommand, RichTextAnchorLink, RichTextReference, RichTextReferenceLink.
	Text *RichText `json:"text,omitempty"`

	// UnixTime: for RichTextDateTime, the Unix time associated with the entity.
	// https://core.telegram.org/bots/api#richtextdatetime
	UnixTime int `json:"unix_time,omitempty"`

	// DateTimeFormat: for RichTextDateTime, the string that defines the formatting of the date and time.
	DateTimeFormat string `json:"date_time_format,omitempty"`

	// User: for RichTextTextMention, the mentioned user.
	// https://core.telegram.org/bots/api#richtexttextmention
	User *User `json:"user,omitempty"`

	// CustomEmojiID: for RichTextCustomEmoji, the unique identifier of the custom emoji. Use
	// GetCustomEmojiStickers to get full information about the sticker.
	// https://core.telegram.org/bots/api#richtextcustomemoji
	CustomEmojiID string `json:"custom_emoji_id,omitempty"`

	// AlternativeText: for RichTextCustomEmoji, the alternative emoji for the custom emoji.
	AlternativeText string `json:"alternative_text,omitempty"`

	// Expression: for RichTextMathematicalExpression, the expression in LaTeX format.
	// https://core.telegram.org/bots/api#richtextmathematicalexpression
	Expression string `json:"expression,omitempty"`

	// URL: for RichTextUrl, the URL of the link.
	// https://core.telegram.org/bots/api#richtexturl
	URL string `json:"url,omitempty"`

	// EmailAddress: for RichTextEmailAddress, the email address.
	EmailAddress string `json:"email_address,omitempty"`

	// PhoneNumber: for RichTextPhoneNumber, the phone number.
	PhoneNumber string `json:"phone_number,omitempty"`

	// BankCardNumber: for RichTextBankCardNumber, the bank card number.
	BankCardNumber string `json:"bank_card_number,omitempty"`

	// Username: for RichTextMention, the mentioned username.
	Username string `json:"username,omitempty"`

	// Hashtag: for RichTextHashtag, the hashtag.
	Hashtag string `json:"hashtag,omitempty"`

	// Cashtag: for RichTextCashtag, the cashtag.
	Cashtag string `json:"cashtag,omitempty"`

	// BotCommand: for RichTextBotCommand, the bot command.
	BotCommand string `json:"bot_command,omitempty"`

	// Name: for RichTextAnchor, the name of the anchor. For RichTextReference, the name of the reference.
	Name string `json:"name,omitempty"`

	// AnchorName: for RichTextAnchorLink, the name of the anchor being linked to. If empty, the link
	// brings back to the top of the message.
	AnchorName string `json:"anchor_name,omitempty"`

	// ReferenceName: for RichTextReferenceLink, the name of the reference being linked to.
	ReferenceName string `json:"reference_name,omitempty"`
}

RichText represents a rich formatted text (Bot API 10.1 Rich Messages). On the wire, RichText can be encoded as a bare JSON string (plain text), a JSON array of RichText, or a JSON object with a "type" discriminator identifying one of the RichText* variants (RichTextBold, RichTextItalic, RichTextUnderline, RichTextStrikethrough, RichTextSpoiler, RichTextDateTime, RichTextTextMention, RichTextSubscript, RichTextSuperscript, RichTextMarked, RichTextCode, RichTextCustomEmoji, RichTextMathematicalExpression, RichTextUrl, RichTextEmailAddress, RichTextPhoneNumber, RichTextBankCardNumber, RichTextMention, RichTextHashtag, RichTextCashtag, RichTextBotCommand, RichTextAnchor, RichTextAnchorLink, RichTextReference, RichTextReferenceLink).

This follows the same single-flattened-struct-with-Type-discriminator convention used elsewhere in this package for unions (see PaidMedia, PollMedia), extended with a custom MarshalJSON/UnmarshalJSON pair to additionally support the plain-string and array wire encodings that RichText, uniquely among this package's unions, also allows.

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

func (RichText) MarshalJSON added in v0.14.9

func (r RichText) MarshalJSON() ([]byte, error)

MarshalJSON implements the three-shape RichText wire encoding: a bare JSON string for plain text, a JSON array for a list of nested rich texts, or a JSON object for a named format variant.

func (*RichText) UnmarshalJSON added in v0.14.9

func (r *RichText) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the three-shape RichText wire encoding: a bare JSON string for plain text, a JSON array for a list of nested rich texts, or a JSON object for a named format variant.

func (RichText) Validate added in v0.15.5

func (r RichText) Validate() error

Validate checks the three RichText wire shapes and recursively validates object/array-shaped content.

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 SentGuestMessage added in v0.14.9

type SentGuestMessage struct {
	// Unique identifier of the inline message sent by the guest bot.
	InlineMessageID string `json:"inline_message_id"`
}

SentGuestMessage describes a message sent by the bot in reply to a guest query, i.e. a message sent within a chat the bot is not a member of via Guest Mode.

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

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 ShippingQuery added in v0.14.7

type ShippingQuery struct {
	ID              string          `json:"id"`
	From            User            `json:"from"`
	InvoicePayload  string          `json:"invoice_payload"`
	ShippingAddress ShippingAddress `json:"shipping_address"`
}

ShippingQuery contains information about an incoming shipping query. https://core.telegram.org/bots/api#shippingquery

type Sticker

type Sticker struct {
	FileID       string     `json:"file_id"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	Type         string     `json:"type,omitempty"`
	Width        int        `json:"width"`
	Height       int        `json:"height"`
	IsAnimated   bool       `json:"is_animated,omitempty"`
	IsVideo      bool       `json:"is_video,omitempty"`
	Thumbnail    *PhotoSize `json:"thumbnail,omitempty"` // optional
	Emoji        string     `json:"emoji,omitempty"`
	SetName      string     `json:"set_name,omitempty"`
	FileSize     int        `json:"file_size,omitempty"` // optional
}

Sticker contains information about a sticker. https://core.telegram.org/bots/api#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 Story added in v0.14.7

type Story struct {
	Chat *Chat `json:"chat"`
	ID   int   `json:"id"`
}

Story represents a message about a forwarded story in the chat. https://core.telegram.org/bots/api#story

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 SuggestedPostApprovalFailed added in v0.14.7

type SuggestedPostApprovalFailed struct{}

SuggestedPostApprovalFailed represents a service message about the failed approval of a suggested post. https://core.telegram.org/bots/api#suggestedpostapprovalfailed

type SuggestedPostApproved added in v0.14.7

type SuggestedPostApproved struct {
	PostDate int `json:"post_date"`
}

SuggestedPostApproved represents a service message about the approval of a suggested post. https://core.telegram.org/bots/api#suggestedpostapproved

type SuggestedPostDeclined added in v0.14.7

type SuggestedPostDeclined struct{}

SuggestedPostDeclined represents a service message about the rejection of a suggested post. https://core.telegram.org/bots/api#suggestedpostdeclined

type SuggestedPostInfo added in v0.14.7

type SuggestedPostInfo struct {
	State    string              `json:"state"`
	Price    *SuggestedPostPrice `json:"price,omitempty"`
	SendDate int                 `json:"send_date,omitempty"`

	// Deprecated: pre-release bindings used suggested_post_date. Retained for
	// decoding stored updates; current Telegram updates use SendDate.
	SuggestedPostDate int `json:"suggested_post_date,omitempty"`
}

SuggestedPostInfo contains information about suggested post parameters. https://core.telegram.org/bots/api#suggestedpostinfo

type SuggestedPostPaid added in v0.14.7

type SuggestedPostPaid struct {
	StarCount int `json:"star_count"`
}

SuggestedPostPaid represents a service message about a successful payment for a suggested post. https://core.telegram.org/bots/api#suggestedpostpaid

type SuggestedPostParameters added in v0.15.5

type SuggestedPostParameters struct {
	Price    *SuggestedPostPrice `json:"price,omitempty"`
	SendDate int64               `json:"send_date,omitempty"`
}

SuggestedPostParameters contains parameters of a post suggested by the bot.

type SuggestedPostPrice added in v0.14.7

type SuggestedPostPrice struct {
	Currency string `json:"currency"`
	Amount   int64  `json:"amount"`
}

SuggestedPostPrice describes the price of a suggested post. https://core.telegram.org/bots/api#suggestedpostprice

type SuggestedPostRefunded added in v0.14.7

type SuggestedPostRefunded struct {
	StarCount int `json:"star_count"`
}

SuggestedPostRefunded represents a service message about a payment refund for a suggested post. https://core.telegram.org/bots/api#suggestedpostrefunded

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.

	// Optional. True, if the command sends an ephemeral message, which can be seen only by the sender
	// of the message and the bot. Bot API 10.2+
	// https://core.telegram.org/bots/api#botcommand
	IsEphemeral bool `json:"is_ephemeral,omitempty"`
}

func (TelegramBotCommand) Validate added in v0.12.0

func (v TelegramBotCommand) Validate() error

type TextQuote added in v0.14.7

type TextQuote struct {
	Text     string          `json:"text"`
	Entities []MessageEntity `json:"entities,omitempty"`
	Position int             `json:"position"`
	IsManual bool            `json:"is_manual,omitempty"`
}

TextQuote contains information about the quoted part of a message that is replied to. https://core.telegram.org/bots/api#textquote

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"`

	// Optional. New incoming message of any kind - text, photo, sticker, etc.
	Message *Message `json:"message,omitempty"`

	// Optional. New version of a message that is known to the bot and was edited
	EditedMessage *Message `json:"edited_message,omitempty"`

	// Optional. New incoming channel post of any kind
	ChannelPost *Message `json:"channel_post,omitempty"`

	// Optional. New version of a channel post that is known to the bot and was edited
	EditedChannelPost *Message `json:"edited_channel_post,omitempty"`

	// Optional. The bot was connected to or disconnected from a business account
	BusinessConnection *BusinessConnection `json:"business_connection,omitempty"`

	// Optional. New message from a connected business account
	BusinessMessage *Message `json:"business_message,omitempty"`

	// Optional. New version of a message from a connected business account
	EditedBusinessMessage *Message `json:"edited_business_message,omitempty"`

	// Optional. Messages were deleted from a connected business account
	DeletedBusinessMessages *BusinessMessagesDeleted `json:"deleted_business_messages,omitempty"`

	// Optional. A reaction to a message was changed by a user
	MessageReaction *MessageReactionUpdated `json:"message_reaction,omitempty"`

	// Optional. Reactions to a message with anonymous reactions were changed
	MessageReactionCount *MessageReactionCountUpdated `json:"message_reaction_count,omitempty"`

	// Optional. New incoming inline query
	InlineQuery *InlineQuery `json:"inline_query,omitempty"`

	// Optional. The result of an inline query that was chosen by a user
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`

	// Optional. New incoming callback query
	CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`

	// Optional. New incoming shipping query. Only for invoices with flexible price
	ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`

	// Optional. New incoming pre-checkout query
	PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`

	// Optional. A user purchased paid media with a non-empty payload
	PurchasedPaidMedia *PaidMediaPurchased `json:"purchased_paid_media,omitempty"`

	// Optional. New poll state
	Poll *Poll `json:"poll,omitempty"`

	// Optional. A user changed their answer in a non-anonymous poll
	PollAnswer *PollAnswer `json:"poll_answer,omitempty"`

	// Optional. The bot's chat member status was updated in a chat
	MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`

	// Optional. A chat member's status was updated in a chat
	ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`

	// Optional. A request to join the chat has been sent
	ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`

	// Optional. A chat boost was added or changed
	ChatBoost *ChatBoostUpdated `json:"chat_boost,omitempty"`

	// Optional. A boost was removed from a chat
	RemovedChatBoost *ChatBoostRemoved `json:"removed_chat_boost,omitempty"`

	// Optional. A managed bot was created or its token was changed. Bot API 9.6+
	ManagedBot *ManagedBotUpdated `json:"managed_bot,omitempty"`

	// Optional. New incoming message received via Guest Mode, in a chat the bot is not a member of. Bot API 10.0+
	GuestMessage *Message `json:"guest_message,omitempty"`

	// Optional. User payment subscription has changed. Bot API 10.2+
	Subscription *BotSubscriptionUpdated `json:"subscription,omitempty"`
}

Update is an update response, from GetUpdates. https://core.telegram.org/bots/api#update

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 {
	// Unique identifier for this user or bot.
	// It has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe.
	ID int64 `json:"id"`

	// True, if this user is a bot
	IsBot bool `json:"is_bot,omitempty"`

	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

	// Optional. True, if this user is a Telegram Premium user
	IsPremium bool `json:"is_premium,omitempty"`

	// Optional. True, if this user added the bot to the attachment menu
	AddedToAttachmentMenu bool `json:"added_to_attachment_menu,omitempty"`

	// Optional. True, if the bot can be invited to groups. Returned only in getMe.
	CanJoinGroups bool `json:"can_join_groups,omitempty"`

	// Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
	CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`

	// Optional. True, if the bot supports inline queries. Returned only in getMe.
	SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`

	// Optional. True, if the bot can be connected to a Telegram Business account. Returned only in getMe.
	CanConnectToBusiness bool `json:"can_connect_to_business,omitempty"`

	// Optional. True, if the bot has a main Web App. Returned only in getMe.
	HasMainWebApp bool `json:"has_main_web_app,omitempty"`

	// Optional. True, if the bot has forum topic mode enabled in private chats. Returned only in getMe.
	HasTopicsEnabled bool `json:"has_topics_enabled,omitempty"`

	// Optional. True, if the bot allows users to create and delete topics in private chats. Returned only in getMe.
	AllowsUsersToCreateTopics bool `json:"allows_users_to_create_topics,omitempty"`

	// Optional. True, if other bots can be created under this bot's control. Returned only in getMe.
	CanManageBots bool `json:"can_manage_bots,omitempty"`

	// Optional. True, if the bot supports guest queries, allowing it to receive certain messages
	// and issue replies within chats it is not a member of. Returned only in getMe. Bot API 10.0+
	SupportsGuestQueries bool `json:"supports_guest_queries,omitempty"`

	// Optional. True, if the bot supports join request queries, allowing it to be asked to process
	// chat join requests. Returned only in getMe. Bot API 10.1+
	// https://core.telegram.org/bots/api#user
	SupportsJoinRequestQueries bool `json:"supports_join_request_queries,omitempty"`
}

User is a user on Telegram. https://core.telegram.org/bots/api#user

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) GetIDInt64 added in v0.14.7

func (u User) GetIDInt64() int64

GetIDInt64 returns Telegram user ID as int64

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 UserRating added in v0.14.7

type UserRating struct {
	Rating int `json:"rating"`
}

UserRating contains information about a user's rating. https://core.telegram.org/bots/api#userrating

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"`
	FoursquareType  string   `json:"foursquare_type,omitempty"`
	GooglePlaceID   string   `json:"google_place_id,omitempty"`
	GooglePlaceType string   `json:"google_place_type,omitempty"`
}

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"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	Width        int        `json:"width"`
	Height       int        `json:"height"`
	Duration     int        `json:"duration"`
	Thumbnail    *PhotoSize `json:"thumbnail,omitempty"` // optional
	MimeType     string     `json:"mime_type,omitempty"` // optional
	FileSize     int        `json:"file_size,omitempty"` // optional
}

Video contains information about a video. https://core.telegram.org/bots/api#video

type VideoChatEnded added in v0.14.7

type VideoChatEnded struct {
	Duration int `json:"duration"`
}

VideoChatEnded represents a service message about a video chat ended in the chat. https://core.telegram.org/bots/api#videochatended

type VideoChatParticipantsInvited added in v0.14.7

type VideoChatParticipantsInvited struct {
	Users []User `json:"users"`
}

VideoChatParticipantsInvited represents a service message about new members invited to a video chat. https://core.telegram.org/bots/api#videochatparticipantsinvited

type VideoChatScheduled added in v0.14.7

type VideoChatScheduled struct {
	StartDate int `json:"start_date"`
}

VideoChatScheduled represents a service message about a video chat scheduled in the chat. https://core.telegram.org/bots/api#videochatscheduled

type VideoChatStarted added in v0.14.7

type VideoChatStarted struct{}

VideoChatStarted represents a service message about a video chat started in the chat. https://core.telegram.org/bots/api#videochatstarted

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 VideoNote added in v0.14.7

type VideoNote struct {
	FileID       string     `json:"file_id"`
	FileUniqueID string     `json:"file_unique_id,omitempty"`
	Length       int        `json:"length"`
	Duration     int        `json:"duration"`
	Thumbnail    *PhotoSize `json:"thumbnail,omitempty"`
	FileSize     int        `json:"file_size,omitempty"`
}

VideoNote represents a video message (available in Telegram apps as of v.4.0). https://core.telegram.org/bots/api#videonote

type VideoQuality added in v0.14.7

type VideoQuality struct {
	Type     string `json:"type"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	FileSize int    `json:"file_size,omitempty"`
}

VideoQuality represents the quality of a video. https://core.telegram.org/bots/api#videoquality

type Voice

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

Voice contains information about a voice. https://core.telegram.org/bots/api#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 WebAppData added in v0.14.7

type WebAppData struct {
	Data       string `json:"data"`
	ButtonText string `json:"button_text"`
}

WebAppData contains data sent from a Web App to the bot. https://core.telegram.org/bots/api#webappdata

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