bot

package module
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 25 Imported by: 350 modules, 384 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Golang Telegram Bot

Go Report Card codecov

✅ Present in the list of libraries https://core.telegram.org/bots/samples#go

Telegram Group

Supports Bot API version: 10.5 from November 22, 2026

It's a Go zero-dependencies telegram bot framework

A simple example echo-bot:

package main

import (
	"context"
	"os"
	"os/signal"

	"github.com/go-telegram/bot"
	"github.com/go-telegram/bot/models"
)

// Send any text message to the bot after the bot has been started

func main() {
	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
	defer cancel()

	opts := []bot.Option{
		bot.WithDefaultHandler(handler),
	}

	b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER", opts...)
	if err != nil {
		panic(err)
	}

	b.Start(ctx)
}

func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
	b.SendMessage(ctx, &bot.SendMessageParams{
		ChatID: update.Message.Chat.ID,
		Text:   update.Message.Text,
	})
}

You can find more examples in the examples folder.

To run the examples, set the EXAMPLE_TELEGRAM_BOT_TOKEN environment variable to your bot token.

Getting started

Go version: 1.18

Install the dependencies:

go get -u github.com/go-telegram/bot

Initialize and run the bot:

b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER")

b.Start(context.TODO())

On create bot will call the getMe method (with 5 sec timeout). And returns error on fail. If you want to change this timeout, use option bot.WithCheckInitTimeout

You can define a default handler for the bot:

b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER", bot.WithDefaultHandler(handler))

func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
	// this handler will be called for all updates
}

Webhooks

If you want to use webhooks, instead of using bot.Start, you should use the bot.StartWebhook method to start the bot. Also, you should use bot.WebhookHandler() method as HTTP handler for your server.

For a valid update, WebhookHandler returns HTTP 200 once a worker takes the update, and the worker then runs its matchers, middlewares and handler. With bot.WithNotAsyncHandlers, a request therefore waits for a free worker. If StartWebhook is not running, or the run stops or the request is canceled before a worker takes the update, it returns HTTP 503 so Telegram can retry, and the update is not handled. An unreadable request body gets HTTP 400 for the same reason.

Cancel the context passed to StartWebhook to shut down. Handlers receive a context derived from it that is canceled when the run stops. StartWebhook waits for running handlers to return. Cancel it before shutting down the HTTP server, so that requests still waiting for a worker get 503 right away.

func main() {
	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
	defer cancel()

	opts := []bot.Option{
		bot.WithDefaultHandler(handler),
		bot.WithWebhookSecretToken(os.Getenv("EXAMPLE_TELEGRAM_WEBHOOK_SECRET_TOKEN")),
	}

	b, err := bot.New(os.Getenv("EXAMPLE_TELEGRAM_BOT_TOKEN"), opts...)
	if err != nil {
		panic(err)
	}

	// call methods.SetWebhook if needed

	go func() {
		if err := http.ListenAndServe(":2000", b.WebhookHandler()); err != nil {
			log.Printf("webhook server: %v", err)
			cancel()
		}
	}()

	b.StartWebhook(ctx)

	// call methods.DeleteWebhook if needed
}

func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
	b.SendMessage(ctx, &bot.SendMessageParams{
		ChatID: update.Message.Chat.ID,
		Text:   update.Message.Text,
	})
}

Demo in examples

Webhook replies

A handler can also answer an update in the response to the webhook request that delivered it. However, Telegram does not report whether the call succeeded. See Making requests when getting updates.

Use bot.WebhookReplyHandler() as the HTTP handler instead of bot.WebhookHandler(). It runs the handler for each update in the goroutine serving the request and responds once the handler returns, so bot.StartWebhook is not needed. In the handler, call bot.WebhookReply with the method name and its parameters:

func main() {
	b, _ := bot.New(os.Getenv("EXAMPLE_TELEGRAM_BOT_TOKEN"), bot.WithDefaultHandler(handler))

	http.ListenAndServe(":2000", b.WebhookReplyHandler())
}

func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
	b.WebhookReply(ctx, "sendMessage", &bot.SendMessageParams{
		ChatID: update.Message.Chat.ID,
		Text:   update.Message.Text,
	})
}

A handler can reply only once per update, and only before it returns. Otherwise, bot.WebhookReply returns an error wrapping bot.ErrorWebhookReplyUnavailable.

Demo in examples

Also, you can manually process updates with bot.ProcessUpdate method.

update := models.Update{}

json.NewDecoder(req.Body).Decode(&update)

b.ProcessUpdate(ctx, &update)

Middlewares

You can use middlewares with WithMiddlewares(middlewares ...Middleware) option.

See an example in examples

Available methods

All available methods are listed in the Telegram Bot API documentation

You can use all these methods as bot funcs. All methods have name like in official documentation, but with capital first letter.

bot.SendMessage, bot.GetMe, bot.SendPhoto, etc

Most methods take a context and a pointer to a parameters struct and return a response and an error. GetMe, GetMeLegacy, Close, and Logout take only a context.

<PARAMS> is a struct with fields that corresponds to Telegram Bot API parameters. All Params structs have name like for corresponded methods, but with Params suffix.

SendMessageParams for SendMessage method etc.

You should pass params by pointer

bot.SendMessage(ctx, &bot.SendMessageParams{...})
Migrating to Bot API 10.5

b.GetMe(ctx) now returns *models.BotFullInfo. Code that only reads me.ID or me.Username from an inferred result needs no changes. If you used me.SupportInlineQueries, use me.SupportsInlineQueries (with an s after Support). If a caller still needs *models.User, switch that call to b.GetMeLegacy(ctx) while migrating. The legacy method is deprecated.

Expandable quotations in rich messages now contain blocks. Read Blocks on models.RichBlockExpandableBlockQuotation; the library no longer populates Text. To send a text quotation, put the rich text in a paragraph block:

quote := models.InputRichBlockExpandableBlockQuotation{
	Blocks: []models.InputRichBlock{{
		Type: models.RichBlockTypeParagraph,
		InputRichBlockParagraph: &models.InputRichBlockParagraph{
			Text: models.RichText{PlainText: "Quoted text"},
		},
	}},
}

Sending a nonzero Text with no blocks returns Text is deprecated; use Blocks before the request is sent. If both are set, only Blocks is used. Ordinary message text (SendMessageParams.Text and models.Message.Text) is unchanged.

Options

You can use options to customize the bot.

b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER", opts...)
Options list (see options.go for more details)
  • WithCheckInitTimeout(timeout time.Duration) - timeout for check init bot
  • WithMiddlewares(middlewares ...Middleware) - add middlewares
  • WithMessageTextHandler(pattern string, matchType MatchType, handler HandlerFunc) - add handler for Message.Text field
  • WithCallbackQueryDataHandler(pattern string, matchType MatchType, handler HandlerFunc) - add handler for CallbackQuery.Data field
  • WithPhotoCaptionHandler - add handler for Message.Caption field
  • WithDefaultHandler(handler HandlerFunc) - add default handler
  • WithDebug() - enable debug mode
  • WithErrorsHandler(handler ErrorsHandler) - add errors handler
  • WithDebugHandler(handler DebugHandler) - add debug handler
  • WithHTTPClient(pollTimeout time.Duration, client HttpClient) - set custom http client
  • WithServerURL(serverURL string) - set server url
  • WithSkipGetMe() - skip GetMe during initialization. Command handlers still match /start; to also match /start@username for the bot's primary or active usernames, call GetMe successfully first.
  • WithAllowedUpdates(params AllowedUpdates) - set allowed_updates for getUpdates method
  • WithUpdatesChannelCap(cap int) - set updates channel capacity, by default 1024
  • WithWebhookSecretToken(webhookSecretToken string) - set X-Telegram-Bot-Api-Secret-Token header sent from telegram servers to confirm validity of update
  • WithWorkers - set the number of workers that are processing the Updates channel, by default 1
  • UseTestEnvironment() - use test environment
  • WithNotAsyncHandlers() - allows to run handlers in the main goroutine
  • WithInitialOffset(offset int64) - allows to set initial offset for getUpdates method

Message.Text and CallbackQuery.Data handlers

For your convenience, you can match message text, photo captions, callback data, inline query text and widget query data.

An example:

b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER")

b.RegisterHandler(bot.HandlerTypeMessageText, "/start", bot.MatchTypeExact, myStartHandler)

b.Start(context.TODO())

also you can use bot init options WithMessageTextHandler and WithCallbackQueryDataHandler

In this example, the handler will be called when the user sends /start message. All other messages will be handled by the default handler.

Handler Types:

  • HandlerTypeMessageText - for Update.Message.Text field
  • HandlerTypeCallbackQueryData - for Update.CallbackQuery.Data field
  • HandlerTypeCallbackQueryGameShortName - for Update.CallbackQuery.GameShortName field
  • HandlerTypePhotoCaption - for Update.Message.Caption field
  • HandlerTypeInlineQuery - for Update.InlineQuery.Query field
  • HandlerTypeWidgetQueryData - for Update.WidgetQuery.Data field
  • HandlerTypeSharedWidgetQueryData - for Update.SharedWidgetQuery.Data field

Use RegisterHandlerInlineQuery(handler) to handle all inline queries, including empty queries. It returns a handler ID and accepts optional middlewares, like RegisterHandler. To filter inline query text, use RegisterHandler with HandlerTypeInlineQuery and MatchTypeExact, MatchTypePrefix, or MatchTypeContains, or use RegisterHandlerRegexp. Inline queries have no message entities, so command match types do not match them.

Widget query data supports exact, prefix, substring and regular-expression matching, for example:

b.RegisterHandler(bot.HandlerTypeWidgetQueryData, "buy:", bot.MatchTypePrefix, widgetHandler)
b.RegisterHandler(bot.HandlerTypeSharedWidgetQueryData, "buy:", bot.MatchTypePrefix, sharedWidgetHandler)

Read the query ID from update.WidgetQuery.ID or update.SharedWidgetQuery.ID and answer it with b.AnswerWidgetQuery. Widget queries have no message entities, so command match types do not match them.

RegisterHandler returns a handler ID string. You can use it to remove the handler later.

b.UnregisterHandler(handlerID)

Match Types:

  • MatchTypeExact
  • MatchTypePrefix
  • MatchTypeContains
  • MatchTypeCommand
  • MatchTypeCommandStartOnly

For MatchTypeCommand and MatchTypeCommandStartOnly usage see an example

You can use RegisterHandlerRegexp to match by regular expression.

re := regexp.MustCompile(`^/start`)

b.RegisterHandlerRegexp(bot.HandlerTypeMessageText, re, myStartHandler)

If you want to use custom handler, use RegisterHandlerMatchFunc

matchFunc := func(update *models.Update) bool {
	// your checks
	return true
}

b.RegisterHandlerMatchFunc(matchFunc, myHandler)

Update user and chat

Use update.EffectiveUser() and update.EffectiveChat() when a handler or middleware works with multiple update types:

if user := update.EffectiveUser(); user != nil {
    log.Printf("user ID: %d", user.ID)
}
if chat := update.EffectiveChat(); chat != nil {
    log.Printf("chat ID: %d", chat.ID)
}

Both helpers return pointers into the original update and are safe to call on a nil update. A user or chat may be unavailable, so check each result for nil. For widget queries, EffectiveUser returns the sender; EffectiveChat returns the widget's chat when present. Inline widget queries and shared widget queries have no chat.

InputFile

For some methods, like SendPhoto, SendAudio etc, you can send file by file path or file contents.

To send a file by URL or FileID, you can use &models.InputFileString{Data: string}:

// file id of uploaded image
inputFileData := "AgACAgIAAxkDAAIBOWJimnCJHQJiJ4P3aasQCPNyo6mlAALDuzEbcD0YSxzjB-vmkZ6BAQADAgADbQADJAQ"
// or URL image path
// inputFileData := "https://example.com/image.png"

params := &bot.SendPhotoParams{
    ChatID:  chatID,
    Photo:   &models.InputFileString{Data: inputFileData},
}

bot.SendPhoto(ctx, params)

Demo in examples

To send an image file by its contents, you can use &models.InputFileUpload{Filename: string, Data: io.Reader}:

fileContent, _ := os.ReadFile("/path/to/image.png")

params := &bot.SendPhotoParams{
    ChatID:  chatID,
    Photo:   &models.InputFileUpload{Filename: "image.png", Data: bytes.NewReader(fileContent)},
}

bot.SendPhoto(ctx, params)

Demo in examples

InputMedia

For methods like SendMediaGroup or EditMessageMedia you can send media by file path or file contents.

Official documentation InputMedia

field media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.

If you want to use attach:// format, you should to define MediaAttachment field with file content reader.

fileContent, _ := os.ReadFile("/path/to/image.png")

media1 := &models.InputMediaPhoto{
	Media: "https://telegram.org/img/t_logo.png",
}

media2 := &models.InputMediaPhoto{
	Media: "attach://image.png",
	Caption: "2",
	MediaAttachment: bytes.NewReader(fileContent),
}

params := &bot.SendMediaGroupParams{
    ChatID: update.Message.Chat.ID,
    Media: []models.InputMedia{
        media1,
        media2,
    },
}

bot.SendMediaGroup(ctx, params)

Demo in examples

Telegram does not accept a reused file as a thumbnail, so a thumbnail is normally an InputFileUpload: it is sent as a separate part and referenced by attach://, with Filename as the part name. An InputFileString is passed through unchanged, so a file_id or an URL reaches the API as written.

A part name identifies one file within a request. Referencing the same file from several entries under one name is fine — the part is written once and every reference resolves to it — but two different files sharing a name are rejected with an error, since Telegram would resolve both references to the first of them. A file part and a form field cannot share a name either.

thumbContent, _ := os.ReadFile("/path/to/thumb.jpg")

media := &models.InputMediaVideo{
	Media:           "attach://video.mp4",
	MediaAttachment: bytes.NewReader(videoContent),
	Thumbnail:       &models.InputFileUpload{Filename: "thumb.jpg", Data: bytes.NewReader(thumbContent)},
}

InputSticker

For CreateNewStickerSet method you can send sticker by file path or file contents.

[Official documentation InputSticker]((https://core.telegram.org/bots/api#inputsticker)

field sticker: The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new file using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL.

If you want to use attach:// format, you should to define StickerAttachment field with file content reader.

fileContent, _ := os.ReadFile("/path/to/telegram.png")

inputSticker1 := models.InputSticker{
	Sticker:   "https://github.com/go-telegram/bot/blob/main/examples/create_new_sticker_set/images/telegram.png?raw=true",
	Format:    "static",
	EmojiList: []string{"1️⃣"},
}

inputSticker2 := models.InputSticker{
	Sticker:           "attach://telegram.png",
	Format:            "static",
	EmojiList:         []string{"2️⃣"},
	StickerAttachment: bytes.NewReader(fileContent),
}

params := &bot.CreateNewStickerSetParams{
	UserID: update.Message.Chat.ID,
	Name:   fmt.Sprintf("Example%d_by_%s", time.Now().Unix(), botUsername),
	Title:  "Example sticker set",
	Stickers: []models.InputSticker{
		inputSticker1,
		inputSticker2,
	},
}

b.CreateNewStickerSet(ctx, params)

Demo in examples

Helpers

EscapeMarkdown(s string) string

Escape special symbols for Telegram MarkdownV2 syntax

EscapeMarkdownUnescaped(s string) string

Escape only unescaped special symbols for Telegram MarkdownV2 syntax

RandomString(n int) string

Returns fast random a-zA-Z string with n length

True() bool, False() bool

Allows you to define *bool values for params, which require *bool, like SendPollParams

p := &bot.SendPollParams{
    ChatID: chatID,
    Question: "Question",
    Options: []string{"Option 1", "Option 2"},
    IsAnonymous: bot.False(),
}

b.SendPoll(ctx, p)
ValidateWebappRequest(values url.Values, token string) (user *WebAppUser, ok bool)

Validate request from Telegram Webapp

https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app

Load the bot token at startup.

token := os.Getenv("TELEGRAM_BOT_TOKEN")
if token == "" {
    log.Fatal("TELEGRAM_BOT_TOKEN is not set or empty")
}

In the request handler, pass the decoded query values.

user, ok := bot.ValidateWebappRequest(req.URL.Query(), token)
if !ok {
    http.Error(w, "Unauthorized", http.StatusUnauthorized)
    return
}
log.Println(user.ID)

It returns only the user. Use ValidateWebAppInitData when the full init data is needed.

ValidateWebAppInitData(initData, token string) (*WebAppInitData, error)

Parse the raw Telegram.WebApp.initData string and validate its hash with the bot token

https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app

data, err := bot.ValidateWebAppInitData(initData, token)
if err == nil {
    err = data.CheckAuthDate(time.Hour)
}
if errors.Is(err, bot.ErrorWebAppInitDataExpired) {
    http.Error(w, "Expired", http.StatusUnauthorized)
    return
}
if err != nil {
    http.Error(w, "Unauthorized", http.StatusUnauthorized)
    return
}
if data.User != nil {
    log.Println(data.User.ID)
}
ValidateWebAppInitDataSignature(initData string, botID int64, publicKey ed25519.PublicKey) (*WebAppInitData, error)

Parse the raw Telegram.WebApp.initData string and validate its Ed25519 signature, for a third party that has the bot ID but not the token

The returned Hash is passed through without verification.

https://core.telegram.org/bots/webapps#validating-data-for-third-party-use

Decode the public key at startup.

publicKey, err := hex.DecodeString(bot.WebAppPublicKeyHex)
if err != nil {
    panic(err)
}

In the request handler, pass the raw init data and the decoded key.

data, err := bot.ValidateWebAppInitDataSignature(initData, botID, publicKey)
if err == nil {
    err = data.CheckAuthDate(time.Hour)
}
if err != nil {
    http.Error(w, "Unauthorized", http.StatusUnauthorized)
    return
}

Return file download link after call method GetFile

See documentation

Errors

This library includes error handling. It provides the following error types:

  • ErrorForbidden (403): This error occurs when the bot has no access to the action, such as when the user has blocked the bot.
  • ErrorBadRequest (400): This error indicates a bad request made to the bot's API.
  • ErrorUnauthorized (401): This error occurs when the bot's access is unauthorized for the requested action.
  • TooManyRequestsError: (429) This error indicates that the bot has received too many requests within a short period. It includes a RetryAfter value indicating when to retry the request.
  • ErrorNotFound (404): This error indicates that the requested resource was not found.
  • ErrorConflict (409): This error indicates a conflict occurred during the request.

Usage:

_, err := b.SendMessage(...)

if errors.Is(err, mybot.ErrorForbidden) {
    // Handle the ErrorForbidden (403) case here
}

if errors.Is(err, mybot.ErrorBadRequest) {
    // Handle the ErrorBadRequest (400) case here
}

if errors.Is(err, mybot.ErrorUnauthorized) {
    // Handle the ErrorUnauthorized (401) case here
}

if mybot.IsTooManyRequestsError(err) {
    // Handle the TooManyRequestsError (429) case here
    fmt.Println("Received TooManyRequestsError with retry_after:", err.(*mybot.TooManyRequestsError).RetryAfter)
}

if errors.Is(err, mybot.ErrorNotFound) {
    // Handle the ErrorNotFound (404) case here
}

if errors.Is(err, mybot.ErrorConflict) {
    // Handle the ErrorConflict (409) case here
}

Other

  • bot.ID() int64 - returns bot ID. Bot ID is a unique identifier for the bot, obtained from the token as first part before :. Example: 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw - bot ID is 110201543. Returns 0 if the prefix cannot be parsed as an int64, including overflow. This method does not validate or authenticate the token.
  • bot.Token() string - returns bot token
  • bot.SetToken() - set new bot token

MiniApp misc

Check the repo go-telegram/miniapp for Telegram MiniApp example.

Repo go-telegram/miniapp-types contains TypeScript types definitions for Telegram MiniApp object.

UI Components

In the repo https://github.com/go-telegram/ui you can find a some UI elements for your bot.

  • datepicker
  • inline_keyboard
  • slider
  • paginator

and more...

Please, check the repo for more information and live demo.

Documentation

Index

Constants

View Source
const (
	WebAppPublicKeyHex     = "e7bf03a2fa4602af4580703d88dda5bb59f32ed8b02a56c187fe7d34caed242d"
	WebAppTestPublicKeyHex = "40055058a4ee38156a06562e52eece92a771bcd8346a8c4615cb7376eddf72ec"
)

Variables

View Source
var (
	ErrorForbidden               = errors.New("forbidden")
	ErrorBadRequest              = errors.New("bad request")
	ErrorUnauthorized            = errors.New("unauthorized")
	ErrorTooManyRequests         = errors.New("too many requests")
	ErrorNotFound                = errors.New("not found")
	ErrorConflict                = errors.New("conflict")
	ErrorWebhookReplyUnavailable = errors.New("webhook reply unavailable")
	ErrorWebAppInitDataMalformed = errors.New("malformed web app data")
	ErrorWebAppInitDataUnsigned  = errors.New("web app data has no hash or signature")
	ErrorWebAppInitDataInvalid   = errors.New("invalid web app data hash or signature")
	ErrorWebAppInitDataExpired   = errors.New("web app data expired")
)

Functions

func EscapeMarkdown

func EscapeMarkdown(s string) string

EscapeMarkdown escapes plain text for Telegram MarkdownV2 syntax. Use it for user input and other dynamic text. For example, EscapeMarkdown("Hello_world") returns "Hello\_world".

func EscapeMarkdownUnescaped added in v0.4.1

func EscapeMarkdownUnescaped(s string) string

EscapeMarkdownUnescaped escapes special symbols that are not already escaped for Telegram MarkdownV2 syntax. Use it for text that may already contain MarkdownV2 escapes.

func False added in v0.7.4

func False() *bool

False and True returns the pointer to bool

func IsMigrateError added in v1.2.1

func IsMigrateError(err error) bool

func IsTooManyRequestsError added in v1.2.1

func IsTooManyRequestsError(err error) bool

func RandomString

func RandomString(n int) string

RandomString returns random a-zA-Z string with n length

func True added in v0.7.4

func True() *bool

True and False returns the pointer to bool

Types

type AddStickerToSetParams

type AddStickerToSetParams struct {
	UserID  int64               `json:"user_id"`
	Name    string              `json:"name"`
	Sticker models.InputSticker `json:"sticker"`
}

type AllowedUpdates added in v1.1.5

type AllowedUpdates []string

type AnswerCallbackQueryParams

type AnswerCallbackQueryParams 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"`
}

type AnswerChatJoinRequestQueryParams added in v1.31.0

type AnswerChatJoinRequestQueryParams struct {
	ChatJoinRequestQueryID string                            `json:"chat_join_request_query_id"`
	Result                 models.ChatJoinRequestQueryResult `json:"result"`
}

type AnswerGuestQueryParams added in v1.21.0

type AnswerGuestQueryParams struct {
	GuestQueryID string                   `json:"guest_query_id"`
	Result       models.InlineQueryResult `json:"result"`
}

type AnswerInlineQueryParams

type AnswerInlineQueryParams struct {
	InlineQueryID string                           `json:"inline_query_id"`
	Results       []models.InlineQueryResult       `json:"results"`
	CacheTime     int                              `json:"cache_time,omitempty"`
	IsPersonal    bool                             `json:"is_personal,omitempty"`
	NextOffset    string                           `json:"next_offset,omitempty"`
	Button        *models.InlineQueryResultsButton `json:"button,omitempty"`
	// DisableCache sends cache_time 0. A zero CacheTime is omitted, and Telegram
	// then caches results for 300 seconds. When set, the flag overrides CacheTime.
	DisableCache bool `json:"-"`
}

func (AnswerInlineQueryParams) MarshalJSON added in v1.30.0

func (p AnswerInlineQueryParams) MarshalJSON() ([]byte, error)

MarshalJSON encodes the params as the struct does. DisableCache forces cache_time to 0, including when CacheTime is non-zero. The alias keeps this method from calling itself.

type AnswerPreCheckoutQueryParams

type AnswerPreCheckoutQueryParams struct {
	PreCheckoutQueryID string `json:"pre_checkout_query_id"`
	OK                 bool   `json:"ok"`
	ErrorMessage       string `json:"error_message,omitempty"`
}

type AnswerShippingQueryParams

type AnswerShippingQueryParams struct {
	ShippingQueryID string                  `json:"shipping_query_id"`
	OK              bool                    `json:"ok"`
	ShippingOptions []models.ShippingOption `json:"shipping_options,omitempty"`
	ErrorMessage    string                  `json:"error_message,omitempty"`
}

type AnswerWebAppQueryParams

type AnswerWebAppQueryParams struct {
	WebAppQueryID string                   `json:"web_app_query_id"`
	Result        models.InlineQueryResult `json:"result"`
}

type AnswerWidgetQueryParams added in v1.28.0

type AnswerWidgetQueryParams struct {
	WidgetQueryID string `json:"widget_query_id"`
	Data          string `json:"data,omitempty"`
}

AnswerWidgetQueryParams https://core.telegram.org/bots/api#answerwidgetquery

type ApproveChatJoinRequestParams

type ApproveChatJoinRequestParams struct {
	ChatID any   `json:"chat_id"`
	UserID int64 `json:"user_id"`
}

type ApproveSuggestedPostParams added in v1.17.0

type ApproveSuggestedPostParams struct {
	ChatID    int64 `json:"chat_id"`
	MessageID int   `json:"message_id"`
	SendDate  int   `json:"send_date,omitempty"`
}

ApproveSuggestedPostParams https://core.telegram.org/bots/api#approvesuggestedpost

type BanChatMemberParams

type BanChatMemberParams struct {
	ChatID         any   `json:"chat_id"`
	UserID         int64 `json:"user_id"`
	UntilDate      int   `json:"until_date,omitempty"`
	RevokeMessages bool  `json:"revoke_messages,omitempty"`
}

type BanChatSenderChatParams

type BanChatSenderChatParams struct {
	ChatID       any   `json:"chat_id"`
	SenderChatID int64 `json:"sender_chat_id"`
}

type Bot

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

Bot is a Telegram bot client. It receives updates by polling or through a webhook, runs middlewares and handlers for them, and provides methods for Telegram API calls.

func New

func New(token string, options ...Option) (*Bot, error)

New creates new Bot instance

func (*Bot) AnswerGuestQuery added in v1.21.0

func (b *Bot) AnswerGuestQuery(ctx context.Context, params *AnswerGuestQueryParams) (*models.SentGuestMessage, error)

func (*Bot) DeleteAllMessageReactions added in v1.21.0

func (b *Bot) DeleteAllMessageReactions(ctx context.Context, params *DeleteAllMessageReactionsParams) (bool, error)

func (*Bot) DeleteMessageReaction added in v1.21.0

func (b *Bot) DeleteMessageReaction(ctx context.Context, params *DeleteMessageReactionParams) (bool, error)
func (b *Bot) FileDownloadLink(f *models.File) string

FileDownloadLink returns the file download link

func (*Bot) GetManagedBotAccessSettings added in v1.21.0

func (b *Bot) GetManagedBotAccessSettings(ctx context.Context, params *GetManagedBotAccessSettingsParams) (*models.BotAccessSettings, error)

func (*Bot) GetManagedBotToken added in v1.21.0

func (b *Bot) GetManagedBotToken(ctx context.Context, params *GetManagedBotTokenParams) (string, error)

func (*Bot) GetMe

func (b *Bot) GetMe(ctx context.Context) (*models.BotFullInfo, error)

GetMe https://core.telegram.org/bots/api#getme GetMe also records the bot's usernames when the returned bot is the one the token belongs to, so a MatchTypeCommand or MatchTypeCommandStartOnly handler for start also matches /start@bot_username.

func (*Bot) GetMeLegacy deprecated added in v1.31.0

func (b *Bot) GetMeLegacy(ctx context.Context) (*models.User, error)

GetMeLegacy returns the result of GetMe in the previous User format.

Deprecated: Use GetMe.

func (*Bot) GetUserPersonalChatMessages added in v1.21.0

func (b *Bot) GetUserPersonalChatMessages(ctx context.Context, params *GetUserPersonalChatMessagesParams) ([]models.Message, error)

func (*Bot) ID added in v1.13.1

func (b *Bot) ID() int64

ID returns the bot user id from the token prefix ("<id>:<secret>"). It returns 0 if the prefix cannot be parsed as an int64. ID does not validate or authenticate the token.

func (*Bot) ProcessUpdate added in v0.7.3

func (b *Bot) ProcessUpdate(ctx context.Context, upd *models.Update)

ProcessUpdate finds the handler for upd, applies the bot middlewares and runs it. The handler runs in a new goroutine, or in the calling goroutine with WithNotAsyncHandlers.

func (*Bot) RegisterHandler

func (b *Bot) RegisterHandler(handlerType HandlerType, pattern string, matchType MatchType, f HandlerFunc, m ...Middleware) string

RegisterHandler registers f for updates whose data, selected by handlerType, matches pattern according to matchType. Handlers are checked in registration order, and only the first match runs. Middlewares in m wrap f. Returns an ID that can be passed to UnregisterHandler.

func (*Bot) RegisterHandlerInlineQuery added in v1.28.0

func (b *Bot) RegisterHandlerInlineQuery(f HandlerFunc, m ...Middleware) string

RegisterHandlerInlineQuery registers a handler for all inline queries, including empty queries. For matching query text, use RegisterHandler or RegisterHandlerRegexp with HandlerTypeInlineQuery. Returns an ID that can be passed to UnregisterHandler.

func (*Bot) RegisterHandlerMatchFunc added in v0.3.3

func (b *Bot) RegisterHandlerMatchFunc(matchFunc MatchFunc, f HandlerFunc, m ...Middleware) string

RegisterHandlerMatchFunc registers f for updates accepted by matchFunc. Handlers are checked in registration order, and only the first match runs. Middlewares in m wrap f. Returns an ID that can be passed to UnregisterHandler.

func (*Bot) RegisterHandlerRegexp

func (b *Bot) RegisterHandlerRegexp(handlerType HandlerType, re *regexp.Regexp, f HandlerFunc, m ...Middleware) string

RegisterHandlerRegexp registers f for updates whose data, selected by handlerType, matches re. Handlers are checked in registration order, and only the first match runs. Middlewares in m wrap f. Returns an ID that can be passed to UnregisterHandler.

func (*Bot) ReplaceManagedBotToken added in v1.21.0

func (b *Bot) ReplaceManagedBotToken(ctx context.Context, params *ReplaceManagedBotTokenParams) (string, error)

func (*Bot) SavePreparedKeyboardButton added in v1.21.0

func (b *Bot) SavePreparedKeyboardButton(ctx context.Context, params *SavePreparedKeyboardButtonParams) (*models.PreparedKeyboardButton, error)

func (*Bot) SendLivePhoto added in v1.21.0

func (b *Bot) SendLivePhoto(ctx context.Context, params *SendLivePhotoParams) (*models.Message, error)

func (*Bot) SetManagedBotAccessSettings added in v1.21.0

func (b *Bot) SetManagedBotAccessSettings(ctx context.Context, params *SetManagedBotAccessSettingsParams) (bool, error)

func (*Bot) SetToken added in v1.8.3

func (b *Bot) SetToken(token string)

SetToken sets the bot token. If the token belongs to a different bot, by its ID prefix, the usernames recorded by GetMe are cleared until GetMe succeeds again. A new token for the same bot, as after revoking the old one, keeps them.

func (*Bot) Start

func (b *Bot) Start(ctx context.Context)

Start receives and processes updates by polling until ctx is canceled. A batch is confirmed once all its updates have been dispatched to handlers, so polling continues while asynchronous handlers run. With WithNotAsyncHandlers, a batch is dispatched only as fast as its handlers run. On cancellation, Start waits for dispatched handlers before returning. When polling resumes after cancellation, it starts from the first update of the batch that was not dispatched, so updates handled after it may be delivered again. Telegram learns the new offset only from the next poll, so after a process restart it may deliver the last batch again: delivery is at least once. Handlers receive a context derived from ctx and canceled when the run stops. They should return when it is canceled. If every worker exits early, such as through runtime.Goexit in a matcher or in a handler run with WithNotAsyncHandlers, the run stops. If another Start or StartWebhook is running on the same Bot, it waits for that run to end first. Calling it from a handler of the running Bot therefore blocks until the ctx passed to that call is canceled.

func (*Bot) StartWebhook

func (b *Bot) StartWebhook(ctx context.Context)

StartWebhook processes updates from WebhookHandler until ctx is canceled. WebhookHandler answers a valid update with HTTP 200 once a worker takes it, and with 503 if the run stops first. Handlers receive a context derived from ctx and canceled when the run stops. StartWebhook waits for running handlers to return. If every worker exits early, such as through runtime.Goexit in a matcher or in a handler run with WithNotAsyncHandlers, the run stops. If another Start or StartWebhook is running on the same Bot, it waits for that run to end first. Calling it from a handler of the running Bot therefore blocks until the ctx passed to that call is canceled.

func (*Bot) Token added in v1.13.1

func (b *Bot) Token() string

Token returns the bot token

func (*Bot) UnregisterHandler

func (b *Bot) UnregisterHandler(id string)

UnregisterHandler removes the handler with the given ID. An unknown ID is ignored.

func (*Bot) WebhookHandler

func (b *Bot) WebhookHandler() http.HandlerFunc

WebhookHandler returns an HTTP handler for updates processed by StartWebhook. For a valid update, it returns 200 once a worker takes the update, after which the worker runs its matchers, middlewares and handler. It returns 503 if StartWebhook is not running, or if no worker takes the update before the run stops or the request is canceled, and 400 if the request body cannot be read. Such an update is not handled, and Telegram sends it again.

func (*Bot) WebhookReply added in v1.29.0

func (b *Bot) WebhookReply(ctx context.Context, method string, params any) error

WebhookReply answers the update being handled by sending a Bot API method call in the response to the webhook request, Telegram does not report whether the response succeeded.

The method is the Bot API method name, such as "answerInlineQuery", and the params are its parameters, such as *AnswerInlineQueryParams. Supported non-nil params must be pointers to structs, while nil and typed-nil pointers are skipped without emitting fields.

WebhookReply works only in a handler run by WebhookReplyHandler. It must be called before the handler returns. It can only be called once per update. Otherwise, WebhookReply returns an error wrapping ErrorWebhookReplyUnavailable.

See https://core.telegram.org/bots/api#making-requests-when-getting-updates

func (*Bot) WebhookReplyHandler added in v1.29.0

func (b *Bot) WebhookReplyHandler() http.HandlerFunc

WebhookReplyHandler returns an HTTP handler for webhook updates that lets handlers answer an update in the webhook response with WebhookReply.

WebhookReplyHandler runs the handler for each update synchronously, in the goroutine serving the request, and responds once the handler returns: with the reply if the handler made one, or with an empty 200 OK otherwise. A request that fails the webhook secret token check is answered with 401 Unauthorized, and one with an unreadable body with 400 Bad Request.

type CallbackQueryMode added in v1.31.0

type CallbackQueryMode string

CallbackQueryMode is how the bot receives callback queries from buttons in messages it sent. https://core.telegram.org/bots/api#setmysettings

const (
	CallbackQueryModeDefault CallbackQueryMode = "default"
	CallbackQueryModeAuto    CallbackQueryMode = "auto"
	CallbackQueryModeInline  CallbackQueryMode = "inline"
)

type CloseForumTopicParams added in v0.3.1

type CloseForumTopicParams struct {
	ChatID          any `json:"chat_id"`
	MessageThreadID int `json:"message_thread_id"`
}

type CloseGeneralForumTopicParams added in v0.3.4

type CloseGeneralForumTopicParams struct {
	ChatID any `json:"chat_id"`
}

type ConvertGiftToStarsParams added in v1.15.0

type ConvertGiftToStarsParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	OwnedGiftID          string `json:"owned_gift_id"`
}

ConvertGiftToStarsParams https://core.telegram.org/bots/api#convertgifttostars

type CopyMessageParams

type CopyMessageParams struct {
	ChatID                  any                             `json:"chat_id"`
	MessageThreadID         int                             `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID   int                             `json:"direct_messages_topic_id,omitempty"`
	FromChatID              any                             `json:"from_chat_id"`
	MessageID               int                             `json:"message_id"`
	VideoStartTimestamp     int                             `json:"video_start_timestamp,omitempty"`
	Caption                 string                          `json:"caption,omitempty"`
	ParseMode               models.ParseMode                `json:"parse_mode,omitempty"`
	CaptionEntities         []models.MessageEntity          `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia   bool                            `json:"show_caption_above_media,omitempty"`
	DisableNotification     bool                            `json:"disable_notification,omitempty"`
	ProtectContent          bool                            `json:"protect_content,omitempty"`
	AllowPaidBroadcast      bool                            `json:"allow_paid_broadcast,omitempty"`
	SuggestedPostParameters *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
	MessageEffectID         string                          `json:"message_effect_id,omitempty"`
	ReplyParameters         *models.ReplyParameters         `json:"reply_parameters,omitempty"`
	ReplyMarkup             models.ReplyMarkup              `json:"reply_markup,omitempty"`
}

CopyMessageParams https://core.telegram.org/bots/api#copymessage

type CopyMessagesParams added in v1.0.0

type CopyMessagesParams struct {
	ChatID                any   `json:"chat_id"`
	MessageThreadID       int   `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID int   `json:"direct_messages_topic_id,omitempty"`
	FromChatID            any   `json:"from_chat_id"`
	MessageIDs            []int `json:"message_ids"`
	DisableNotification   bool  `json:"disable_notification,omitempty"`
	ProtectContent        bool  `json:"protect_content,omitempty"`
	RemoveCaption         bool  `json:"remove_caption,omitempty"`
}

CopyMessagesParams https://core.telegram.org/bots/api#copymessages

type CreateChatInviteLinkParams

type CreateChatInviteLinkParams struct {
	ChatID             any    `json:"chat_id"`
	Name               string `json:"name,omitempty"`
	ExpireDate         int    `json:"expire_date,omitempty"`
	MemberLimit        int    `json:"member_limit,omitempty"`
	CreatesJoinRequest bool   `json:"creates_join_request,omitempty"`
}

type CreateChatSubscriptionInviteLinkParams added in v1.7.0

type CreateChatSubscriptionInviteLinkParams struct {
	ChatID             any    `json:"chat_id"`
	Name               string `json:"name,omitempty"`
	SubscriptionPeriod int    `json:"subscription_period"`
	SubscriptionPrice  int    `json:"subscription_price"`
}

type CreateForumTopicParams added in v0.3.1

type CreateForumTopicParams struct {
	ChatID            any    `json:"chat_id"`
	Name              string `json:"name"`
	IconColor         int    `json:"icon_color,omitempty"`
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}

type CreateInvoiceLinkParams

type CreateInvoiceLinkParams struct {
	BusinessConnectionID      string                `json:"business_connection_id,omitempty"`
	Title                     string                `json:"title"`
	Description               string                `json:"description"`
	Payload                   string                `json:"payload"`
	ProviderToken             string                `json:"provider_token,omitempty"`
	Currency                  string                `json:"currency"`
	Prices                    []models.LabeledPrice `json:"prices"`
	SubscriptionPeriod        int                   `json:"subscription_period,omitempty"`
	MaxTipAmount              int                   `json:"max_tip_amount,omitempty"`
	SuggestedTipAmounts       []int                 `json:"suggested_tip_amounts,omitempty"`
	ProviderData              string                `json:"provider_data,omitempty"`
	PhotoURL                  string                `json:"photo_url,omitempty"`
	PhotoSize                 int                   `json:"photo_size,omitempty"`
	PhotoWidth                int                   `json:"photo_width,omitempty"`
	PhotoHeight               int                   `json:"photo_height,omitempty"`
	NeedName                  bool                  `json:"need_name,omitempty"`
	NeedPhoneNumber           bool                  `json:"need_phone_number,omitempty"`
	NeedEmail                 bool                  `json:"need_email,omitempty"`
	NeedShippingAddress       bool                  `json:"need_shipping_address,omitempty"`
	SendPhoneNumberToProvider bool                  `json:"send_phone_number_to_provider,omitempty"`
	SendEmailToProvider       bool                  `json:"send_email_to_provider,omitempty"`
	IsFlexible                bool                  `json:"is_flexible,omitempty"`
}

type CreateNewStickerSetParams

type CreateNewStickerSetParams struct {
	UserID          int64                 `json:"user_id"`
	Name            string                `json:"name"`
	Title           string                `json:"title"`
	Stickers        []models.InputSticker `json:"stickers"`
	StickerType     string                `json:"sticker_type,omitempty"`
	NeedsRepainting bool                  `json:"needs_repainting,omitempty"`
}

type DebugHandler added in v0.7.5

type DebugHandler func(format string, args ...any)

type DeclineChatJoinRequestParams

type DeclineChatJoinRequestParams struct {
	ChatID any   `json:"chat_id"`
	UserID int64 `json:"user_id"`
}

type DeclineSuggestedPostParams added in v1.17.0

type DeclineSuggestedPostParams struct {
	ChatID    int64  `json:"chat_id"`
	MessageID int    `json:"message_id"`
	Comment   string `json:"comment,omitempty"`
}

DeclineSuggestedPostParams https://core.telegram.org/bots/api#declinesuggestedpost

type DeleteAllMessageReactionsParams added in v1.21.0

type DeleteAllMessageReactionsParams struct {
	ChatID      any   `json:"chat_id"`
	UserID      int64 `json:"user_id,omitempty"`
	ActorChatID int64 `json:"actor_chat_id,omitempty"`
}

type DeleteBusinessAccountGiftParams added in v1.28.0

type DeleteBusinessAccountGiftParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	OwnedGiftID          string `json:"owned_gift_id"`
}

DeleteBusinessAccountGiftParams https://core.telegram.org/bots/api#deletebusinessaccountgift

type DeleteBusinessMessagesParams added in v1.15.0

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

DeleteBusinessMessagesParams https://core.telegram.org/bots/api#deletebusinessmessages

type DeleteChatPhotoParams

type DeleteChatPhotoParams struct {
	ChatID any `json:"chat_id"`
}

type DeleteChatStickerSetParams

type DeleteChatStickerSetParams struct {
	ChatID         any    `json:"chat_id"`
	StickerSetName string `json:"sticker_set_name"`
}

type DeleteEphemeralMessageParams added in v1.23.0

type DeleteEphemeralMessageParams struct {
	ChatID             any   `json:"chat_id"`
	ReceiverUserID     int64 `json:"receiver_user_id"`
	EphemeralMessageID int   `json:"ephemeral_message_id"`
}

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

type DeleteForumTopicParams added in v0.3.1

type DeleteForumTopicParams struct {
	ChatID          any `json:"chat_id"`
	MessageThreadID int `json:"message_thread_id"`
}

type DeleteMessageParams

type DeleteMessageParams struct {
	ChatID    any `json:"chat_id"`
	MessageID int `json:"message_id"`
}

DeleteMessageParams https://core.telegram.org/bots/api#deletemessage

type DeleteMessageReactionParams added in v1.21.0

type DeleteMessageReactionParams struct {
	ChatID      any   `json:"chat_id"`
	MessageID   int   `json:"message_id"`
	UserID      int64 `json:"user_id,omitempty"`
	ActorChatID int64 `json:"actor_chat_id,omitempty"`
}

type DeleteMessagesParams added in v1.0.0

type DeleteMessagesParams struct {
	ChatID     any   `json:"chat_id"`
	MessageIDs []int `json:"message_ids"`
}

DeleteMessagesParams https://core.telegram.org/bots/api#deletemessages

type DeleteMyCommandsParams

type DeleteMyCommandsParams struct {
	Scope        models.BotCommandScope `json:"scope,omitempty"`
	LanguageCode string                 `json:"language_code,omitempty"`
}

type DeleteStickerFromSetParams

type DeleteStickerFromSetParams struct {
	Sticker string `json:"sticker"`
}

type DeleteStickerSetParams added in v0.7.0

type DeleteStickerSetParams struct {
	Name string `json:"name"`
}

type DeleteStoryParams added in v1.15.0

type DeleteStoryParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	StoryID              int    `json:"story_id"`
}

DeleteStoryParams https://core.telegram.org/bots/api#deletestory

type DeleteWebhookParams

type DeleteWebhookParams struct {
	DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`
}

type EditChatInviteLinkParams

type EditChatInviteLinkParams struct {
	ChatID             any    `json:"chat_id"`
	InviteLink         string `json:"invite_link"`
	Name               string `json:"name,omitempty"`
	ExpireDate         int    `json:"expire_date,omitempty"`
	MemberLimit        int    `json:"member_limit,omitempty"`
	CreatesJoinRequest bool   `json:"creates_join_request,omitempty"`
}

type EditChatSubscriptionInviteLinkParams added in v1.7.0

type EditChatSubscriptionInviteLinkParams struct {
	ChatID     any    `json:"chat_id"`
	InviteLink string `json:"invite_link"`
	Name       string `json:"name,omitempty"`
}

type EditEphemeralMessageCaptionParams added in v1.23.0

type EditEphemeralMessageCaptionParams struct {
	ChatID                any                          `json:"chat_id"`
	ReceiverUserID        int64                        `json:"receiver_user_id"`
	EphemeralMessageID    int                          `json:"ephemeral_message_id"`
	Caption               string                       `json:"caption,omitempty"`
	ParseMode             models.ParseMode             `json:"parse_mode,omitempty"`
	CaptionEntities       []models.MessageEntity       `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia bool                         `json:"show_caption_above_media,omitempty"`
	ReplyMarkup           *models.InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

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

type EditEphemeralMessageMediaParams added in v1.23.0

type EditEphemeralMessageMediaParams struct {
	ChatID             any                          `json:"chat_id"`
	ReceiverUserID     int64                        `json:"receiver_user_id"`
	EphemeralMessageID int                          `json:"ephemeral_message_id"`
	Media              models.InputMedia            `json:"media"`
	ReplyMarkup        *models.InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

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

type EditEphemeralMessageReplyMarkupParams added in v1.23.0

type EditEphemeralMessageReplyMarkupParams struct {
	ChatID             any                          `json:"chat_id"`
	ReceiverUserID     int64                        `json:"receiver_user_id"`
	EphemeralMessageID int                          `json:"ephemeral_message_id"`
	ReplyMarkup        *models.InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

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

type EditEphemeralMessageTextParams added in v1.23.0

type EditEphemeralMessageTextParams struct {
	ChatID             any                          `json:"chat_id"`
	ReceiverUserID     int64                        `json:"receiver_user_id"`
	EphemeralMessageID int                          `json:"ephemeral_message_id"`
	Text               string                       `json:"text,omitempty"`
	ParseMode          models.ParseMode             `json:"parse_mode,omitempty"`
	Entities           []models.MessageEntity       `json:"entities,omitempty"`
	RichMessage        *models.InputRichMessage     `json:"rich_message,omitempty"`
	LinkPreviewOptions *models.LinkPreviewOptions   `json:"link_preview_options,omitempty"`
	ReplyMarkup        *models.InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

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

type EditForumTopicParams added in v0.3.1

type EditForumTopicParams struct {
	ChatID            any    `json:"chat_id"`
	MessageThreadID   int    `json:"message_thread_id"`
	Name              string `json:"name,omitempty"`
	IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}

type EditGeneralForumTopicParams added in v0.3.4

type EditGeneralForumTopicParams struct {
	ChatID any    `json:"chat_id"`
	Name   string `json:"name"`
}

type EditMessageCaptionParams

type EditMessageCaptionParams struct {
	BusinessConnectionID  string                 `json:"business_connection_id,omitempty"`
	ChatID                any                    `json:"chat_id,omitempty"`
	MessageID             int                    `json:"message_id,omitempty"`
	InlineMessageID       string                 `json:"inline_message_id,omitempty"`
	Caption               string                 `json:"caption,omitempty"`
	ParseMode             models.ParseMode       `json:"parse_mode,omitempty"`
	CaptionEntities       []models.MessageEntity `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia bool                   `json:"show_caption_above_media,omitempty"`
	DisableWebPagePreview bool                   `json:"disable_web_page_preview,omitempty"`
	ReplyMarkup           models.ReplyMarkup     `json:"reply_markup,omitempty"`
}

type EditMessageChecklistParams added in v1.16.0

type EditMessageChecklistParams struct {
	BusinessConnectionID string                `json:"business_connection_id,omitempty"`
	ChatID               int64                 `json:"chat_id,omitempty"`
	MessageID            int                   `json:"message_id,omitempty"`
	Checklist            models.InputChecklist `json:"checklist"`
	ReplyMarkup          models.ReplyMarkup    `json:"reply_markup,omitempty"`
}

EditMessageChecklistParams https://core.telegram.org/bots/api#editmessagechecklist

type EditMessageLiveLocationParams

type EditMessageLiveLocationParams struct {
	BusinessConnectionID string             `json:"business_connection_id,omitempty"`
	ChatID               any                `json:"chat_id,omitempty"`
	MessageID            int                `json:"message_id,omitempty"`
	InlineMessageID      string             `json:"inline_message_id,omitempty"`
	Latitude             float64            `json:"latitude"`
	Longitude            float64            `json:"longitude"`
	LivePeriod           int                `json:"live_period,omitempty"`
	HorizontalAccuracy   float64            `json:"horizontal_accuracy,omitempty"`
	Heading              int                `json:"heading,omitempty"`
	ProximityAlertRadius int                `json:"proximity_alert_radius,omitempty"`
	ReplyMarkup          models.ReplyMarkup `json:"reply_markup,omitempty"`
}

type EditMessageMediaParams

type EditMessageMediaParams struct {
	BusinessConnectionID string             `json:"business_connection_id,omitempty"`
	ChatID               any                `json:"chat_id,omitempty"`
	MessageID            int                `json:"message_id,omitempty"`
	InlineMessageID      string             `json:"inline_message_id,omitempty"`
	Media                models.InputMedia  `json:"media"`
	ReplyMarkup          models.ReplyMarkup `json:"reply_markup,omitempty"`
}

type EditMessageReplyMarkupParams

type EditMessageReplyMarkupParams struct {
	BusinessConnectionID string             `json:"business_connection_id,omitempty"`
	ChatID               any                `json:"chat_id,omitempty"`
	MessageID            int                `json:"message_id,omitempty"`
	InlineMessageID      string             `json:"inline_message_id,omitempty"`
	ReplyMarkup          models.ReplyMarkup `json:"reply_markup,omitempty"`
}

type EditMessageTextParams

type EditMessageTextParams struct {
	BusinessConnectionID string                     `json:"business_connection_id,omitempty"`
	ChatID               any                        `json:"chat_id,omitempty"`
	MessageID            int                        `json:"message_id,omitempty"`
	InlineMessageID      string                     `json:"inline_message_id,omitempty"`
	Text                 string                     `json:"text"`
	ParseMode            models.ParseMode           `json:"parse_mode,omitempty"`
	Entities             []models.MessageEntity     `json:"entities,omitempty"`
	LinkPreviewOptions   *models.LinkPreviewOptions `json:"link_preview_options,omitempty"`
	RichMessage          *models.InputRichMessage   `json:"rich_message,omitempty"`
	ReplyMarkup          models.ReplyMarkup         `json:"reply_markup,omitempty"`
}

EditMessageTextParams https://core.telegram.org/bots/api#editmessagetext

type EditMessageWidgetDataParams added in v1.28.0

type EditMessageWidgetDataParams struct {
	ChatID          any     `json:"chat_id,omitempty"`
	MessageID       int     `json:"message_id,omitempty"`
	InlineMessageID string  `json:"inline_message_id,omitempty"`
	PublicData      *string `json:"public_data,omitempty"`
	ChatData        *string `json:"chat_data,omitempty"`
}

EditMessageWidgetDataParams https://core.telegram.org/bots/api#editmessagewidgetdata

type EditSharedWidgetDataParams added in v1.28.0

type EditSharedWidgetDataParams struct {
	WidgetID   string `json:"widget_id"`
	PublicData string `json:"public_data"`
	CacheTime  int    `json:"cache_time,omitempty"`
}

EditSharedWidgetDataParams https://core.telegram.org/bots/api#editsharedwidgetdata

type EditStoryParams added in v1.15.0

type EditStoryParams struct {
	BusinessConnectionID string                   `json:"business_connection_id"`
	StoryID              int                      `json:"story_id"`
	Content              models.InputStoryContent `json:"content"`
	Caption              string                   `json:"caption,omitempty"`
	ParseMode            models.ParseMode         `json:"parse_mode,omitempty"`
	CaptionEntities      []models.MessageEntity   `json:"caption_entities,omitempty"`
	Areas                []models.StoryArea       `json:"areas,omitempty"`
}

EditStoryParams https://core.telegram.org/bots/api#editstory

type EditUserStarSubscriptionParams added in v1.11.0

type EditUserStarSubscriptionParams struct {
	UserID                  int64  `json:"user_id"`
	TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
	IsCanceled              bool   `json:"is_canceled"`
}

EditUserStarSubscriptionParams https://core.telegram.org/bots/api#edituserstarsubscription

type ErrorsHandler

type ErrorsHandler func(err error)

type ExportChatInviteLinkParams

type ExportChatInviteLinkParams struct {
	ChatID any `json:"chat_id"`
}

type ForwardMessageParams

type ForwardMessageParams struct {
	ChatID                  any                             `json:"chat_id"`
	MessageThreadID         int                             `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID   int                             `json:"direct_messages_topic_id,omitempty"`
	FromChatID              any                             `json:"from_chat_id"`
	VideoStartTimestamp     int                             `json:"video_start_timestamp,omitempty"`
	DisableNotification     bool                            `json:"disable_notification,omitempty"`
	ProtectContent          bool                            `json:"protect_content,omitempty"`
	SuggestedPostParameters *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
	MessageEffectID         string                          `json:"message_effect_id,omitempty"`
	MessageID               int                             `json:"message_id"`
}

ForwardMessageParams https://core.telegram.org/bots/api#forwardmessage

type ForwardMessagesParams added in v1.0.0

type ForwardMessagesParams struct {
	ChatID                any   `json:"chat_id"`
	MessageThreadID       int   `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID int   `json:"direct_messages_topic_id,omitempty"`
	FromChatID            any   `json:"from_chat_id"`
	MessageIDs            []int `json:"message_ids"`
	DisableNotification   bool  `json:"disable_notification,omitempty"`
	ProtectContent        bool  `json:"protect_content,omitempty"`
}

ForwardMessagesParams https://core.telegram.org/bots/api#forwardmessages

type GetBusinessAccountGiftsParams added in v1.15.0

type GetBusinessAccountGiftsParams struct {
	BusinessConnectionID        string `json:"business_connection_id"`
	ExcludeUnsaved              bool   `json:"exclude_unsaved,omitempty"`
	ExcludeSaved                bool   `json:"exclude_saved,omitempty"`
	ExcludeUnlimited            bool   `json:"exclude_unlimited,omitempty"`
	ExcludeLimitedUpgradable    bool   `json:"exclude_limited_upgradable,omitempty"`
	ExcludeLimitedNonUpgradable bool   `json:"exclude_limited_non_upgradable,omitempty"`
	ExcludeUnique               bool   `json:"exclude_unique,omitempty"`
	ExcludeFromBlockchain       bool   `json:"exclude_from_blockchain,omitempty"`
	SortByPrice                 bool   `json:"sort_by_price,omitempty"`
	Offset                      string `json:"offset,omitempty"`
	Limit                       int    `json:"limit,omitempty"`
}

GetBusinessAccountGiftsParams https://core.telegram.org/bots/api#getbusinessaccountgifts

type GetBusinessAccountStarBalanceParams added in v1.15.0

type GetBusinessAccountStarBalanceParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
}

GetBusinessAccountStarBalanceParams https://core.telegram.org/bots/api#getbusinessaccountstarbalance

type GetBusinessConnectionParams added in v1.8.4

type GetBusinessConnectionParams struct {
	BusinessConnectionID any `json:"business_connection_id"`
}

GetBusinessConnectionParams https://core.telegram.org/bots/api#getbusinessconnection

type GetChatAdministratorsParams

type GetChatAdministratorsParams struct {
	ChatID     any   `json:"chat_id"`
	ReturnBots *bool `json:"return_bots,omitempty"`
}

type GetChatGiftsParams added in v1.18.0

type GetChatGiftsParams struct {
	ChatID any    `json:"chat_id"`
	Offset string `json:"offset,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

GetChatGiftsParams https://core.telegram.org/bots/api#getchatgifts

type GetChatMemberCountParams

type GetChatMemberCountParams struct {
	ChatID any `json:"chat_id"`
}

type GetChatMemberParams

type GetChatMemberParams struct {
	ChatID any   `json:"chat_id"`
	UserID int64 `json:"user_id"`
}

type GetChatMenuButtonParams

type GetChatMenuButtonParams struct {
	ChatID any `json:"chat_id"`
}

type GetChatParams

type GetChatParams struct {
	ChatID any `json:"chat_id"`
}

type GetCustomEmojiStickersParams

type GetCustomEmojiStickersParams struct {
	CustomEmojiIDs []string `json:"custom_emoji_ids"`
}

type GetFileParams

type GetFileParams struct {
	FileID string `json:"file_id"`
}

type GetGameHighScoresParams

type GetGameHighScoresParams struct {
	UserID          int64 `json:"user_id"`
	ChatID          any   `json:"chat_id,omitempty"`
	MessageID       int   `json:"message_id,omitempty"`
	InlineMessageID int   `json:"inline_message_id,omitempty"`
}

type GetManagedBotAccessSettingsParams added in v1.21.0

type GetManagedBotAccessSettingsParams struct {
	UserID int64 `json:"user_id"`
}

type GetManagedBotTokenParams added in v1.21.0

type GetManagedBotTokenParams struct {
	UserID int64 `json:"user_id"`
}

type GetMyCommandsParams

type GetMyCommandsParams struct {
	Scope        models.BotCommandScope `json:"scope,omitempty"`
	LanguageCode string                 `json:"language_code,omitempty"`
}

type GetMyDefaultAdministratorRightsParams

type GetMyDefaultAdministratorRightsParams struct {
	ForChannels bool `json:"for_channels,omitempty"`
}

type GetMyDescriptionParams added in v0.7.0

type GetMyDescriptionParams struct {
	LanguageCode string `json:"language_code,omitempty"`
}

type GetMyNameParams added in v0.7.6

type GetMyNameParams struct {
	LanguageCode string `json:"language_code,omitempty"`
}

type GetMyShortDescriptionParams added in v0.7.0

type GetMyShortDescriptionParams struct {
	LanguageCode string `json:"language_code,omitempty"`
}

type GetStarTransactionsParams added in v1.5.0

type GetStarTransactionsParams struct {
	Offset int `json:"offset,omitempty"`
	Limit  int `json:"limit,omitempty"`
}

type GetStickerSetParams

type GetStickerSetParams struct {
	Name string `json:"name"`
}

type GetUniqueGiftParams added in v1.28.0

type GetUniqueGiftParams struct {
	Name string `json:"name"`
}

GetUniqueGiftParams https://core.telegram.org/bots/api#getuniquegift

type GetUserChatBoostsParams added in v1.0.0

type GetUserChatBoostsParams struct {
	ChatID any `json:"chat_id"`
	UserID int `json:"user_id"`
}

GetUserChatBoostsParams https://core.telegram.org/bots/api#getuserchatboosts

type GetUserGiftsParams added in v1.18.0

type GetUserGiftsParams struct {
	UserID int64  `json:"user_id"`
	Offset string `json:"offset,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

GetUserGiftsParams https://core.telegram.org/bots/api#getusergifts

type GetUserPersonalChatMessagesParams added in v1.21.0

type GetUserPersonalChatMessagesParams struct {
	UserID int64 `json:"user_id"`
	Limit  int   `json:"limit"`
}

type GetUserProfileAudiosParams added in v1.19.0

type GetUserProfileAudiosParams struct {
	UserID int64 `json:"user_id"`
	Offset int   `json:"offset,omitempty"`
	Limit  int   `json:"limit,omitempty"`
}

GetUserProfileAudiosParams https://core.telegram.org/bots/api#getuserprofileaudios

type GetUserProfilePhotosParams

type GetUserProfilePhotosParams struct {
	UserID int64 `json:"user_id"`
	Offset int   `json:"offset,omitempty"`
	Limit  int   `json:"limit,omitempty"`
}

type GiftPremiumSubscriptionParams added in v1.15.0

type GiftPremiumSubscriptionParams struct {
	UserID        int64                  `json:"user_id"`
	MonthCount    int                    `json:"month_count"`
	StarCount     int                    `json:"star_count"`
	Text          string                 `json:"text,omitempty"`
	TextParseMode string                 `json:"text_parse_mode,omitempty"`
	TextEntities  []models.MessageEntity `json:"text_entities,omitempty"`
}

GiftPremiumSubscriptionParams https://core.telegram.org/bots/api#giftpremiumsubscription

type HandlerFunc

type HandlerFunc func(ctx context.Context, bot *Bot, update *models.Update)

type HandlerType

type HandlerType int

HandlerType selects the update data that a handler matches against.

const (
	HandlerTypeMessageText                HandlerType = iota // Text of Update.Message
	HandlerTypeCallbackQueryData                             // Data of Update.CallbackQuery
	HandlerTypeCallbackQueryGameShortName                    // GameShortName of Update.CallbackQuery
	HandlerTypePhotoCaption                                  // Caption of Update.Message, for any message type
	HandlerTypeInlineQuery                                   // Query of Update.InlineQuery
	HandlerTypeWidgetQueryData                               // Data of Update.WidgetQuery
	HandlerTypeSharedWidgetQueryData                         // Data of Update.SharedWidgetQuery
)

type HideGeneralForumTopicParams added in v0.3.4

type HideGeneralForumTopicParams struct {
	ChatID any `json:"chat_id"`
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type LeaveChatParams

type LeaveChatParams struct {
	ChatID any `json:"chat_id"`
}

type MatchFunc added in v0.3.3

type MatchFunc func(update *models.Update) bool

type MatchType

type MatchType int

MatchType defines how a handler pattern is compared with the update data.

const (
	MatchTypeExact    MatchType = iota // Data equals pattern
	MatchTypePrefix                    // Data starts with pattern
	MatchTypeContains                  // Data contains pattern
	// MatchTypeCommand matches a bot command anywhere in a message text or
	// caption, so it works only with HandlerTypeMessageText and
	// HandlerTypePhotoCaption. Specify the command without the slash, such as
	// "start". After GetMe succeeds it also matches commands addressed to the
	// bot's primary username or any of its active usernames.
	MatchTypeCommand
	// MatchTypeCommandStartOnly is like MatchTypeCommand, but the command must
	// be at the start of the text or caption.
	MatchTypeCommandStartOnly
)

type Middleware

type Middleware func(next HandlerFunc) HandlerFunc

type MigrateError added in v1.2.1

type MigrateError struct {
	Message         string
	MigrateToChatID int
}

func (*MigrateError) Error added in v1.2.1

func (e *MigrateError) Error() string

type Option

type Option func(b *Bot)

Option is a function that configures a bot.

func UseTestEnvironment added in v1.7.1

func UseTestEnvironment() Option

UseTestEnvironment sends API requests to the Telegram test environment.

func WithAllowedUpdates added in v1.1.5

func WithAllowedUpdates(params AllowedUpdates) Option

WithAllowedUpdates sets the update types requested from getUpdates. It applies only to polling.

func WithCallbackQueryDataHandler

func WithCallbackQueryDataHandler(pattern string, matchType MatchType, handler HandlerFunc) Option

WithCallbackQueryDataHandler registers a handler for callback queries whose data matches pattern and matchType. To add a handler after creating the bot, use Bot.RegisterHandler.

func WithCheckInitTimeout added in v0.3.0

func WithCheckInitTimeout(timeout time.Duration) Option

WithCheckInitTimeout sets the timeout for the GetMe call that New makes.

func WithDebug

func WithDebug() Option

WithDebug enables debug mode. The debug handler then receives API requests, API responses and webhook payloads, except getUpdates requests and responses whose result is an empty array.

func WithDebugHandler added in v0.7.5

func WithDebugHandler(handler DebugHandler) Option

WithDebugHandler sets the handler for debug messages. The bot emits them only in debug mode, see WithDebug.

func WithDefaultHandler

func WithDefaultHandler(handler HandlerFunc) Option

WithDefaultHandler sets the handler for updates that no registered handler matches.

func WithErrorsHandler

func WithErrorsHandler(handler ErrorsHandler) Option

WithErrorsHandler sets the callback for errors reported internally by the library, such as polling and webhook processing errors. Errors from API methods such as SendMessage are returned to the caller and must be handled there.

func WithHTTPClient

func WithHTTPClient(pollTimeout time.Duration, client HttpClient) Option

WithHTTPClient sets the HTTP client for requests to the Telegram API and the polling timeout. A getUpdates request asks Telegram to wait up to pollTimeout minus one second.

func WithInitialOffset added in v1.13.3

func WithInitialOffset(offset int64) Option

WithInitialOffset sets the ID of the last processed update. The first getUpdates request uses offset+1 as its offset.

func WithMessageTextHandler

func WithMessageTextHandler(pattern string, matchType MatchType, handler HandlerFunc) Option

WithMessageTextHandler registers a handler for messages whose text matches pattern and matchType. To add a handler after creating the bot, use Bot.RegisterHandler.

func WithMiddlewares

func WithMiddlewares(middlewares ...Middleware) Option

WithMiddlewares adds middlewares that wrap the handler of each incoming update. A middleware can run code before and after the next handler, or skip it. The first added middleware is the outermost, so they start in the order added.

func WithNotAsyncHandlers added in v1.9.0

func WithNotAsyncHandlers() Option

WithNotAsyncHandlers runs each handler synchronously in the calling goroutine: the worker for queued updates, or the caller of ProcessUpdate. Each worker handles its updates sequentially, but several workers can still run handlers concurrently. A WebhookHandler request may wait for a busy worker.

func WithPhotoCaptionHandler added in v1.12.1

func WithPhotoCaptionHandler(pattern string, matchType MatchType, handler HandlerFunc) Option

WithPhotoCaptionHandler registers a handler for messages whose caption matches pattern and matchType. It checks the caption of any message type, not only photos. To add a handler after creating the bot, use Bot.RegisterHandler.

func WithServerURL

func WithServerURL(serverURL string) Option

WithServerURL sets the Bot API server URL, such as that of a local Bot API server.

func WithSkipGetMe added in v0.7.9

func WithSkipGetMe() Option

WithSkipGetMe allows skip call GetMe on bot init. A MatchTypeCommand or MatchTypeCommandStartOnly handler for a bare command such as start then matches /start@bot_username only after a GetMe call succeeds.

func WithUpdatesChannelCap added in v1.2.0

func WithUpdatesChannelCap(cap int) Option

WithUpdatesChannelCap sets the capacity of the queue between the update source and the workers. Start fetches the next batch only after the current one is dispatched, and a webhook request waits until a worker takes its update, so the capacity only bounds how many updates wait for a worker. New returns an error for a negative capacity.

func WithWebhookSecretToken added in v1.6.0

func WithWebhookSecretToken(webhookSecretToken string) Option

WithWebhookSecretToken sets the expected value of the X-Telegram-Bot-Api-Secret-Token header. Webhook requests with a different value are rejected. An empty token disables the check.

func WithWorkers added in v1.8.1

func WithWorkers(workers int) Option

WithWorkers sets the number of workers that take updates from the queue. By default a worker starts each handler in a new goroutine, so this number does not limit concurrent handlers. With WithNotAsyncHandlers, it limits how many queued updates are handled at once. Start and StartWebhook report an error and return if workers is not positive.

type PinChatMessageParams

type PinChatMessageParams struct {
	ChatID              any  `json:"chat_id"`
	MessageID           int  `json:"message_id"`
	DisableNotification bool `json:"disable_notification,omitempty"`
}

type PostStoryParams added in v1.15.0

type PostStoryParams struct {
	BusinessConnectionID string                   `json:"business_connection_id"`
	Content              models.InputStoryContent `json:"content"`
	ActivePeriod         int                      `json:"active_period"`
	Caption              string                   `json:"caption,omitempty"`
	ParseMode            models.ParseMode         `json:"parse_mode,omitempty"`
	CaptionEntities      []models.MessageEntity   `json:"caption_entities,omitempty"`
	Areas                []models.StoryArea       `json:"areas,omitempty"`
	PostToChatPage       bool                     `json:"post_to_chat_page,omitempty"`
	ProtectContent       bool                     `json:"protect_content,omitempty"`
}

PostStoryParams https://core.telegram.org/bots/api#poststory

type PromoteChatMemberParams

type PromoteChatMemberParams struct {
	ChatID                  any   `json:"chat_id" rules:"required,chat_id"`
	UserID                  int64 `json:"user_id" rules:"required"`
	IsAnonymous             bool  `json:"is_anonymous,omitempty"`
	CanManageChat           bool  `json:"can_manage_chat,omitempty"`
	CanDeleteMessages       bool  `json:"can_delete_messages,omitempty"`
	CanManageVideoChats     bool  `json:"can_manage_video_chats,omitempty"`
	CanRestrictMembers      bool  `json:"can_restrict_members,omitempty"`
	CanPromoteMembers       bool  `json:"can_promote_members,omitempty"`
	CanChangeInfo           bool  `json:"can_change_info,omitempty"`
	CanInviteUsers          bool  `json:"can_invite_users,omitempty"`
	CanPostMessages         bool  `json:"can_post_messages,omitempty"`
	CanEditMessages         bool  `json:"can_edit_messages,omitempty"`
	CanPinMessages          bool  `json:"can_pin_messages,omitempty"`
	CanPostStories          bool  `json:"can_post_stories,omitempty"`
	CanEditStories          bool  `json:"can_edit_stories,omitempty"`
	CanDeleteStories        bool  `json:"can_delete_stories,omitempty"`
	CanManageTopics         bool  `json:"can_manage_topics,omitempty"`
	CanManageDirectMessages bool  `json:"can_manage_direct_messages,omitempty"`
	CanManageTags           bool  `json:"can_manage_tags,omitempty"`
	CanSendWelcomeMessages  bool  `json:"can_send_welcome_messages,omitempty"`
}

type ReadBusinessMessageParams added in v1.15.0

type ReadBusinessMessageParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	ChatID               int64  `json:"chat_id"`
	MessageID            int    `json:"message_id"`
}

ReadBusinessMessageParams https://core.telegram.org/bots/api#readbusinessmessage

type RefundStarPaymentParams added in v1.4.0

type RefundStarPaymentParams struct {
	UserID                  int64  `json:"user_id"`
	TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
}

type RemoveBusinessAccountProfilePhotoParams added in v1.15.0

type RemoveBusinessAccountProfilePhotoParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	IsPublic             bool   `json:"is_public,omitempty"`
}

RemoveBusinessAccountProfilePhotoParams https://core.telegram.org/bots/api#removebusinessaccountprofilephoto

type RemoveChatVerificationParams added in v1.13.0

type RemoveChatVerificationParams struct {
	ChatID any `json:"chat_id"`
}

RemoveChatVerificationParams https://core.telegram.org/bots/api#removechatverification

type RemoveUserVerificationParams added in v1.13.0

type RemoveUserVerificationParams struct {
	UserID int64 `json:"user_id"`
}

RemoveUserVerificationParams https://core.telegram.org/bots/api#removeuserverification

type ReopenForumTopicParams added in v0.3.1

type ReopenForumTopicParams struct {
	ChatID          any `json:"chat_id"`
	MessageThreadID int `json:"message_thread_id"`
}

type ReopenGeneralForumTopicParams added in v0.3.4

type ReopenGeneralForumTopicParams struct {
	ChatID any `json:"chat_id"`
}

type ReplaceManagedBotTokenParams added in v1.21.0

type ReplaceManagedBotTokenParams struct {
	UserID int64 `json:"user_id"`
}

type ReplaceStickerInSetParams added in v1.2.0

type ReplaceStickerInSetParams struct {
	UserID     int64               `json:"user_id"`
	Name       string              `json:"name"`
	OldSticker string              `json:"old_sticker"`
	Sticker    models.InputSticker `json:"sticker"`
}

type RepostStoryParams added in v1.19.0

type RepostStoryParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	FromChatID           int64  `json:"from_chat_id"`
	FromStoryID          int    `json:"from_story_id"`
	ActivePeriod         int    `json:"active_period"`
	PostToChatPage       bool   `json:"post_to_chat_page,omitempty"`
	ProtectContent       bool   `json:"protect_content,omitempty"`
}

RepostStoryParams https://core.telegram.org/bots/api#repoststory

type RestrictChatMemberParams

type RestrictChatMemberParams struct {
	ChatID                        any                     `json:"chat_id"`
	UserID                        int64                   `json:"user_id"`
	Permissions                   *models.ChatPermissions `json:"permissions,omitempty"`
	UseIndependentChatPermissions bool                    `json:"use_independent_chat_permissions,omitempty"`
	UntilDate                     int                     `json:"until_date,omitempty"`
}

type RevokeChatInviteLinkParams

type RevokeChatInviteLinkParams struct {
	ChatID     any    `json:"chat_id"`
	InviteLink string `json:"invite_link"`
}

type SavePreparedInlineMessageParams added in v1.11.0

type SavePreparedInlineMessageParams struct {
	UserID            int64                    `json:"user_id"`
	Result            models.InlineQueryResult `json:"result"`
	AllowUserChats    bool                     `json:"allow_user_chats,omitempty"`
	AllowBotChats     bool                     `json:"allow_bot_chats,omitempty"`
	AllowGroupChats   bool                     `json:"allow_group_chats,omitempty"`
	AllowChannelChats bool                     `json:"allow_channel_chats,omitempty"`
}

SavePreparedInlineMessageParams https://core.telegram.org/bots/api#savepreparedinlinemessage

type SavePreparedKeyboardButtonParams added in v1.21.0

type SavePreparedKeyboardButtonParams struct {
	UserID int64                 `json:"user_id"`
	Button models.KeyboardButton `json:"button"`
}

type SendAnimationParams

type SendAnimationParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Animation                  models.InputFile                   `json:"animation"`
	Duration                   int                                `json:"duration,omitempty"`
	Width                      int                                `json:"width,omitempty"`
	Height                     int                                `json:"height,omitempty"`
	Thumbnail                  models.InputFile                   `json:"thumbnail,omitempty"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia      bool                               `json:"show_caption_above_media,omitempty"`
	HasSpoiler                 bool                               `json:"has_spoiler,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendAnimationParams https://core.telegram.org/bots/api#sendanimation

type SendAudioParams

type SendAudioParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Audio                      models.InputFile                   `json:"audio"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	Duration                   int                                `json:"duration,omitempty"`
	Performer                  string                             `json:"performer,omitempty"`
	Title                      string                             `json:"title,omitempty"`
	Thumbnail                  models.InputFile                   `json:"thumbnail,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendAudioParams https://core.telegram.org/bots/api#sendaudio

type SendChatActionParams

type SendChatActionParams struct {
	BusinessConnectionID string            `json:"business_connection_id,omitempty"`
	ChatID               any               `json:"chat_id"`
	MessageThreadID      int               `json:"message_thread_id,omitempty"`
	Action               models.ChatAction `json:"action"`
}

type SendChatJoinRequestWebAppParams added in v1.31.0

type SendChatJoinRequestWebAppParams struct {
	ChatJoinRequestQueryID string `json:"chat_join_request_query_id"`
	WebAppURL              string `json:"web_app_url"`
}

type SendChecklistParams added in v1.16.0

type SendChecklistParams struct {
	BusinessConnectionID string                  `json:"business_connection_id,omitempty"`
	ChatID               any                     `json:"chat_id"`
	Checklist            models.InputChecklist   `json:"checklist"`
	DisableNotification  bool                    `json:"disable_notification,omitempty"`
	ProtectContent       bool                    `json:"protect_content,omitempty"`
	MessageEffectID      string                  `json:"message_effect_id,omitempty"`
	ReplyParameters      *models.ReplyParameters `json:"reply_parameters,omitempty"`
	ReplyMarkup          models.ReplyMarkup      `json:"reply_markup,omitempty"`
}

SendChecklistParams https://core.telegram.org/bots/api#sendchecklist

type SendContactParams

type SendContactParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	PhoneNumber                string                             `json:"phone_number"`
	FirstName                  string                             `json:"first_name"`
	LastName                   string                             `json:"last_name,omitempty"`
	VCard                      string                             `json:"vcard,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendContactParams https://core.telegram.org/bots/api#sendcontact

type SendDiceParams

type SendDiceParams struct {
	BusinessConnectionID    string                          `json:"business_connection_id,omitempty"`
	ChatID                  any                             `json:"chat_id"`
	MessageThreadID         int                             `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID   int                             `json:"direct_messages_topic_id,omitempty"`
	Emoji                   string                          `json:"emoji,omitempty"`
	DisableNotification     bool                            `json:"disable_notification,omitempty"`
	ProtectContent          bool                            `json:"protect_content,omitempty"`
	AllowPaidBroadcast      bool                            `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID         string                          `json:"message_effect_id,omitempty"`
	SuggestedPostParameters *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
	ReplyParameters         *models.ReplyParameters         `json:"reply_parameters,omitempty"`
	ReplyMarkup             models.ReplyMarkup              `json:"reply_markup,omitempty"`
}

SendDiceParams https://core.telegram.org/bots/api#senddice

type SendDocumentParams

type SendDocumentParams struct {
	BusinessConnectionID        string                             `json:"business_connection_id,omitempty"`
	ChatID                      any                                `json:"chat_id,omitempty"`
	MessageThreadID             int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID       int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters  *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Document                    models.InputFile                   `json:"document"`
	Thumbnail                   models.InputFile                   `json:"thumbnail,omitempty"`
	Caption                     string                             `json:"caption,omitempty"`
	ParseMode                   models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities             []models.MessageEntity             `json:"caption_entities,omitempty"`
	DisableContentTypeDetection bool                               `json:"disable_content_type_detection,omitempty"`
	DisableNotification         bool                               `json:"disable_notification,omitempty"`
	ProtectContent              bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast          bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID             string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters     *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters             *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                 models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendDocumentParams https://core.telegram.org/bots/api#senddocument

type SendGameParams

type SendGameParams struct {
	BusinessConnectionID string                  `json:"business_connection_id,omitempty"`
	ChatID               any                     `json:"chat_id"`
	MessageThreadID      int                     `json:"message_thread_id,omitempty"`
	GameShorName         string                  `json:"game_short_name"`
	DisableNotification  bool                    `json:"disable_notification,omitempty"`
	ProtectContent       bool                    `json:"protect_content,omitempty"`
	AllowPaidBroadcast   bool                    `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID      string                  `json:"message_effect_id,omitempty"`
	ReplyParameters      *models.ReplyParameters `json:"reply_parameters,omitempty"`
	ReplyMarkup          models.ReplyMarkup      `json:"reply_markup,omitempty"`
}

SendGameParams https://core.telegram.org/bots/api#sendgame

type SendGiftParams added in v1.11.0

type SendGiftParams struct {
	UserID        int64                  `json:"user_id"`
	ChatID        any                    `json:"chat_id,omitempty"`
	GiftID        string                 `json:"gift_id"`
	PayForUpgrade bool                   `json:"pay_for_upgrade,omitempty"`
	Text          string                 `json:"text,omitempty"`
	TextParseMode models.ParseMode       `json:"text_parse_mode,omitempty"`
	TextEntities  []models.MessageEntity `json:"text_entities,omitempty"`
}

SendGiftParams https://core.telegram.org/bots/api#sendgift

type SendInvoiceParams

type SendInvoiceParams struct {
	ChatID                    any                             `json:"chat_id"`
	MessageThreadID           int                             `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID     int                             `json:"direct_messages_topic_id,omitempty"`
	Title                     string                          `json:"title"`
	Description               string                          `json:"description"`
	Payload                   string                          `json:"payload"`
	ProviderToken             string                          `json:"provider_token,omitempty"`
	Currency                  string                          `json:"currency"`
	Prices                    []models.LabeledPrice           `json:"prices"`
	MaxTipAmount              int                             `json:"max_tip_amount,omitempty"`
	SuggestedTipAmounts       []int                           `json:"suggested_tip_amounts,omitempty"`
	StartParameter            string                          `json:"start_parameter,omitempty"`
	ProviderData              string                          `json:"provider_data,omitempty"`
	PhotoURL                  string                          `json:"photo_url,omitempty"`
	PhotoSize                 int                             `json:"photo_size,omitempty"`
	PhotoWidth                int                             `json:"photo_width,omitempty"`
	PhotoHeight               int                             `json:"photo_height,omitempty"`
	NeedName                  bool                            `json:"need_name,omitempty"`
	NeedPhoneNumber           bool                            `json:"need_phone_number,omitempty"`
	NeedEmail                 bool                            `json:"need_email,omitempty"`
	NeedShippingAddress       bool                            `json:"need_shipping_address,omitempty"`
	SendPhoneNumberToProvider bool                            `json:"send_phone_number_to_provider,omitempty"`
	SendEmailToProvider       bool                            `json:"send_email_to_provider,omitempty"`
	IsFlexible                bool                            `json:"is_flexible,omitempty"`
	DisableNotification       bool                            `json:"disable_notification,omitempty"`
	ProtectContent            bool                            `json:"protect_content,omitempty"`
	AllowPaidBroadcast        bool                            `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID           string                          `json:"message_effect_id,omitempty"`
	SuggestedPostParameters   *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
	ReplyParameters           *models.ReplyParameters         `json:"reply_parameters,omitempty"`
	ReplyMarkup               models.ReplyMarkup              `json:"reply_markup,omitempty"`
}

SendInvoiceParams https://core.telegram.org/bots/api#sendinvoice

type SendLivePhotoParams added in v1.21.0

type SendLivePhotoParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	LivePhoto                  models.InputFile                   `json:"live_photo"`
	Photo                      models.InputFile                   `json:"photo"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia      bool                               `json:"show_caption_above_media,omitempty"`
	HasSpoiler                 bool                               `json:"has_spoiler,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

type SendLocationParams

type SendLocationParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Latitude                   float64                            `json:"latitude"`
	Longitude                  float64                            `json:"longitude"`
	HorizontalAccuracy         float64                            `json:"horizontal_accuracy,omitempty"`
	LivePeriod                 int                                `json:"live_period,omitempty"`
	Heading                    int                                `json:"heading,omitempty"`
	ProximityAlertRadius       int                                `json:"proximity_alert_radius,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendLocationParams https://core.telegram.org/bots/api#sendlocation

type SendMediaGroupParams

type SendMediaGroupParams struct {
	BusinessConnectionID  string                  `json:"business_connection_id,omitempty"`
	ChatID                any                     `json:"chat_id"`
	MessageThreadID       int                     `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID int                     `json:"direct_messages_topic_id,omitempty"`
	Media                 []models.InputMedia     `json:"media"`
	DisableNotification   bool                    `json:"disable_notification,omitempty"`
	ProtectContent        bool                    `json:"protect_content,omitempty"`
	AllowPaidBroadcast    bool                    `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID       string                  `json:"message_effect_id,omitempty"`
	ReplyParameters       *models.ReplyParameters `json:"reply_parameters,omitempty"`
}

SendMediaGroupParams https://core.telegram.org/bots/api#sendmediagroup

type SendMessageDraftParams added in v1.18.0

type SendMessageDraftParams struct {
	BusinessConnectionID string                 `json:"business_connection_id,omitempty"`
	ChatID               any                    `json:"chat_id"`
	MessageThreadID      int                    `json:"message_thread_id,omitempty"`
	DraftID              string                 `json:"draft_id"`
	Text                 string                 `json:"text"`
	ParseMode            models.ParseMode       `json:"parse_mode,omitempty"`
	Entities             []models.MessageEntity `json:"entities,omitempty"`
	CanStop              bool                   `json:"can_stop,omitempty"`
	KeepOnStop           bool                   `json:"keep_on_stop,omitempty"`
}

SendMessageDraftParams https://core.telegram.org/bots/api#sendmessagedraft

type SendMessageParams

type SendMessageParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Text                       string                             `json:"text"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	Entities                   []models.MessageEntity             `json:"entities,omitempty"`
	LinkPreviewOptions         *models.LinkPreviewOptions         `json:"link_preview_options,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendMessageParams https://core.telegram.org/bots/api#sendmessage

type SendPaidMediaParams added in v1.6.0

type SendPaidMediaParams struct {
	BusinessConnectionID    string                          `json:"business_connection_id,omitempty"`
	ChatID                  any                             `json:"chat_id"`
	StarCount               int                             `json:"star_count"`
	MessageThreadID         int                             `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID   int                             `json:"direct_messages_topic_id,omitempty"`
	Media                   []models.InputPaidMedia         `json:"media"`
	Payload                 string                          `json:"payload,omitempty"`
	Caption                 string                          `json:"caption,omitempty"`
	ParseMode               models.ParseMode                `json:"parse_mode,omitempty"`
	CaptionEntities         []models.MessageEntity          `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia   bool                            `json:"show_caption_above_media,omitempty"`
	DisableNotification     bool                            `json:"disable_notification,omitempty"`
	ProtectContent          bool                            `json:"protect_content,omitempty"`
	AllowPaidBroadcast      bool                            `json:"allow_paid_broadcast,omitempty"`
	SuggestedPostParameters *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"`
	ReplyParameters         *models.ReplyParameters         `json:"reply_parameters,omitempty"`
	ReplyMarkup             models.ReplyMarkup              `json:"reply_markup,omitempty"`
}

SendPaidMediaParams https://core.telegram.org/bots/api#sendpaidmedia

type SendPhotoParams

type SendPhotoParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Photo                      models.InputFile                   `json:"photo"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia      bool                               `json:"show_caption_above_media,omitempty"`
	HasSpoiler                 bool                               `json:"has_spoiler,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendPhotoParams https://core.telegram.org/bots/api#sendphoto

type SendPollParams

type SendPollParams struct {
	BusinessConnectionID   string                   `json:"business_connection_id,omitempty"`
	ChatID                 any                      `json:"chat_id"`
	MessageThreadID        int                      `json:"message_thread_id,omitempty"`
	Question               string                   `json:"question"`
	QuestionParseMode      models.ParseMode         `json:"question_parse_mode,omitempty"`
	QuestionEntities       []models.MessageEntity   `json:"question_entities,omitempty"`
	Options                []models.InputPollOption `json:"options"`
	IsAnonymous            *bool                    `json:"is_anonymous,omitempty"`
	Type                   string                   `json:"type,omitempty"`
	AllowsMultipleAnswers  bool                     `json:"allows_multiple_answers,omitempty"`
	CorrectOptionIDs       []int                    `json:"correct_option_ids,omitempty"`
	Explanation            string                   `json:"explanation,omitempty"`
	ExplanationParseMode   string                   `json:"explanation_parse_mode,omitempty"`
	ExplanationEntities    []models.MessageEntity   `json:"explanation_entities,omitempty"`
	Description            string                   `json:"description,omitempty"`
	DescriptionParseMode   models.ParseMode         `json:"description_parse_mode,omitempty"`
	DescriptionEntities    []models.MessageEntity   `json:"description_entities,omitempty"`
	Media                  models.InputMedia        `json:"media,omitempty"`
	ExplanationMedia       models.InputMedia        `json:"explanation_media,omitempty"`
	MembersOnly            bool                     `json:"members_only,omitempty"`
	CountryCodes           []string                 `json:"country_codes,omitempty"`
	AllowsRevoting         bool                     `json:"allows_revoting,omitempty"`
	ShuffleOptions         bool                     `json:"shuffle_options,omitempty"`
	AllowAddingOptions     bool                     `json:"allow_adding_options,omitempty"`
	HideResultsUntilCloses bool                     `json:"hide_results_until_closes,omitempty"`
	OpenPeriod             int                      `json:"open_period,omitempty"`
	CloseDate              int                      `json:"close_date,omitempty"`
	IsClosed               bool                     `json:"is_closed,omitempty"`
	DisableNotification    bool                     `json:"disable_notification,omitempty"`
	ProtectContent         bool                     `json:"protect_content,omitempty"`
	AllowPaidBroadcast     bool                     `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID        string                   `json:"message_effect_id,omitempty"`
	ReplyParameters        *models.ReplyParameters  `json:"reply_parameters,omitempty"`
	ReplyMarkup            models.ReplyMarkup       `json:"reply_markup,omitempty"`
}

SendPollParams https://core.telegram.org/bots/api#sendpoll

type SendRichMessageDraftParams added in v1.22.0

type SendRichMessageDraftParams struct {
	ChatID          any                     `json:"chat_id"`
	MessageThreadID int                     `json:"message_thread_id,omitempty"`
	DraftID         int                     `json:"draft_id"`
	RichMessage     models.InputRichMessage `json:"rich_message"`
	CanStop         bool                    `json:"can_stop,omitempty"`
	KeepOnStop      bool                    `json:"keep_on_stop,omitempty"`
}

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

type SendRichMessageParams added in v1.22.0

type SendRichMessageParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	RichMessage                models.InputRichMessage            `json:"rich_message"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

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

type SendSharedWidgetParams added in v1.28.0

type SendSharedWidgetParams struct {
	ChatID                any                     `json:"chat_id"`
	MessageThreadID       int                     `json:"message_thread_id,omitempty"`
	WidgetID              string                  `json:"widget_id"`
	ChatData              string                  `json:"chat_data,omitempty"`
	Caption               string                  `json:"caption,omitempty"`
	ParseMode             models.ParseMode        `json:"parse_mode,omitempty"`
	CaptionEntities       []models.MessageEntity  `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia bool                    `json:"show_caption_above_media,omitempty"`
	DisableNotification   bool                    `json:"disable_notification,omitempty"`
	ProtectContent        bool                    `json:"protect_content,omitempty"`
	AllowPaidBroadcast    bool                    `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID       string                  `json:"message_effect_id,omitempty"`
	ReplyParameters       *models.ReplyParameters `json:"reply_parameters,omitempty"`
	ReplyMarkup           models.ReplyMarkup      `json:"reply_markup,omitempty"`
}

SendSharedWidgetParams https://core.telegram.org/bots/api#sendsharedwidget

type SendStickerParams

type SendStickerParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Sticker                    models.InputFile                   `json:"sticker"`
	Emoji                      string                             `json:"emoji,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendStickerParams https://core.telegram.org/bots/api#sendsticker

type SendVenueParams

type SendVenueParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	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"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendVenueParams https://core.telegram.org/bots/api#sendvenue

type SendVideoNoteParams

type SendVideoNoteParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	VideoNote                  models.InputFile                   `json:"video_note"`
	Duration                   int                                `json:"duration,omitempty"`
	Length                     int                                `json:"length,omitempty"`
	Thumbnail                  models.InputFile                   `json:"thumbnail,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendVideoNoteParams https://core.telegram.org/bots/api#sendvideonote

type SendVideoParams

type SendVideoParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Video                      models.InputFile                   `json:"video"`
	Duration                   int                                `json:"duration,omitempty"`
	Width                      int                                `json:"width,omitempty"`
	Height                     int                                `json:"height,omitempty"`
	Thumbnail                  models.InputFile                   `json:"thumbnail,omitempty"`
	Cover                      models.InputFile                   `json:"cover,omitempty"`
	StartTimestamp             int                                `json:"start_timestamp,omitempty"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia      bool                               `json:"show_caption_above_media,omitempty"`
	HasSpoiler                 bool                               `json:"has_spoiler,omitempty"`
	SupportsStreaming          bool                               `json:"supports_streaming,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendVideoParams https://core.telegram.org/bots/api#sendvideo

type SendVoiceParams

type SendVoiceParams struct {
	BusinessConnectionID       string                             `json:"business_connection_id,omitempty"`
	ChatID                     any                                `json:"chat_id,omitempty"`
	MessageThreadID            int                                `json:"message_thread_id,omitempty"`
	DirectMessagesTopicID      int                                `json:"direct_messages_topic_id,omitempty"`
	EphemeralMessageParameters *models.EphemeralMessageParameters `json:"ephemeral_message_parameters,omitempty"`
	Voice                      models.InputFile                   `json:"voice"`
	Caption                    string                             `json:"caption,omitempty"`
	ParseMode                  models.ParseMode                   `json:"parse_mode,omitempty"`
	CaptionEntities            []models.MessageEntity             `json:"caption_entities,omitempty"`
	Duration                   int                                `json:"duration,omitempty"`
	DisableNotification        bool                               `json:"disable_notification,omitempty"`
	ProtectContent             bool                               `json:"protect_content,omitempty"`
	AllowPaidBroadcast         bool                               `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID            string                             `json:"message_effect_id,omitempty"`
	SuggestedPostParameters    *models.SuggestedPostParameters    `json:"suggested_post_parameters,omitempty"`
	ReplyParameters            *models.ReplyParameters            `json:"reply_parameters,omitempty"`
	ReplyMarkup                models.ReplyMarkup                 `json:"reply_markup,omitempty"`
}

SendVoiceParams https://core.telegram.org/bots/api#sendvoice

type SendWidgetParams added in v1.28.0

type SendWidgetParams struct {
	ChatID                any                     `json:"chat_id"`
	MessageThreadID       int                     `json:"message_thread_id,omitempty"`
	HTML                  string                  `json:"html"`
	Width                 int                     `json:"width,omitempty"`
	Height                int                     `json:"height,omitempty"`
	PublicData            string                  `json:"public_data,omitempty"`
	ChatData              string                  `json:"chat_data,omitempty"`
	Caption               string                  `json:"caption,omitempty"`
	ParseMode             models.ParseMode        `json:"parse_mode,omitempty"`
	CaptionEntities       []models.MessageEntity  `json:"caption_entities,omitempty"`
	ShowCaptionAboveMedia bool                    `json:"show_caption_above_media,omitempty"`
	AllowQueries          bool                    `json:"allow_queries,omitempty"`
	IsShared              bool                    `json:"is_shared,omitempty"`
	DisableNotification   bool                    `json:"disable_notification,omitempty"`
	ProtectContent        bool                    `json:"protect_content,omitempty"`
	AllowPaidBroadcast    bool                    `json:"allow_paid_broadcast,omitempty"`
	MessageEffectID       string                  `json:"message_effect_id,omitempty"`
	ReplyParameters       *models.ReplyParameters `json:"reply_parameters,omitempty"`
	ReplyMarkup           models.ReplyMarkup      `json:"reply_markup,omitempty"`
}

SendWidgetParams https://core.telegram.org/bots/api#sendwidget

type SetBusinessAccountBioParams added in v1.15.0

type SetBusinessAccountBioParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	Bio                  string `json:"bio,omitempty"`
}

SetBusinessAccountBioParams https://core.telegram.org/bots/api#setbusinessaccountbio

type SetBusinessAccountGiftSettingsParams added in v1.15.0

type SetBusinessAccountGiftSettingsParams struct {
	BusinessConnectionID string                   `json:"business_connection_id"`
	ShowGiftButton       bool                     `json:"show_gift_button"`
	AcceptedGiftTypes    models.AcceptedGiftTypes `json:"accepted_gift_types"`
}

SetBusinessAccountGiftSettingsParams https://core.telegram.org/bots/api#setbusinessaccountgiftsettings

type SetBusinessAccountNameParams added in v1.15.0

type SetBusinessAccountNameParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	FirstName            string `json:"first_name"`
	LastName             string `json:"last_name,omitempty"`
}

SetBusinessAccountNameParams https://core.telegram.org/bots/api#setbusinessaccountname

type SetBusinessAccountProfilePhotoParams added in v1.15.0

type SetBusinessAccountProfilePhotoParams struct {
	BusinessConnectionID string                   `json:"business_connection_id"`
	Photo                models.InputProfilePhoto `json:"photo"`
	IsPublic             bool                     `json:"is_public,omitempty"`
}

SetBusinessAccountProfilePhotoParams https://core.telegram.org/bots/api#setbusinessaccountprofilephoto

type SetBusinessAccountUsernameParams added in v1.15.0

type SetBusinessAccountUsernameParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	Username             string `json:"username,omitempty"`
}

SetBusinessAccountUsernameParams https://core.telegram.org/bots/api#setbusinessaccountusername

type SetChatAdministratorCustomTitleParams

type SetChatAdministratorCustomTitleParams struct {
	ChatID      any    `json:"chat_id"`
	UserID      int64  `json:"user_id"`
	CustomTitle string `json:"custom_title"`
}

type SetChatDescriptionParams

type SetChatDescriptionParams struct {
	ChatID      any    `json:"chat_id"`
	Description string `json:"description"`
}

type SetChatMemberTagParams added in v1.20.0

type SetChatMemberTagParams struct {
	ChatID any    `json:"chat_id" rules:"required,chat_id"`
	UserID int64  `json:"user_id" rules:"required"`
	Tag    string `json:"tag,omitempty"`
}

SetChatMemberTagParams https://core.telegram.org/bots/api#setchatmembertag

type SetChatMenuButtonParams

type SetChatMenuButtonParams struct {
	ChatID     any                    `json:"chat_id,omitempty"`
	MenuButton models.InputMenuButton `json:"menu_button"`
}

type SetChatPermissionsParams

type SetChatPermissionsParams struct {
	ChatID                        any                    `json:"chat_id"`
	Permissions                   models.ChatPermissions `json:"permissions"`
	UseIndependentChatPermissions bool                   `json:"use_independent_chat_permissions,omitempty"`
}

type SetChatPhotoParams

type SetChatPhotoParams struct {
	ChatID any              `json:"chat_id"`
	Photo  models.InputFile `json:"photo"`
}

type SetChatStickerSetParams

type SetChatStickerSetParams struct {
	ChatID         any    `json:"chat_id"`
	StickerSetName string `json:"sticker_set_name"`
}

type SetChatTitleParams

type SetChatTitleParams struct {
	ChatID any    `json:"chat_id"`
	Title  string `json:"title"`
}

type SetCustomEmojiStickerSetThumbnailParams added in v0.7.0

type SetCustomEmojiStickerSetThumbnailParams struct {
	Name          string `json:"name"`
	CustomEmojiID string `json:"custom_emoji_id,omitempty"`
}

type SetGameScoreParams

type SetGameScoreParams struct {
	UserID             int64 `json:"user_id"`
	Score              int   `json:"score"`
	Force              bool  `json:"force,omitempty"`
	DisableEditMessage bool  `json:"disable_edit_message,omitempty"`
	ChatID             any   `json:"chat_id,omitempty"`
	MessageID          int   `json:"message_id,omitempty"`
	InlineMessageID    int   `json:"inline_message_id,omitempty"`
}

type SetManagedBotAccessSettingsParams added in v1.21.0

type SetManagedBotAccessSettingsParams struct {
	UserID             int64   `json:"user_id"`
	IsAccessRestricted bool    `json:"is_access_restricted"`
	AddedUserIDs       []int64 `json:"added_user_ids,omitempty"`
}

type SetMessageReactionParams added in v1.0.0

type SetMessageReactionParams struct {
	ChatID    any                   `json:"chat_id"`
	MessageID int                   `json:"message_id"`
	Reaction  []models.ReactionType `json:"reaction,omitempty"`
	IsBig     *bool                 `json:"is_big,omitempty"`
}

SetMessageReactionParams https://core.telegram.org/bots/api#setmessagereaction

type SetMyCommandsParams

type SetMyCommandsParams struct {
	Commands     []models.BotCommand    `json:"commands"`
	Scope        models.BotCommandScope `json:"scope,omitempty"`
	LanguageCode string                 `json:"language_code,omitempty"`
}

type SetMyDefaultAdministratorRightsParams

type SetMyDefaultAdministratorRightsParams struct {
	Rights      *models.ChatAdministratorRights `json:"rights,omitempty"`
	ForChannels bool                            `json:"for_channels,omitempty"`
}

type SetMyDescriptionParams added in v0.7.0

type SetMyDescriptionParams struct {
	Description  string `json:"description,omitempty"`
	LanguageCode string `json:"language_code,omitempty"`
}

type SetMyNameParams added in v0.7.6

type SetMyNameParams struct {
	Name         string `json:"name,omitempty"`
	LanguageCode string `json:"language_code,omitempty"`
}

type SetMyProfilePhotoParams added in v1.19.0

type SetMyProfilePhotoParams struct {
	Photo models.InputProfilePhoto `json:"photo"`
}

SetMyProfilePhotoParams https://core.telegram.org/bots/api#setmyprofilephoto

type SetMySettingsParams added in v1.31.0

type SetMySettingsParams struct {
	SupportsInlineQueries          *bool             `json:"supports_inline_queries,omitempty"`
	InlineQueryPlaceholder         *string           `json:"inline_query_placeholder,omitempty"`
	NeedsInlineQueryLocation       *bool             `json:"needs_inline_query_location,omitempty"`
	InlineFeedbackShareDenominator *int              `json:"inline_feedback_share_denominator,omitempty"`
	CanJoinGroups                  *bool             `json:"can_join_groups,omitempty"`
	CanReadAllGroupMessages        *bool             `json:"can_read_all_group_messages,omitempty"`
	CanConnectToBusiness           *bool             `json:"can_connect_to_business,omitempty"`
	CanManageBots                  *bool             `json:"can_manage_bots,omitempty"`
	SupportsGuestQueries           *bool             `json:"supports_guest_queries,omitempty"`
	SupportsJoinRequestQueries     *bool             `json:"supports_join_request_queries,omitempty"`
	HasTopicsEnabled               *bool             `json:"has_topics_enabled,omitempty"`
	AllowsUsersToCreateTopics      *bool             `json:"allows_users_to_create_topics,omitempty"`
	HasTopicSidebar                *bool             `json:"has_topic_sidebar,omitempty"`
	CanCommunicateWithBots         *bool             `json:"can_communicate_with_bots,omitempty"`
	CallbackQueryMode              CallbackQueryMode `json:"callback_query_mode,omitempty"`
}

SetMySettingsParams https://core.telegram.org/bots/api#setmysettings

type SetMyShortDescriptionParams added in v0.7.0

type SetMyShortDescriptionParams struct {
	ShortDescription string `json:"short_description,omitempty"`
	LanguageCode     string `json:"language_code,omitempty"`
}

type SetPassportDataErrorsParams

type SetPassportDataErrorsParams struct {
	UserID int64                         `json:"user_id"`
	Errors []models.PassportElementError `json:"errors"`
}

type SetStickerEmojiListParams added in v0.7.0

type SetStickerEmojiListParams struct {
	Sticker   string   `json:"sticker"`
	EmojiList []string `json:"emoji_list"`
}

type SetStickerKeywordsParams added in v0.7.0

type SetStickerKeywordsParams struct {
	Sticker  string   `json:"sticker"`
	Keywords []string `json:"keywords"`
}

type SetStickerMaskPositionParams added in v0.7.0

type SetStickerMaskPositionParams struct {
	Sticker      string              `json:"sticker"`
	MaskPosition models.MaskPosition `json:"mask_position"`
}

type SetStickerPositionInSetParams

type SetStickerPositionInSetParams struct {
	Sticker  string `json:"sticker"`
	Position int    `json:"position"`
}

type SetStickerSetThumbnailParams added in v0.7.0

type SetStickerSetThumbnailParams struct {
	Name      string           `json:"name"`
	UserID    int64            `json:"user_id"`
	Thumbnail models.InputFile `json:"thumbnail,omitempty"`
	Format    string           `json:"format"`
}

type SetStickerSetTitleParams added in v0.7.0

type SetStickerSetTitleParams struct {
	Name  string `json:"name"`
	Title string `json:"title"`
}

type SetUserEmojiStatusParams added in v1.11.0

type SetUserEmojiStatusParams struct {
	UserID                    int64  `json:"user_id"`
	EmojiStatusCustomEmojiID  string `json:"emoji_status_custom_emoji_id,omitempty"`
	EmojiStatusExpirationDate int    `json:"emoji_status_expiration_date,omitempty"`
}

SetUserEmojiStatusParams https://core.telegram.org/bots/api#setuseremojistatus

type SetWebhookParams

type SetWebhookParams struct {
	URL                string           `json:"url"`
	Certificate        models.InputFile `json:"certificate,omitempty"`
	IPAddress          string           `json:"ip_address,omitempty"`
	MaxConnections     int              `json:"max_connections,omitempty"`
	AllowedUpdates     []string         `json:"allowed_updates,omitempty"`
	DropPendingUpdates bool             `json:"drop_pending_updates,omitempty"`
	SecretToken        string           `json:"secret_token,omitempty"`
}

type StopMessageLiveLocationParams

type StopMessageLiveLocationParams struct {
	BusinessConnectionID string             `json:"business_connection_id,omitempty"`
	ChatID               any                `json:"chat_id,omitempty"`
	MessageID            int                `json:"message_id,omitempty"`
	InlineMessageID      string             `json:"inline_message_id,omitempty"`
	ReplyMarkup          models.ReplyMarkup `json:"reply_markup,omitempty"`
}

type StopPollParams

type StopPollParams struct {
	BusinessConnectionID string             `json:"business_connection_id,omitempty"`
	ChatID               any                `json:"chat_id"`
	MessageID            int                `json:"message_id"`
	ReplyMarkup          models.ReplyMarkup `json:"reply_markup,omitempty"`
}

type TooManyRequestsError added in v1.2.1

type TooManyRequestsError struct {
	Message    string
	RetryAfter int
}

func (*TooManyRequestsError) Error added in v1.2.1

func (e *TooManyRequestsError) Error() string

type TransferBusinessAccountStarsParams added in v1.15.0

type TransferBusinessAccountStarsParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	StarCount            int    `json:"star_count"`
}

TransferBusinessAccountStarsParams https://core.telegram.org/bots/api#transferbusinessaccountstars

type TransferGiftParams added in v1.15.0

type TransferGiftParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	OwnedGiftID          string `json:"owned_gift_id"`
	NewOwnerChatID       int64  `json:"new_owner_chat_id"`
	StarCount            int    `json:"star_count"`
}

TransferGiftParams https://core.telegram.org/bots/api#transfergift

type UnbanChatMemberParams

type UnbanChatMemberParams struct {
	ChatID       any   `json:"chat_id"`
	UserID       int64 `json:"user_id"`
	OnlyIfBanned bool  `json:"only_if_banned,omitempty"`
}

type UnbanChatSenderChatParams

type UnbanChatSenderChatParams struct {
	ChatID       any   `json:"chat_id"`
	SenderChatID int64 `json:"sender_chat_id"`
}

type UnhideGeneralForumTopicParams added in v0.3.4

type UnhideGeneralForumTopicParams struct {
	ChatID any `json:"chat_id"`
}

type UnpinAllChatMessagesParams

type UnpinAllChatMessagesParams struct {
	ChatID any `json:"chat_id"`
}

type UnpinAllForumTopicMessagesParams added in v0.3.1

type UnpinAllForumTopicMessagesParams struct {
	ChatID          any `json:"chat_id"`
	MessageThreadID int `json:"message_thread_id"`
}

type UnpinAllGeneralForumTopicMessagesParams added in v0.7.15

type UnpinAllGeneralForumTopicMessagesParams struct {
	ChatID any `json:"chat_id"`
}

type UnpinChatMessageParams

type UnpinChatMessageParams struct {
	ChatID    any `json:"chat_id"`
	MessageID int `json:"message_id,omitempty"`
}

type UpgradeGiftParams added in v1.15.0

type UpgradeGiftParams struct {
	BusinessConnectionID string `json:"business_connection_id"`
	OwnedGiftID          string `json:"owned_gift_id"`
	KeepOriginalDetails  bool   `json:"keep_original_details,omitempty"`
	StarCount            int    `json:"star_count,omitempty"`
}

UpgradeGiftParams https://core.telegram.org/bots/api#upgradegift

type UploadStickerFileParams

type UploadStickerFileParams struct {
	UserID        int64            `json:"user_id"`
	Sticker       models.InputFile `json:"sticker"`
	StickerFormat string           `json:"sticker_format"`
}

type VerifyChatParams added in v1.13.0

type VerifyChatParams struct {
	ChatID                     any                    `json:"chat_id"`
	CustomDescription          string                 `json:"custom_description,omitempty"`
	CustomDescriptionParseMode models.ParseMode       `json:"custom_description_parse_mode,omitempty"`
	CustomDescriptionEntities  []models.MessageEntity `json:"custom_description_entities,omitempty"`
}

VerifyChatParams https://core.telegram.org/bots/api#verifychat

type VerifyUserParams added in v1.13.0

type VerifyUserParams struct {
	UserID                     int64                  `json:"user_id"`
	CustomDescription          string                 `json:"custom_description,omitempty"`
	CustomDescriptionParseMode models.ParseMode       `json:"custom_description_parse_mode,omitempty"`
	CustomDescriptionEntities  []models.MessageEntity `json:"custom_description_entities,omitempty"`
}

VerifyUserParams https://core.telegram.org/bots/api#verifyuser

type WebAppChat added in v1.31.0

type WebAppChat struct {
	ID       int64           `json:"id"`
	Type     models.ChatType `json:"type"`
	Title    string          `json:"title"`
	Username string          `json:"username,omitempty"`
	PhotoURL string          `json:"photo_url,omitempty"`
}

WebAppChat https://core.telegram.org/bots/webapps#webappchat

type WebAppInitData added in v1.31.0

type WebAppInitData struct {
	QueryID                string      `json:"query_id,omitempty"`
	ChatJoinRequestQueryID string      `json:"chat_join_request_query_id,omitempty"`
	User                   *WebAppUser `json:"user,omitempty"`
	Receiver               *WebAppUser `json:"receiver,omitempty"`
	Chat                   *WebAppChat `json:"chat,omitempty"`
	ChatType               string      `json:"chat_type,omitempty"`
	ChatInstance           string      `json:"chat_instance,omitempty"`
	StartParam             string      `json:"start_param,omitempty"`
	CanSendAfter           int         `json:"can_send_after,omitempty"` // seconds
	AuthDate               int         `json:"auth_date"`
	Hash                   string      `json:"hash"`
	Signature              string      `json:"signature"`
}

WebAppInitData https://core.telegram.org/bots/webapps#webappinitdata

User, Receiver and Chat are nil when the field is absent or null.

func ValidateWebAppInitData added in v1.31.0

func ValidateWebAppInitData(initData, token string) (*WebAppInitData, error)

ValidateWebAppInitData parses Mini App init data and checks its hash with the bot token.

Pass raw Telegram.WebApp.initData without a leading "?" or "#tgWebAppData=". Unknown fields are included in the check but not returned. Decoded field names containing '=' or LF, or values containing LF, are malformed.

An empty token returns a configuration error before parsing initData. On failure it returns nil data. Use errors.Is for ErrorWebAppInitDataMalformed, ErrorWebAppInitDataUnsigned and ErrorWebAppInitDataInvalid.

func ValidateWebAppInitDataSignature added in v1.31.0

func ValidateWebAppInitDataSignature(initData string, botID int64, publicKey ed25519.PublicKey) (*WebAppInitData, error)

ValidateWebAppInitDataSignature verifies Mini App init data with Telegram's Ed25519 public key. Decode WebAppPublicKeyHex or WebAppTestPublicKeyHex with hex.DecodeString.

Signatures use canonical base64url, with or without padding. The returned Hash is unauthenticated.

An invalid public key length or nonpositive bot ID returns a configuration error before parsing. See ValidateWebAppInitData for the input format and data errors. On failure it returns nil data.

func (*WebAppInitData) CheckAuthDate added in v1.31.0

func (d *WebAppInitData) CheckAuthDate(maxAge time.Duration) error

CheckAuthDate returns ErrorWebAppInitDataExpired if the data is older than maxAge or if maxAge is not positive. With a positive maxAge, future timestamps pass.

type WebAppUser added in v1.13.0

type WebAppUser struct {
	ID                    int64  `json:"id"`
	IsBot                 bool   `json:"is_bot"`
	FirstName             string `json:"first_name"`
	LastName              string `json:"last_name"`
	Username              string `json:"username"`
	LanguageCode          string `json:"language_code"`
	IsPremium             bool   `json:"is_premium"`
	AddedToAttachmentMenu bool   `json:"added_to_attachment_menu"`
	AllowsWriteToPM       bool   `json:"allows_write_to_pm"`
	PhotoURL              string `json:"photo_url"`
}

WebAppUser represents user model from webapp request

func ValidateWebappRequest added in v1.6.1

func ValidateWebappRequest(values url.Values, token string) (user *WebAppUser, ok bool)

ValidateWebappRequest validates Mini App init data. values must already be decoded, as returned by url.ParseQuery or http.Request.URL.Query. It uses the first value per key and leaves values unchanged. An empty token, LF in signed names or values, or '=' in signed names returns nil, false.

Directories

Path Synopsis
examples
command_handler command
commands command
echo command
edit_message command
getme command
inline_keyboard command
inline_mode command
middleware command
payment command
send_document command
send_paid_media command
send_photo command
send_video command
streaming_draft command

Jump to

Keyboard shortcuts

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