Documentation
¶
Overview ¶
Package botapi is a Telegram Bot API library implemented over MTProto using github.com/gotd/td.
Unlike HTTP Bot API clients, botapi does not talk to api.telegram.org. It exposes the familiar Bot API surface (types, methods, updates) but speaks MTProto directly. That avoids the public Bot API server's rate limits, keeps updates flowing over one persistent connection, and gives access to the raw gotd client when the Bot API surface does not cover something (Bot.Raw).
Construction ¶
New builds an unconnected bot from a BotFather token and an MTProto app identity (AppID/AppHash from https://my.telegram.org — these are not the bot token). Run connects, authorizes as a bot and serves updates until the context is canceled:
bot, err := botapi.New(token, botapi.Options{AppID: id, AppHash: hash})
if err != nil {
return err
}
bot.OnCommand("start", "Start the bot", func(c *botapi.Context) error {
_, err := c.Reply("hello")
return err
})
return bot.Run(ctx)
Sending ¶
Outgoing methods hang off *Bot, take a context first and a ChatID target, and share functional SendOptions (ReplyTo, Silent, WithReplyMarkup, WithParseMode, ...). A ChatID is constructed with ID (numeric) or Username:
bot.SendMessage(ctx, botapi.ID(chatID), "*hi*", botapi.WithParseMode(botapi.ParseModeMarkdownV2))
bot.SendPhoto(ctx, botapi.Username("@channel"), botapi.FileURL("https://.../x.jpg"), "caption")
Receiving ¶
Updates are dispatched through a small handler framework. Register handlers with the On* helpers (OnMessage, OnCommand, OnCallbackQuery, OnInlineQuery, ...), narrow them with Predicates (Command, HasText, Regex, CallbackPrefix, And/Or/Not, ...), and group shared middleware with Group/Use. Each handler receives a *Context with helpers (Message, Sender, Reply, Send, AnswerCallback, AnswerInline).
Errors ¶
Methods return errors shaped like the HTTP Bot API: an *Error with a Code and Description (see errors_map.go). Extract it with errors.As, or use the helpers Code, AsFloodWait and AsChatMigrated. Context cancellation passes through unchanged so callers can errors.Is on ctx.Err().
Sealed unions ¶
Where the Bot API uses "one of" objects (ChatID, InputFile, ReplyMarkup, InputMedia, ChatMember, InlineQueryResult, InputMessageContent, ...) this package uses sealed interfaces: an interface with an unexported marker method and a fixed set of concrete implementations, so an illegal state is unrepresentable and switches over them are checked for exhaustiveness.
See docs/roadmap.md for the implementation status.
Index ¶
- Variables
- func AsChatMigrated(err error) (newChatID int64, ok bool)
- func AsFloodWait(err error) (retryAfter time.Duration, ok bool)
- func Code(err error) int
- type Animation
- type AnswerCallbackQueryOption
- type AnswerInlineQueryOption
- type Audio
- type BanChatMemberOption
- type Bot
- func (b *Bot) AddStickerToSet(ctx context.Context, name string, sticker InputSticker) error
- func (b *Bot) AnswerCallbackQuery(ctx context.Context, callbackQueryID string, opts ...AnswerCallbackQueryOption) error
- func (b *Bot) AnswerInlineQuery(ctx context.Context, inlineQueryID string, results []InlineQueryResult, ...) error
- func (b *Bot) AnswerPreCheckoutQuery(ctx context.Context, preCheckoutQueryID string, ok bool, ...) error
- func (b *Bot) AnswerShippingQuery(ctx context.Context, shippingQueryID string, ok bool, ...) error
- func (b *Bot) Background() context.Context
- func (b *Bot) BanChatMember(ctx context.Context, chat ChatID, userID int64, opts ...BanChatMemberOption) error
- func (b *Bot) CopyMessage(ctx context.Context, to, from ChatID, messageID int, opts ...SendOption) (*Message, error)
- func (b *Bot) CreateChatInviteLink(ctx context.Context, chat ChatID, opts ...InviteLinkOption) (*ChatInviteLink, error)
- func (b *Bot) CreateNewStickerSet(ctx context.Context, userID int64, name, title string, stickers []InputSticker, ...) error
- func (b *Bot) DeleteChatPhoto(ctx context.Context, chat ChatID) error
- func (b *Bot) DeleteChatStickerSet(ctx context.Context, chat ChatID) error
- func (b *Bot) DeleteMessage(ctx context.Context, chat ChatID, messageID int) error
- func (b *Bot) DeleteMessages(ctx context.Context, chat ChatID, messageIDs []int) error
- func (b *Bot) DeleteMyCommands(ctx context.Context, opts ...CommandOption) error
- func (b *Bot) DeleteStickerFromSet(ctx context.Context, sticker string) error
- func (b *Bot) Dispatcher() *tg.UpdateDispatcher
- func (b *Bot) DownloadFile(ctx context.Context, fileID string, w io.Writer) (int64, error)
- func (b *Bot) DownloadFileToPath(ctx context.Context, fileID, path string) error
- func (b *Bot) EditChatInviteLink(ctx context.Context, chat ChatID, inviteLink string, opts ...InviteLinkOption) (*ChatInviteLink, error)
- func (b *Bot) EditMessageCaption(ctx context.Context, chat ChatID, messageID int, caption string, ...) (*Message, error)
- func (b *Bot) EditMessageLiveLocation(ctx context.Context, chat ChatID, messageID int, latitude, longitude float64, ...) (*Message, error)
- func (b *Bot) EditMessageMedia(ctx context.Context, chat ChatID, messageID int, media InputMedia, ...) (*Message, error)
- func (b *Bot) EditMessageReplyMarkup(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Message, error)
- func (b *Bot) EditMessageText(ctx context.Context, chat ChatID, messageID int, text string, ...) (*Message, error)
- func (b *Bot) ExportChatInviteLink(ctx context.Context, chat ChatID) (string, error)
- func (b *Bot) ForwardMessage(ctx context.Context, to, from ChatID, messageID int, opts ...SendOption) (*Message, error)
- func (b *Bot) GetChat(ctx context.Context, chat ChatID) (*Chat, error)
- func (b *Bot) GetChatAdministrators(ctx context.Context, chat ChatID) ([]ChatMember, error)
- func (b *Bot) GetChatMember(ctx context.Context, chat ChatID, userID int64) (ChatMember, error)
- func (b *Bot) GetChatMemberCount(ctx context.Context, chat ChatID) (int, error)
- func (b *Bot) GetFile(_ context.Context, fileID string) (*File, error)
- func (b *Bot) GetGameHighScores(ctx context.Context, chat ChatID, messageID int, userID int64) ([]GameHighScore, error)
- func (b *Bot) GetMyCommands(ctx context.Context, opts ...CommandOption) ([]BotCommand, error)
- func (b *Bot) GetStickerSet(ctx context.Context, name string) (*StickerSet, error)
- func (b *Bot) GetUserProfilePhotos(ctx context.Context, userID int64, opts ...GetUserProfilePhotosOption) (*UserProfilePhotos, error)
- func (b *Bot) Group(predicates ...Predicate) *Group
- func (b *Bot) LeaveChat(ctx context.Context, chat ChatID) error
- func (b *Bot) Logger() log.Logger
- func (b *Bot) OnCallbackQuery(h Handler, predicates ...Predicate)
- func (b *Bot) OnChannelPost(h Handler, predicates ...Predicate)
- func (b *Bot) OnCommand(name, description string, h Handler, predicates ...Predicate)
- func (b *Bot) OnEditedMessage(h Handler, predicates ...Predicate)
- func (b *Bot) OnInlineQuery(h Handler, predicates ...Predicate)
- func (b *Bot) OnMessage(h Handler, predicates ...Predicate)
- func (b *Bot) OnPreCheckoutQuery(h Handler, predicates ...Predicate)
- func (b *Bot) OnShippingQuery(h Handler, predicates ...Predicate)
- func (b *Bot) PeerRef(ctx context.Context, chat ChatID) (PeerRef, error)
- func (b *Bot) Peers() *peers.Manager
- func (b *Bot) PinChatMessage(ctx context.Context, chat ChatID, messageID int, opts ...SendOption) error
- func (b *Bot) PromoteChatMember(ctx context.Context, chat ChatID, userID int64, rights ChatAdminRights) error
- func (b *Bot) Raw() *tg.Client
- func (b *Bot) RestrictChatMember(ctx context.Context, chat ChatID, userID int64, permissions ChatPermissions, ...) error
- func (b *Bot) RevokeChatInviteLink(ctx context.Context, chat ChatID, inviteLink string) (*ChatInviteLink, error)
- func (b *Bot) Run(ctx context.Context) error
- func (b *Bot) Self() *tg.User
- func (b *Bot) SendAnimation(ctx context.Context, chat ChatID, animation InputFile, caption string, ...) (*Message, error)
- func (b *Bot) SendAudio(ctx context.Context, chat ChatID, audio InputFile, caption string, ...) (*Message, error)
- func (b *Bot) SendChatAction(ctx context.Context, chat ChatID, action ChatAction) error
- func (b *Bot) SendContact(ctx context.Context, chat ChatID, phoneNumber, firstName, lastName string, ...) (*Message, error)
- func (b *Bot) SendDice(ctx context.Context, chat ChatID, emoji DiceEmoji, opts ...SendOption) (*Message, error)
- func (b *Bot) SendDocument(ctx context.Context, chat ChatID, document InputFile, caption string, ...) (*Message, error)
- func (b *Bot) SendGame(ctx context.Context, chat ChatID, gameShortName string, opts ...SendOption) (*Message, error)
- func (b *Bot) SendInvoice(ctx context.Context, chat ChatID, params InvoiceParams, opts ...SendOption) (*Message, error)
- func (b *Bot) SendLocation(ctx context.Context, chat ChatID, latitude, longitude float64, ...) (*Message, error)
- func (b *Bot) SendMediaGroup(ctx context.Context, chat ChatID, media []InputMedia, opts ...SendOption) ([]*Message, error)
- func (b *Bot) SendMessage(ctx context.Context, chat ChatID, text string, opts ...SendOption) (*Message, error)
- func (b *Bot) SendPhoto(ctx context.Context, chat ChatID, photo InputFile, caption string, ...) (*Message, error)
- func (b *Bot) SendPoll(ctx context.Context, chat ChatID, question string, options []string, ...) (*Message, error)
- func (b *Bot) SendRichHTML(ctx context.Context, chat ChatID, html string, opts ...SendOption) (*Message, error)
- func (b *Bot) SendRichMarkdown(ctx context.Context, chat ChatID, markdown string, opts ...SendOption) (*Message, error)
- func (b *Bot) SendRichMessage(ctx context.Context, chat ChatID, msg tg.InputRichMessageClass, ...) (*Message, error)
- func (b *Bot) SendSticker(ctx context.Context, chat ChatID, sticker InputFile, opts ...SendOption) (*Message, error)
- func (b *Bot) SendVenue(ctx context.Context, chat ChatID, latitude, longitude float64, ...) (*Message, error)
- func (b *Bot) SendVideo(ctx context.Context, chat ChatID, video InputFile, caption string, ...) (*Message, error)
- func (b *Bot) SendVideoNote(ctx context.Context, chat ChatID, videoNote InputFile, opts ...SendOption) (*Message, error)
- func (b *Bot) SendVoice(ctx context.Context, chat ChatID, voice InputFile, caption string, ...) (*Message, error)
- func (b *Bot) Sender() *message.Sender
- func (b *Bot) SetChatAdministratorCustomTitle(ctx context.Context, chat ChatID, userID int64, customTitle string) error
- func (b *Bot) SetChatDescription(ctx context.Context, chat ChatID, description string) error
- func (b *Bot) SetChatPermissions(ctx context.Context, chat ChatID, permissions ChatPermissions) error
- func (b *Bot) SetChatPhoto(ctx context.Context, chat ChatID, photo InputFile) error
- func (b *Bot) SetChatStickerSet(ctx context.Context, chat ChatID, stickerSetName string) error
- func (b *Bot) SetChatTitle(ctx context.Context, chat ChatID, title string) error
- func (b *Bot) SetGameScore(ctx context.Context, chat ChatID, messageID int, userID int64, score int, ...) (*Message, error)
- func (b *Bot) SetMyCommands(ctx context.Context, commands []BotCommand, opts ...CommandOption) error
- func (b *Bot) SetPassportDataErrors(ctx context.Context, userID int64, errs []PassportElementError) error
- func (b *Bot) SetStickerPositionInSet(ctx context.Context, sticker string, position int) error
- func (b *Bot) SetStickerSetThumb(ctx context.Context, name string, thumb InputFile) error
- func (b *Bot) StopMessageLiveLocation(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Message, error)
- func (b *Bot) StopPoll(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Poll, error)
- func (b *Bot) UnbanChatMember(ctx context.Context, chat ChatID, userID int64) error
- func (b *Bot) UnpinAllChatMessages(ctx context.Context, chat ChatID) error
- func (b *Bot) UnpinChatMessage(ctx context.Context, chat ChatID, messageID int) error
- func (b *Bot) UploadStickerFile(ctx context.Context, userID int64, sticker InputFile, format StickerFormat) (*File, error)
- func (b *Bot) Use(mws ...Middleware)
- type BotCommand
- type BotCommandScope
- func BotCommandScopeAllChatAdministrators() BotCommandScope
- func BotCommandScopeAllGroupChats() BotCommandScope
- func BotCommandScopeAllPrivateChats() BotCommandScope
- func BotCommandScopeChat(chat ChatID) BotCommandScope
- func BotCommandScopeChatAdministrators(chat ChatID) BotCommandScope
- func BotCommandScopeChatMember(chat ChatID, userID int64) BotCommandScope
- func BotCommandScopeDefault() BotCommandScope
- type CallbackQuery
- type Chat
- type ChatAction
- type ChatAdminRights
- type ChatID
- type ChatIDInt
- type ChatIDUsername
- type ChatInviteLink
- type ChatMember
- type ChatMemberAdministrator
- type ChatMemberBanned
- type ChatMemberLeft
- type ChatMemberMember
- type ChatMemberOwner
- type ChatMemberRestricted
- type ChatMemberStatus
- type ChatMemberUpdated
- type ChatPermissions
- type ChatType
- type ChosenInlineResult
- type CommandOption
- type Contact
- type Context
- func (c *Context) AnswerCallback(opts ...AnswerCallbackQueryOption) error
- func (c *Context) AnswerInline(results []InlineQueryResult, opts ...AnswerInlineQueryOption) error
- func (c *Context) Background() context.Context
- func (c *Context) Chat() (ChatID, bool)
- func (c *Context) Message() *Message
- func (c *Context) Reply(text string, opts ...SendOption) (*Message, error)
- func (c *Context) Send(text string, opts ...SendOption) (*Message, error)
- func (c *Context) Sender() *User
- type Dice
- type DiceEmoji
- type Document
- type Error
- type File
- type ForceReply
- type Game
- type GameHighScore
- type GetUserProfilePhotosOption
- type Group
- func (g *Group) Handle(h Handler, predicates ...Predicate)
- func (g *Group) OnCallbackQuery(h Handler, predicates ...Predicate)
- func (g *Group) OnCommand(name, description string, h Handler, predicates ...Predicate)
- func (g *Group) OnMessage(h Handler, predicates ...Predicate)
- func (g *Group) Use(mws ...Middleware) *Group
- type Handler
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InlineQuery
- type InlineQueryResult
- type InlineQueryResultArticle
- type InlineQueryResultCachedAudio
- type InlineQueryResultCachedDocument
- type InlineQueryResultCachedGif
- type InlineQueryResultCachedPhoto
- type InlineQueryResultCachedSticker
- type InlineQueryResultCachedVideo
- type InlineQueryResultCachedVoice
- type InlineQueryResultContact
- type InlineQueryResultGif
- type InlineQueryResultLocation
- type InlineQueryResultMpeg4Gif
- type InlineQueryResultPhoto
- type InlineQueryResultVenue
- type InputContactMessageContent
- type InputFile
- type InputFileID
- type InputFileURL
- type InputFileUpload
- type InputLocationMessageContent
- type InputMedia
- type InputMediaAnimation
- type InputMediaAudio
- type InputMediaDocument
- type InputMediaPhoto
- type InputMediaType
- type InputMediaVideo
- type InputMessageContent
- type InputSticker
- type InputTextMessageContent
- type InputVenueMessageContent
- type InviteLinkOption
- type InvoiceParams
- type KeyboardButton
- type KeyboardButtonPollType
- type LabeledPrice
- type LiveLocationOption
- type Location
- type MenuButton
- type MenuButtonCommands
- type MenuButtonDefault
- type MenuButtonType
- type MenuButtonWebApp
- type Message
- type MessageEntity
- type MessageEntityType
- type MessageOrigin
- type MessageOriginChannel
- type MessageOriginChat
- type MessageOriginHiddenUser
- type MessageOriginType
- type MessageOriginUser
- type Middleware
- type Options
- type OrderInfo
- type ParseMode
- type PassportElementError
- type PassportElementErrorDataField
- type PassportElementErrorFile
- type PassportElementErrorFiles
- type PassportElementErrorFrontSide
- type PassportElementErrorReverseSide
- type PassportElementErrorSelfie
- type PassportElementErrorTranslationFile
- type PassportElementErrorTranslationFiles
- type PassportElementErrorUnspecified
- type PeerRef
- type PhotoSize
- type Poll
- type PollAnswer
- type PollOption
- type PollType
- type PreCheckoutAnswerOption
- type PreCheckoutQuery
- type Predicate
- func CallbackData(s string) Predicate
- func CallbackPrefix(prefix string) Predicate
- func ChatTypeIs(t ChatType) Predicate
- func Command(name string) Predicate
- func HasPrefix(prefix string) Predicate
- func HasText() Predicate
- func Not(p Predicate) Predicate
- func Or(predicates ...Predicate) Predicate
- func Regex(pattern string) Predicate
- func TextEquals(s string) Predicate
- type ReactionType
- type ReactionTypeCustomEmoji
- type ReactionTypeEmoji
- type ReactionTypeKind
- type ReactionTypePaid
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type ReplyMarkup
- type ResponseParameters
- type SendOption
- type SetGameScoreOption
- type ShippingAddress
- type ShippingAnswerOption
- type ShippingOption
- type ShippingQuery
- type Sticker
- type StickerFormat
- type StickerSet
- type StickerSetOption
- type StickerType
- type Storage
- type Update
- type User
- type UserProfilePhotos
- type Venue
- type Video
- type VideoNote
- type Voice
- type WebAppInfo
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("botapi: not implemented")
ErrNotImplemented is returned by methods whose translation is not yet wired.
Functions ¶
func AsChatMigrated ¶
AsChatMigrated reports whether err indicates that a basic group was upgraded to a supergroup and, if so, the new supergroup chat id the caller should use.
func AsFloodWait ¶
AsFloodWait reports whether err (or anything it wraps) is a flood-wait error and, if so, how long the caller should wait before retrying.
It understands both this package's *Error (via Parameters.RetryAfter) and the underlying github.com/gotd/td/tgerr flood-wait representation.
Types ¶
type Animation ¶
type Animation struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Animation represents an animation file (GIF or H.264/MPEG-4 AVC without sound).
func (Animation) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Animation) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type AnswerCallbackQueryOption ¶
type AnswerCallbackQueryOption func(*answerCallbackConfig)
AnswerCallbackQueryOption configures an AnswerCallbackQuery call.
func WithCallbackAlert ¶
func WithCallbackAlert() AnswerCallbackQueryOption
WithCallbackAlert shows the notification as an alert dialog instead of a top-of-screen toast.
func WithCallbackCacheTime ¶
func WithCallbackCacheTime(seconds int) AnswerCallbackQueryOption
WithCallbackCacheTime sets, in seconds, how long the result may be cached client-side.
func WithCallbackText ¶
func WithCallbackText(text string) AnswerCallbackQueryOption
WithCallbackText sets the notification text shown to the user (0-200 characters). By default nothing is shown.
func WithCallbackURL ¶
func WithCallbackURL(url string) AnswerCallbackQueryOption
WithCallbackURL sets a URL to open. Telegram restricts which URLs are accepted (game URLs, or t.me/your_bot?start= links).
type AnswerInlineQueryOption ¶
type AnswerInlineQueryOption func(*answerInlineConfig)
AnswerInlineQueryOption configures an AnswerInlineQuery call.
func WithInlineCacheTime ¶
func WithInlineCacheTime(seconds int) AnswerInlineQueryOption
WithInlineCacheTime sets the maximum time, in seconds, the result may be cached on the server.
func WithInlineNextOffset ¶
func WithInlineNextOffset(offset string) AnswerInlineQueryOption
WithInlineNextOffset sets the offset a client returns to request the next page of results. An empty offset (the default) means no more results.
func WithInlinePersonal ¶
func WithInlinePersonal() AnswerInlineQueryOption
WithInlinePersonal marks the results as personal so they are not cached for other users querying the same thing.
func WithInlineSwitchPM ¶
func WithInlineSwitchPM(text, startParam string) AnswerInlineQueryOption
WithInlineSwitchPM shows a button above the results that switches the user to a private chat with the bot, passing startParam as the /start parameter.
type Audio ¶
type Audio struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
FileName string `json:"file_name,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
}
Audio represents an audio file to be treated as music.
func (Audio) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Audio) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type BanChatMemberOption ¶
type BanChatMemberOption func(*banConfig)
BanChatMemberOption configures a BanChatMember call.
func WithBanUntil ¶
func WithBanUntil(untilDate int) BanChatMemberOption
WithBanUntil sets the Unix time when the user will be unbanned (0 or far in the future means forever).
func WithRevokeMessages ¶
func WithRevokeMessages() BanChatMemberOption
WithRevokeMessages deletes all messages from the user being banned.
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is a Telegram Bot API client implemented over MTProto.
Construct it with New, register update handlers on its Dispatcher, then call Run to connect and serve. Bot is safe for concurrent use once running.
func New ¶
New constructs an unconnected Bot from a BotFather token. It performs no network I/O; call Run to connect, authorize and serve updates.
func (*Bot) AddStickerToSet ¶
AddStickerToSet adds a sticker to a set created by the bot.
func (*Bot) AnswerCallbackQuery ¶
func (b *Bot) AnswerCallbackQuery(ctx context.Context, callbackQueryID string, opts ...AnswerCallbackQueryOption) error
AnswerCallbackQuery responds to a callback query sent from an inline keyboard. The callbackQueryID is the CallbackQuery.ID from the update.
func (*Bot) AnswerInlineQuery ¶
func (b *Bot) AnswerInlineQuery( ctx context.Context, inlineQueryID string, results []InlineQueryResult, opts ...AnswerInlineQueryOption, ) error
AnswerInlineQuery sends the results of an inline query. inlineQueryID is the InlineQuery.ID from the update.
func (*Bot) AnswerPreCheckoutQuery ¶
func (b *Bot) AnswerPreCheckoutQuery(ctx context.Context, preCheckoutQueryID string, ok bool, opts ...PreCheckoutAnswerOption) error
AnswerPreCheckoutQuery replies to a pre-checkout query. When ok is false, provide a human-readable reason via WithPreCheckoutError.
func (*Bot) AnswerShippingQuery ¶
func (b *Bot) AnswerShippingQuery(ctx context.Context, shippingQueryID string, ok bool, opts ...ShippingAnswerOption) error
AnswerShippingQuery replies to a shipping query. When ok is true, provide the available shipping options; otherwise pass an error message via WithShippingError describing why the order can't be shipped.
func (*Bot) Background ¶ added in v0.2.0
Background returns a context tied to the bot's run lifetime, for proactive or background sends that are not in response to an update — e.g. from a timer, queue or goroutine. It is canceled when the bot stops.
A handler's own context is per-update (and may carry a Timeout deadline), so it must not be used for work that outlives the handler. Use Background instead:
bot.OnCommand("remind", "Remind in a minute", func(c *botapi.Context) error {
chat, _ := c.Chat()
ctx := c.Bot.Background()
go func() {
time.Sleep(time.Minute)
c.Bot.SendMessage(ctx, chat, "⏰ reminder")
}()
return nil
})
Before Run has connected (or after it has stopped) Background returns an already-canceled context, so background sends fail fast rather than block.
func (*Bot) BanChatMember ¶
func (b *Bot) BanChatMember(ctx context.Context, chat ChatID, userID int64, opts ...BanChatMemberOption) error
BanChatMember bans a user from a supergroup or channel. The bot must be an administrator with the can_restrict_members right.
func (*Bot) CopyMessage ¶
func (b *Bot) CopyMessage(ctx context.Context, to, from ChatID, messageID int, opts ...SendOption) (*Message, error)
CopyMessage copies a message: it re-sends the message's content to another chat as a new message, without the "forwarded from" header. Unlike ForwardMessage, the result is not linked to the original.
func (*Bot) CreateChatInviteLink ¶
func (b *Bot) CreateChatInviteLink(ctx context.Context, chat ChatID, opts ...InviteLinkOption) (*ChatInviteLink, error)
CreateChatInviteLink creates an additional invite link for a chat.
func (*Bot) CreateNewStickerSet ¶
func (b *Bot) CreateNewStickerSet( ctx context.Context, userID int64, name, title string, stickers []InputSticker, opts ...StickerSetOption, ) error
CreateNewStickerSet creates a new sticker set owned by the given user. name is the set short name (used in t.me/addstickers/<name>).
func (*Bot) DeleteChatPhoto ¶
DeleteChatPhoto removes the profile photo of a chat.
func (*Bot) DeleteChatStickerSet ¶
DeleteChatStickerSet removes the group sticker set from a supergroup.
func (*Bot) DeleteMessage ¶
DeleteMessage deletes a message for everyone in the chat.
func (*Bot) DeleteMessages ¶
DeleteMessages deletes several messages for everyone in the chat.
func (*Bot) DeleteMyCommands ¶
func (b *Bot) DeleteMyCommands(ctx context.Context, opts ...CommandOption) error
DeleteMyCommands clears the list of the bot's commands for the given scope and language, restoring the default commands.
func (*Bot) DeleteStickerFromSet ¶
DeleteStickerFromSet removes a sticker, referenced by file_id, from the set it belongs to.
func (*Bot) Dispatcher ¶
func (b *Bot) Dispatcher() *tg.UpdateDispatcher
Dispatcher returns the update dispatcher for registering raw MTProto update handlers. The typed Bot API handler framework is built on top of this and will be added in a later phase.
func (*Bot) DownloadFile ¶
DownloadFile streams the file referenced by file_id into w. It follows DC migration transparently. The number of bytes written is returned.
func (*Bot) DownloadFileToPath ¶
DownloadFileToPath downloads the file referenced by file_id to a local path.
func (*Bot) EditChatInviteLink ¶
func (b *Bot) EditChatInviteLink(ctx context.Context, chat ChatID, inviteLink string, opts ...InviteLinkOption) (*ChatInviteLink, error)
EditChatInviteLink edits a non-primary invite link created by the bot.
func (*Bot) EditMessageCaption ¶
func (b *Bot) EditMessageCaption(ctx context.Context, chat ChatID, messageID int, caption string, opts ...SendOption) (*Message, error)
EditMessageCaption edits the caption of a media message and returns the edited message.
func (*Bot) EditMessageLiveLocation ¶
func (b *Bot) EditMessageLiveLocation( ctx context.Context, chat ChatID, messageID int, latitude, longitude float64, opts ...LiveLocationOption, ) (*Message, error)
EditMessageLiveLocation edits a live location message, moving the point to the given coordinates.
func (*Bot) EditMessageMedia ¶
func (b *Bot) EditMessageMedia(ctx context.Context, chat ChatID, messageID int, media InputMedia, opts ...SendOption) (*Message, error)
EditMessageMedia replaces the media (and caption) of a message. The new media may reference an existing file_id, an HTTP URL Telegram fetches, or a local upload.
func (*Bot) EditMessageReplyMarkup ¶
func (b *Bot) EditMessageReplyMarkup(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Message, error)
EditMessageReplyMarkup edits only the reply markup of a message, leaving its text and media unchanged. A nil markup removes the keyboard.
func (*Bot) EditMessageText ¶
func (b *Bot) EditMessageText(ctx context.Context, chat ChatID, messageID int, text string, opts ...SendOption) (*Message, error)
EditMessageText edits the text of a message and returns the edited message.
func (*Bot) ExportChatInviteLink ¶
ExportChatInviteLink generates a new primary invite link for a chat, revoking any previous one, and returns it.
func (*Bot) ForwardMessage ¶
func (b *Bot) ForwardMessage(ctx context.Context, to, from ChatID, messageID int, opts ...SendOption) (*Message, error)
ForwardMessage forwards a single message from one chat to another and returns the forwarded message. Silent and ProtectContent options apply.
func (*Bot) GetChatAdministrators ¶
GetChatAdministrators returns the administrators of a supergroup or channel, excluding other bots.
func (*Bot) GetChatMember ¶
GetChatMember returns information about a member of a supergroup or channel.
func (*Bot) GetChatMemberCount ¶
GetChatMemberCount returns the number of members in a supergroup or channel.
func (*Bot) GetFile ¶
GetFile decodes a file_id and returns a File describing it.
Unlike the HTTP Bot API, this library is MTProto-native: there is no file server, so GetFile performs no network I/O and FilePath is left empty. Use DownloadFile or DownloadFileToPath to fetch the contents. FileUniqueID is derived locally from the file_id.
func (*Bot) GetGameHighScores ¶
func (b *Bot) GetGameHighScores(ctx context.Context, chat ChatID, messageID int, userID int64) ([]GameHighScore, error)
GetGameHighScores returns the high scores of the game in the given message for the user and their close neighbors.
func (*Bot) GetMyCommands ¶
func (b *Bot) GetMyCommands(ctx context.Context, opts ...CommandOption) ([]BotCommand, error)
GetMyCommands returns the current list of the bot's commands for the given scope and language.
func (*Bot) GetStickerSet ¶
GetStickerSet returns a sticker set by its short name.
func (*Bot) GetUserProfilePhotos ¶
func (b *Bot) GetUserProfilePhotos(ctx context.Context, userID int64, opts ...GetUserProfilePhotosOption) (*UserProfilePhotos, error)
GetUserProfilePhotos returns a user's profile photos.
func (*Bot) Logger ¶ added in v0.2.0
Logger returns the bot's structured logger (the github.com/gotd/log port).
func (*Bot) OnCallbackQuery ¶
OnCallbackQuery registers a handler for callback queries from inline keyboards.
func (*Bot) OnChannelPost ¶
OnChannelPost registers a handler for new channel posts.
func (*Bot) OnCommand ¶
OnCommand registers a handler for the given bot command (e.g. "start"). The description is shown in the client's command menu; unless command registration is disabled, Run publishes the registered commands to Telegram via SetMyCommands.
func (*Bot) OnEditedMessage ¶
OnEditedMessage registers a handler for edited messages.
func (*Bot) OnInlineQuery ¶
OnInlineQuery registers a handler for inline queries.
func (*Bot) OnPreCheckoutQuery ¶
OnPreCheckoutQuery registers a handler for pre-checkout queries.
func (*Bot) OnShippingQuery ¶
OnShippingQuery registers a handler for shipping queries (flexible invoices).
func (*Bot) PeerRef ¶ added in v0.2.0
PeerRef resolves a chat to a serializable reference including its access hash.
func (*Bot) PinChatMessage ¶
func (b *Bot) PinChatMessage(ctx context.Context, chat ChatID, messageID int, opts ...SendOption) error
PinChatMessage pins a message in a chat. By default it notifies members; pass Silent to pin quietly.
func (*Bot) PromoteChatMember ¶
func (b *Bot) PromoteChatMember(ctx context.Context, chat ChatID, userID int64, rights ChatAdminRights) error
PromoteChatMember promotes or demotes a user in a supergroup or channel. The granted rights are the true fields of rights; pass a zero value to demote.
func (*Bot) Raw ¶
Raw returns the underlying gotd/td API client for direct MTProto calls. It is the escape hatch for anything the Bot API surface does not (yet) cover.
func (*Bot) RestrictChatMember ¶
func (b *Bot) RestrictChatMember(ctx context.Context, chat ChatID, userID int64, permissions ChatPermissions, untilDate int) error
RestrictChatMember restricts a user in a supergroup. permissions is an allow-list; denied actions are turned into MTProto banned rights. untilDate is a Unix time (0 means forever).
func (*Bot) RevokeChatInviteLink ¶
func (b *Bot) RevokeChatInviteLink(ctx context.Context, chat ChatID, inviteLink string) (*ChatInviteLink, error)
RevokeChatInviteLink revokes an invite link created by the bot.
func (*Bot) Run ¶
Run connects, authorizes as a bot, and blocks serving updates until ctx is canceled or a fatal error occurs. Register handlers before calling Run.
func (*Bot) SendAnimation ¶
func (b *Bot) SendAnimation(ctx context.Context, chat ChatID, animation InputFile, caption string, opts ...SendOption) (*Message, error)
SendAnimation sends an animation (GIF or silent video) from a file_id, URL or local upload.
func (*Bot) SendAudio ¶
func (b *Bot) SendAudio(ctx context.Context, chat ChatID, audio InputFile, caption string, opts ...SendOption) (*Message, error)
SendAudio sends an audio file (music) from a file_id, URL or local upload.
func (*Bot) SendChatAction ¶
SendChatAction tells the chat that the bot is performing an action (e.g. "typing"). The status is cleared automatically after a short period or when the next message is sent.
The switch over ChatAction is exhaustive (exhaustive lint).
func (*Bot) SendContact ¶
func (b *Bot) SendContact(ctx context.Context, chat ChatID, phoneNumber, firstName, lastName string, opts ...SendOption) (*Message, error)
SendContact sends a phone contact.
func (*Bot) SendDice ¶
func (b *Bot) SendDice(ctx context.Context, chat ChatID, emoji DiceEmoji, opts ...SendOption) (*Message, error)
SendDice sends an animated emoji with a random value. A zero emoji defaults to the die (🎲).
func (*Bot) SendDocument ¶
func (b *Bot) SendDocument(ctx context.Context, chat ChatID, document InputFile, caption string, opts ...SendOption) (*Message, error)
SendDocument sends a general file from a file_id, URL or local upload.
func (*Bot) SendGame ¶
func (b *Bot) SendGame(ctx context.Context, chat ChatID, gameShortName string, opts ...SendOption) (*Message, error)
SendGame sends a game identified by its short name (configured via BotFather).
func (*Bot) SendInvoice ¶
func (b *Bot) SendInvoice(ctx context.Context, chat ChatID, params InvoiceParams, opts ...SendOption) (*Message, error)
SendInvoice sends an invoice.
func (*Bot) SendLocation ¶
func (b *Bot) SendLocation(ctx context.Context, chat ChatID, latitude, longitude float64, opts ...SendOption) (*Message, error)
SendLocation sends a point on the map.
func (*Bot) SendMediaGroup ¶
func (b *Bot) SendMediaGroup(ctx context.Context, chat ChatID, media []InputMedia, opts ...SendOption) ([]*Message, error)
SendMediaGroup sends a group of 2-10 photos, videos, documents or audio files as an album. Items referencing an existing file_id are not yet supported.
func (*Bot) SendMessage ¶
func (b *Bot) SendMessage(ctx context.Context, chat ChatID, text string, opts ...SendOption) (*Message, error)
SendMessage sends a text message to a chat and returns the sent message.
func (*Bot) SendPhoto ¶
func (b *Bot) SendPhoto(ctx context.Context, chat ChatID, photo InputFile, caption string, opts ...SendOption) (*Message, error)
SendPhoto sends a photo from a file_id, URL or local upload.
func (*Bot) SendPoll ¶
func (b *Bot) SendPoll(ctx context.Context, chat ChatID, question string, options []string, opts ...SendOption) (*Message, error)
SendPoll sends a native poll. At least two options are required.
func (*Bot) SendRichHTML ¶ added in v0.2.0
func (b *Bot) SendRichHTML(ctx context.Context, chat ChatID, html string, opts ...SendOption) (*Message, error)
SendRichHTML sends a rich message whose content is the given HTML document, parsed by Telegram's servers.
func (*Bot) SendRichMarkdown ¶ added in v0.2.0
func (b *Bot) SendRichMarkdown(ctx context.Context, chat ChatID, markdown string, opts ...SendOption) (*Message, error)
SendRichMarkdown sends a rich message whose content is the given Markdown document, parsed by Telegram's servers.
func (*Bot) SendRichMessage ¶ added in v0.2.0
func (b *Bot) SendRichMessage(ctx context.Context, chat ChatID, msg tg.InputRichMessageClass, opts ...SendOption) (*Message, error)
SendRichMessage sends a rich message (Bot API 10.1): structured content — headings, paragraphs, lists, tables, block quotes, media, math and more — as a tree of page blocks rather than a flat string with entity ranges.
Build the content with github.com/gotd/td/telegram/message/rich, for example:
msg := rich.New(
rich.Heading1(rich.Plain("Title")),
rich.Paragraph(rich.Bold(rich.Plain("Hello"))),
).Input()
bot.SendRichMessage(ctx, chat, msg)
For whole-document HTML or Markdown, prefer SendRichHTML / SendRichMarkdown. The usual SendOptions (reply, silent, protect, reply markup) apply.
func (*Bot) SendSticker ¶
func (b *Bot) SendSticker(ctx context.Context, chat ChatID, sticker InputFile, opts ...SendOption) (*Message, error)
SendSticker sends a sticker from a file_id, URL or local upload.
func (*Bot) SendVenue ¶
func (b *Bot) SendVenue( ctx context.Context, chat ChatID, latitude, longitude float64, title, address string, opts ...SendOption, ) (*Message, error)
SendVenue sends information about a venue.
func (*Bot) SendVideo ¶
func (b *Bot) SendVideo(ctx context.Context, chat ChatID, video InputFile, caption string, opts ...SendOption) (*Message, error)
SendVideo sends a video from a file_id, URL or local upload.
func (*Bot) SendVideoNote ¶
func (b *Bot) SendVideoNote(ctx context.Context, chat ChatID, videoNote InputFile, opts ...SendOption) (*Message, error)
SendVideoNote sends a rounded square video message from a file_id or local upload.
func (*Bot) SendVoice ¶
func (b *Bot) SendVoice(ctx context.Context, chat ChatID, voice InputFile, caption string, opts ...SendOption) (*Message, error)
SendVoice sends a voice note from a file_id, URL or local upload.
func (*Bot) SetChatAdministratorCustomTitle ¶
func (b *Bot) SetChatAdministratorCustomTitle(ctx context.Context, chat ChatID, userID int64, customTitle string) error
SetChatAdministratorCustomTitle sets a custom title (rank) for an administrator that the bot has promoted in a supergroup. It preserves the administrator's existing rights.
func (*Bot) SetChatDescription ¶
SetChatDescription changes the description of a chat.
func (*Bot) SetChatPermissions ¶
func (b *Bot) SetChatPermissions(ctx context.Context, chat ChatID, permissions ChatPermissions) error
SetChatPermissions sets the default permissions for all non-administrator members of a supergroup. permissions is an allow-list.
func (*Bot) SetChatPhoto ¶
SetChatPhoto sets a new profile photo for a chat. The photo must be a local upload (file_id and URL are not accepted by Telegram for this method).
func (*Bot) SetChatStickerSet ¶
SetChatStickerSet sets the group sticker set for a supergroup.
func (*Bot) SetChatTitle ¶
SetChatTitle changes the title of a chat. The bot must be an administrator with the appropriate rights.
func (*Bot) SetGameScore ¶
func (b *Bot) SetGameScore( ctx context.Context, chat ChatID, messageID int, userID int64, score int, opts ...SetGameScoreOption, ) (*Message, error)
SetGameScore sets a user's score in the game contained in the given message.
func (*Bot) SetMyCommands ¶
func (b *Bot) SetMyCommands(ctx context.Context, commands []BotCommand, opts ...CommandOption) error
SetMyCommands sets the list of the bot's commands for the given scope and language.
func (*Bot) SetPassportDataErrors ¶
func (b *Bot) SetPassportDataErrors(ctx context.Context, userID int64, errs []PassportElementError) error
SetPassportDataErrors reports errors in the Telegram Passport data the user submitted to the bot, so the user can fix and resubmit them.
func (*Bot) SetStickerPositionInSet ¶
SetStickerPositionInSet moves a sticker, referenced by file_id, to the given zero-based position in its set.
func (*Bot) SetStickerSetThumb ¶
SetStickerSetThumb sets the thumbnail of a sticker set owned by the bot. The thumbnail is referenced by file_id or uploaded.
func (*Bot) StopMessageLiveLocation ¶
func (b *Bot) StopMessageLiveLocation(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Message, error)
StopMessageLiveLocation stops updating a live location message before its live period expires.
func (*Bot) StopPoll ¶
func (b *Bot) StopPoll(ctx context.Context, chat ChatID, messageID int, markup ReplyMarkup) (*Poll, error)
StopPoll stops an open poll and returns its final state. The bot must be the poll's author.
func (*Bot) UnbanChatMember ¶
UnbanChatMember removes a user's ban from a supergroup or channel, clearing all restrictions. It does not re-add the user to the chat.
func (*Bot) UnpinAllChatMessages ¶
UnpinAllChatMessages clears the list of pinned messages in a chat.
func (*Bot) UnpinChatMessage ¶
UnpinChatMessage unpins the message with the given id in a chat.
func (*Bot) UploadStickerFile ¶
func (b *Bot) UploadStickerFile(ctx context.Context, userID int64, sticker InputFile, format StickerFormat) (*File, error)
UploadStickerFile uploads a file for later use in a sticker set and returns a File whose file_id can be passed to CreateNewStickerSet or AddStickerToSet.
func (*Bot) Use ¶
func (b *Bot) Use(mws ...Middleware)
Use registers global middleware applied to every handled update. Middleware runs outermost-first in registration order. Call before Run.
type BotCommand ¶
type BotCommand struct {
// Command is the text of the command, 1-32 characters, lowercase English
// letters, digits and underscores.
Command string `json:"command"`
// Description is the command description, 1-256 characters.
Description string `json:"description"`
}
BotCommand represents a bot command shown in the menu.
type BotCommandScope ¶
type BotCommandScope interface {
// contains filtered or unexported methods
}
BotCommandScope is a sealed union describing the scope to which a list of bot commands applies.
Construct with BotCommandScopeDefault, BotCommandScopeAllPrivateChats, BotCommandScopeAllGroupChats, BotCommandScopeAllChatAdministrators, BotCommandScopeChat, BotCommandScopeChatAdministrators or BotCommandScopeChatMember.
func BotCommandScopeAllChatAdministrators ¶
func BotCommandScopeAllChatAdministrators() BotCommandScope
BotCommandScopeAllChatAdministrators covers all group and supergroup chat administrators.
func BotCommandScopeAllGroupChats ¶
func BotCommandScopeAllGroupChats() BotCommandScope
BotCommandScopeAllGroupChats covers all group and supergroup chats.
func BotCommandScopeAllPrivateChats ¶
func BotCommandScopeAllPrivateChats() BotCommandScope
BotCommandScopeAllPrivateChats covers all private chats.
func BotCommandScopeChat ¶
func BotCommandScopeChat(chat ChatID) BotCommandScope
BotCommandScopeChat covers a specific chat.
func BotCommandScopeChatAdministrators ¶
func BotCommandScopeChatAdministrators(chat ChatID) BotCommandScope
BotCommandScopeChatAdministrators covers the administrators of a specific group or supergroup chat.
func BotCommandScopeChatMember ¶
func BotCommandScopeChatMember(chat ChatID, userID int64) BotCommandScope
BotCommandScopeChatMember covers a specific member of a group or supergroup chat.
func BotCommandScopeDefault ¶
func BotCommandScopeDefault() BotCommandScope
BotCommandScopeDefault covers all chats with no narrower scope set.
type CallbackQuery ¶
type CallbackQuery struct {
ID string `json:"id"`
From User `json:"from"`
Message *Message `json:"message,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
ChatInstance string `json:"chat_instance,omitempty"`
Data string `json:"data,omitempty"`
GameShortName string `json:"game_short_name,omitempty"`
}
CallbackQuery represents an incoming callback from a callback button in an inline keyboard.
type Chat ¶
type Chat struct {
ID int64 `json:"id"`
Type ChatType `json:"type"`
Title string `json:"title,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
IsForum bool `json:"is_forum,omitempty"`
}
Chat represents a chat: a private conversation, group, supergroup or channel.
func (Chat) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Chat) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type ChatAction ¶
type ChatAction string
ChatAction is a status reported to a chat via SendChatAction.
const ( ChatActionTyping ChatAction = "typing" ChatActionUploadPhoto ChatAction = "upload_photo" ChatActionRecordVideo ChatAction = "record_video" ChatActionUploadVideo ChatAction = "upload_video" ChatActionRecordVoice ChatAction = "record_voice" ChatActionUploadVoice ChatAction = "upload_voice" ChatActionUploadDocument ChatAction = "upload_document" ChatActionChooseSticker ChatAction = "choose_sticker" ChatActionFindLocation ChatAction = "find_location" ChatActionRecordVideoNote ChatAction = "record_video_note" ChatActionUploadVideoNote ChatAction = "upload_video_note" )
type ChatAdminRights ¶
type ChatAdminRights struct {
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"`
CanManageTopics bool `json:"can_manage_topics,omitempty"`
// CustomTitle is the administrator's rank (custom title), if any.
CustomTitle string `json:"custom_title,omitempty"`
}
ChatAdminRights describes the administrator privileges granted to a user in a supergroup or channel. It mirrors the Bot API promoteChatMember parameters.
type ChatID ¶
type ChatID interface {
// json.Marshaler so a ChatID serializes to the bare int or string the wire
// format expects.
json.Marshaler
// contains filtered or unexported methods
}
ChatID identifies a target chat. The Bot API accepts either a numeric chat id or an @username; this sealed union represents exactly those two cases, so an illegal "both/neither" state is unrepresentable.
Construct with ID or Username.
type ChatIDInt ¶
type ChatIDInt int64
ChatIDInt is a numeric chat identifier.
func (ChatIDInt) MarshalJSON ¶
MarshalJSON encodes the id as a JSON number.
type ChatIDUsername ¶
type ChatIDUsername string
ChatIDUsername is an @username target (with or without the leading @).
func (ChatIDUsername) MarshalJSON ¶
func (c ChatIDUsername) MarshalJSON() ([]byte, error)
MarshalJSON encodes the username as a JSON string.
type ChatInviteLink ¶
type ChatInviteLink struct {
InviteLink string `json:"invite_link"`
Creator User `json:"creator"`
CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
IsPrimary bool `json:"is_primary,omitempty"`
IsRevoked bool `json:"is_revoked,omitempty"`
Name string `json:"name,omitempty"`
ExpireDate int `json:"expire_date,omitempty"`
MemberLimit int `json:"member_limit,omitempty"`
PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
}
ChatInviteLink represents an invite link for a chat.
type ChatMember ¶
type ChatMember interface {
// contains filtered or unexported methods
}
ChatMember is a sealed union describing one member of a chat. The concrete type corresponds to the member's status.
Concrete variants: *ChatMemberOwner, *ChatMemberAdministrator, *ChatMemberMember, *ChatMemberRestricted, *ChatMemberLeft, *ChatMemberBanned.
type ChatMemberAdministrator ¶
type ChatMemberAdministrator struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
CanBeEdited bool `json:"can_be_edited,omitempty"`
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"`
CustomTitle string `json:"custom_title,omitempty"`
}
ChatMemberAdministrator is a chat administrator with granted privileges.
type ChatMemberBanned ¶
type ChatMemberBanned struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
UntilDate int `json:"until_date,omitempty"`
}
ChatMemberBanned is a user banned from the chat.
type ChatMemberLeft ¶
type ChatMemberLeft struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
}
ChatMemberLeft is a user who is not and was not a member of the chat.
type ChatMemberMember ¶
type ChatMemberMember struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
UntilDate int `json:"until_date,omitempty"`
}
ChatMemberMember is an ordinary member with no special restrictions.
type ChatMemberOwner ¶
type ChatMemberOwner struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
IsAnonymous bool `json:"is_anonymous,omitempty"`
CustomTitle string `json:"custom_title,omitempty"`
}
ChatMemberOwner is the chat creator.
type ChatMemberRestricted ¶
type ChatMemberRestricted struct {
Status ChatMemberStatus `json:"status"`
User User `json:"user"`
IsMember bool `json:"is_member,omitempty"`
CanSendMessages bool `json:"can_send_messages,omitempty"`
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
CanSendPolls bool `json:"can_send_polls,omitempty"`
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
CanChangeInfo bool `json:"can_change_info,omitempty"`
CanInviteUsers bool `json:"can_invite_users,omitempty"`
CanPinMessages bool `json:"can_pin_messages,omitempty"`
UntilDate int `json:"until_date,omitempty"`
}
ChatMemberRestricted is a member subject to restrictions.
type ChatMemberStatus ¶
type ChatMemberStatus string
ChatMemberStatus is a member's status in a chat.
const ( StatusCreator ChatMemberStatus = "creator" StatusAdministrator ChatMemberStatus = "administrator" StatusMember ChatMemberStatus = "member" StatusRestricted ChatMemberStatus = "restricted" StatusLeft ChatMemberStatus = "left" StatusBanned ChatMemberStatus = "kicked" )
type ChatMemberUpdated ¶
type ChatMemberUpdated struct {
Chat Chat `json:"chat"`
From User `json:"from"`
Date int `json:"date"`
OldChatMember ChatMember `json:"old_chat_member"`
NewChatMember ChatMember `json:"new_chat_member"`
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
}
ChatMemberUpdated represents a change in the status of a chat member.
type ChatPermissions ¶
type ChatPermissions struct {
CanSendMessages bool `json:"can_send_messages,omitempty"`
CanSendAudios bool `json:"can_send_audios,omitempty"`
CanSendDocuments bool `json:"can_send_documents,omitempty"`
CanSendPhotos bool `json:"can_send_photos,omitempty"`
CanSendVideos bool `json:"can_send_videos,omitempty"`
CanSendVideoNotes bool `json:"can_send_video_notes,omitempty"`
CanSendVoiceNotes bool `json:"can_send_voice_notes,omitempty"`
CanSendPolls bool `json:"can_send_polls,omitempty"`
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
CanChangeInfo bool `json:"can_change_info,omitempty"`
CanInviteUsers bool `json:"can_invite_users,omitempty"`
CanPinMessages bool `json:"can_pin_messages,omitempty"`
CanManageTopics bool `json:"can_manage_topics,omitempty"`
}
ChatPermissions describes the actions a non-administrator user is allowed to take in a chat. A nil/false field denies the action.
type ChatType ¶
type ChatType string
ChatType is the kind of a chat.
const ( ChatTypePrivate ChatType = "private" ChatTypeGroup ChatType = "group" ChatTypeSupergroup ChatType = "supergroup" ChatTypeChannel ChatType = "channel" // ChatTypeSender is used for inline queries sent from the inline mode of a // private chat with the bot. ChatTypeSender ChatType = "sender" )
type ChosenInlineResult ¶
type ChosenInlineResult struct {
ResultID string `json:"result_id"`
From User `json:"from"`
Location *Location `json:"location,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
Query string `json:"query"`
}
ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner.
type CommandOption ¶
type CommandOption func(*commandConfig)
CommandOption configures a commands call (scope and language code).
func WithCommandScope ¶
func WithCommandScope(scope BotCommandScope) CommandOption
WithCommandScope restricts the commands call to the given scope. When unset the default scope is used.
func WithLanguageCode ¶
func WithLanguageCode(code string) CommandOption
WithLanguageCode restricts the commands call to a two-letter language code.
type Contact ¶
type Contact struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
UserID int64 `json:"user_id,omitempty"`
VCard string `json:"vcard,omitempty"`
}
Contact represents a phone contact.
func (Contact) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Contact) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Context ¶
Context is passed to a Handler. It embeds the request context (so it can be passed straight to Bot methods) and carries the Bot and the Update.
func (*Context) AnswerCallback ¶
func (c *Context) AnswerCallback(opts ...AnswerCallbackQueryOption) error
AnswerCallback answers the update's callback query. It is an error to call it when the update is not a callback query.
func (*Context) AnswerInline ¶
func (c *Context) AnswerInline(results []InlineQueryResult, opts ...AnswerInlineQueryOption) error
AnswerInline answers the update's inline query with the given results. It is an error to call it when the update is not an inline query.
func (*Context) Background ¶ added in v0.2.0
Background returns a context tied to the bot's run lifetime, for sends that must outlive this handler (a timer, queue or goroutine). The handler's own context is per-update and may be canceled (e.g. by Timeout middleware) as soon as the handler returns, so do not capture it for background work.
Send messages to any chat in the background with Bot.SendMessage and this context:
ctx := c.Background()
go func() { c.Bot.SendMessage(ctx, botapi.ID(other), "hi") }()
func (*Context) Message ¶
Message returns the message the update carries (new/edited message or channel post), or nil.
func (*Context) Reply ¶
func (c *Context) Reply(text string, opts ...SendOption) (*Message, error)
Reply sends a text message to the update's chat as a reply to the incoming message.
type Dice ¶
Dice represents an animated emoji with a random value.
func (Dice) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Dice) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Document ¶
type Document struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Document represents a general file (other than photos, voice or audio).
func (Document) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Document) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Error ¶
type Error struct {
// Code is the Bot-API-compatible error code (e.g. 400, 403, 429).
Code int
// Description is a human-readable message.
Description string
// Parameters carries optional recovery hints (retry_after, migrate_to_chat_id).
Parameters *ResponseParameters
// contains filtered or unexported fields
}
Error is a Bot-API-shaped error. Methods return it (wrapped) so callers can branch on a stable Code/Description regardless of the underlying MTProto error.
Use errors.As to extract it:
var apiErr *botapi.Error
if errors.As(err, &apiErr) && apiErr.Code == 403 { ... }
type File ¶
type File struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int64 `json:"file_size,omitempty"`
FilePath string `json:"file_path,omitempty"`
}
File represents a file ready to be downloaded.
type ForceReply ¶
type ForceReply struct {
// ForceReply is always true; the type itself signals the intent.
ForceReply bool `json:"force_reply"`
InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
Selective bool `json:"selective,omitempty"`
}
ForceReply forces the user's client to display a reply interface.
type Game ¶
type Game struct {
Title string `json:"title"`
Description string `json:"description"`
Photo []PhotoSize `json:"photo"`
Text string `json:"text,omitempty"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
Animation *Animation `json:"animation,omitempty"`
}
Game represents a game. Use BotFather to set up a game for your bot.
type GameHighScore ¶
type GameHighScore struct {
Position int `json:"position"`
User User `json:"user"`
Score int `json:"score"`
}
GameHighScore represents one row of a game's high-score table.
type GetUserProfilePhotosOption ¶
type GetUserProfilePhotosOption func(*userPhotosConfig)
GetUserProfilePhotosOption configures a GetUserProfilePhotos call.
func WithProfilePhotosLimit ¶
func WithProfilePhotosLimit(limit int) GetUserProfilePhotosOption
WithProfilePhotosLimit caps the number of photos returned (1-100).
func WithProfilePhotosOffset ¶
func WithProfilePhotosOffset(offset int) GetUserProfilePhotosOption
WithProfilePhotosOffset sets the number of photos to skip.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a set of handlers that share predicates and middleware. Every handler registered through the group inherits the group's predicates (as additional guards) and its middleware (applied inside the global middleware).
Create one with Bot.Group:
admin := bot.Group(ChatTypeIs(ChatTypeSupergroup))
admin.Use(Recover())
admin.OnCommand("ban", "Ban a user", banHandler)
func (*Group) OnCallbackQuery ¶
OnCallbackQuery registers a callback-query handler in the group.
func (*Group) Use ¶
func (g *Group) Use(mws ...Middleware) *Group
Use adds middleware applied to every handler registered through this group. Returns the group for chaining.
type InlineKeyboardButton ¶
type InlineKeyboardButton struct {
Text string `json:"text"`
URL string `json:"url,omitempty"`
CallbackData string `json:"callback_data,omitempty"`
WebApp *WebAppInfo `json:"web_app,omitempty"`
SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
Pay bool `json:"pay,omitempty"`
}
InlineKeyboardButton is one button of an inline keyboard. Exactly one of the optional action fields should be set.
func InlineButtonData ¶
func InlineButtonData(text, data string) InlineKeyboardButton
InlineButtonData builds an inline button that sends callback data.
func InlineButtonURL ¶
func InlineButtonURL(text, url string) InlineKeyboardButton
InlineButtonURL builds an inline button that opens a URL.
func InlineRow ¶
func InlineRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton
InlineRow groups inline buttons into a single keyboard row.
func (*InlineKeyboardButton) Decode ¶ added in v0.2.0
func (s *InlineKeyboardButton) Decode(d *jx.Decoder) error
Decode parses the inline keyboard button from a JSON object.
func (*InlineKeyboardButton) Encode ¶ added in v0.2.0
func (s *InlineKeyboardButton) Encode(e *jx.Encoder)
Encode writes the inline keyboard button as a JSON object.
func (InlineKeyboardButton) MarshalJSON ¶ added in v0.2.0
func (s InlineKeyboardButton) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*InlineKeyboardButton) UnmarshalJSON ¶ added in v0.2.0
func (s *InlineKeyboardButton) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
InlineKeyboardMarkup is an inline keyboard that appears beneath a message.
func InlineKeyboard ¶
func InlineKeyboard(rows ...[]InlineKeyboardButton) *InlineKeyboardMarkup
InlineKeyboard builds an inline keyboard from rows of buttons.
func (*InlineKeyboardMarkup) Decode ¶ added in v0.2.0
func (s *InlineKeyboardMarkup) Decode(d *jx.Decoder) error
Decode parses the inline keyboard markup from a JSON object.
func (*InlineKeyboardMarkup) Encode ¶ added in v0.2.0
func (s *InlineKeyboardMarkup) Encode(e *jx.Encoder)
Encode writes the inline keyboard markup as a JSON object.
func (InlineKeyboardMarkup) MarshalJSON ¶ added in v0.2.0
func (s InlineKeyboardMarkup) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*InlineKeyboardMarkup) UnmarshalJSON ¶ added in v0.2.0
func (s *InlineKeyboardMarkup) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type InlineQuery ¶
type InlineQuery struct {
ID string `json:"id"`
From User `json:"from"`
Query string `json:"query"`
Offset string `json:"offset"`
ChatType ChatType `json:"chat_type,omitempty"`
Location *Location `json:"location,omitempty"`
}
InlineQuery represents an incoming inline query.
type InlineQueryResult ¶
type InlineQueryResult interface {
// contains filtered or unexported methods
}
InlineQueryResult is a sealed union describing one result of an inline query.
Concrete variants cover articles, fresh-by-URL media (photo/gif/mpeg4 gif/video), cached-by-file_id media (photo/gif/mpeg4 gif/sticker/document/ video/audio/voice) and contact/location/venue results.
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct {
ID string `json:"id"`
Title string `json:"title"`
InputMessageContent InputMessageContent `json:"input_message_content"`
ReplyMarkup *InlineKeyboardMarkup
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
}
InlineQueryResultArticle is a link to an article or web page.
type InlineQueryResultCachedAudio ¶
type InlineQueryResultCachedAudio struct {
ID string `json:"id"`
AudioFileID string `json:"audio_file_id"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedAudio is a link to an audio file stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedDocument ¶
type InlineQueryResultCachedDocument struct {
ID string `json:"id"`
Title string `json:"title"`
DocumentFileID string `json:"document_file_id"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedDocument is a link to a file stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedGif ¶
type InlineQueryResultCachedGif struct {
ID string `json:"id"`
GifFileID string `json:"gif_file_id"`
Title string `json:"title,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedGif is a link to an animated GIF stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedPhoto ¶
type InlineQueryResultCachedPhoto struct {
ID string `json:"id"`
PhotoFileID string `json:"photo_file_id"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedPhoto is a link to a photo stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedSticker ¶
type InlineQueryResultCachedSticker struct {
ID string `json:"id"`
StickerFileID string `json:"sticker_file_id"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
}
InlineQueryResultCachedSticker is a link to a sticker stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedVideo ¶
type InlineQueryResultCachedVideo struct {
ID string `json:"id"`
VideoFileID string `json:"video_file_id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedVideo is a link to a video stored on Telegram's servers, referenced by file_id.
type InlineQueryResultCachedVoice ¶
type InlineQueryResultCachedVoice struct {
ID string `json:"id"`
VoiceFileID string `json:"voice_file_id"`
Title string `json:"title"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultCachedVoice is a link to a voice message stored on Telegram's servers, referenced by file_id.
type InlineQueryResultContact ¶
type InlineQueryResultContact struct {
ID string `json:"id"`
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Vcard string `json:"vcard,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
}
InlineQueryResultContact is a contact with a phone number.
type InlineQueryResultGif ¶
type InlineQueryResultGif struct {
ID string `json:"id"`
GifURL string `json:"gif_url"`
ThumbnailURL string `json:"thumbnail_url"`
GifWidth int `json:"gif_width,omitempty"`
GifHeight int `json:"gif_height,omitempty"`
Title string `json:"title,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultGif is a link to an animated GIF, sent by URL.
type InlineQueryResultLocation ¶
type InlineQueryResultLocation struct {
ID string `json:"id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading,omitempty"`
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
}
InlineQueryResultLocation is a location on a map.
type InlineQueryResultMpeg4Gif ¶
type InlineQueryResultMpeg4Gif struct {
ID string `json:"id"`
Mpeg4URL string `json:"mpeg4_url"`
ThumbnailURL string `json:"thumbnail_url"`
Title string `json:"title,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultMpeg4Gif is a link to an MPEG-4 animation (video without sound), sent by URL.
type InlineQueryResultPhoto ¶
type InlineQueryResultPhoto struct {
ID string `json:"id"`
PhotoURL string `json:"photo_url"`
ThumbnailURL string `json:"thumbnail_url"`
PhotoWidth int `json:"photo_width,omitempty"`
PhotoHeight int `json:"photo_height,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
// contains filtered or unexported fields
}
InlineQueryResultPhoto is a link to a photo, sent by URL.
type InlineQueryResultVenue ¶
type InlineQueryResultVenue struct {
ID string `json:"id"`
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"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ReplyMarkup *InlineKeyboardMarkup
InputMessageContent InputMessageContent
}
InlineQueryResultVenue is a venue.
type InputContactMessageContent ¶
type InputContactMessageContent struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Vcard string `json:"vcard,omitempty"`
}
InputContactMessageContent is the content of a contact message.
type InputFile ¶
type InputFile interface {
// contains filtered or unexported methods
}
InputFile is a sealed union describing a file to send: an existing Telegram file_id, an HTTP URL Telegram fetches, or a local upload.
Construct with FileID, FileURL, FileFromPath, FileFromBytes or FileFromReader.
func FileFromBytes ¶
FileFromBytes uploads in-memory content under the given filename.
func FileFromPath ¶
FileFromPath uploads a local file from disk.
func FileFromReader ¶
FileFromReader uploads streamed content under the given filename.
type InputFileID ¶
type InputFileID string
InputFileID references a file already on Telegram's servers by file_id.
type InputFileURL ¶
type InputFileURL string
InputFileURL references a file by HTTP URL for Telegram to fetch.
type InputFileUpload ¶
type InputFileUpload struct {
// Name is the filename reported to Telegram.
Name string
// Path, when non-empty, is read from disk.
Path string
// Bytes, when non-nil, is the in-memory content.
Bytes []byte
// Reader, when non-nil, streams the content.
Reader interface{ Read([]byte) (int, error) }
}
InputFileUpload is a local file to be uploaded. Exactly one source is set; the send path (Phase 3) chooses the uploader accordingly.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct {
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"`
}
InputLocationMessageContent is the content of a location message.
type InputMedia ¶
type InputMedia interface {
// contains filtered or unexported methods
}
InputMedia is a sealed union describing the content of a media message to be sent (e.g. in a media group or via an edit).
Concrete variants: *InputMediaPhoto, *InputMediaVideo, *InputMediaAnimation, *InputMediaAudio, *InputMediaDocument.
The Media (and Thumbnail) fields hold an InputFile; the send path (Phase 3) resolves each to a file_id, URL or upload.
type InputMediaAnimation ¶
type InputMediaAnimation struct {
Type InputMediaType `json:"type"`
Media InputFile `json:"-"`
Thumbnail InputFile `json:"-"`
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
HasSpoiler bool `json:"has_spoiler,omitempty"`
}
InputMediaAnimation is an animation (GIF or silent H.264/MPEG-4 AVC) to be sent.
type InputMediaAudio ¶
type InputMediaAudio struct {
Type InputMediaType `json:"type"`
Media InputFile `json:"-"`
Thumbnail InputFile `json:"-"`
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Duration int `json:"duration,omitempty"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
}
InputMediaAudio is an audio file to be sent.
type InputMediaDocument ¶
type InputMediaDocument struct {
Type InputMediaType `json:"type"`
Media InputFile `json:"-"`
Thumbnail InputFile `json:"-"`
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
}
InputMediaDocument is a general file to be sent.
type InputMediaPhoto ¶
type InputMediaPhoto struct {
Type InputMediaType `json:"type"`
Media InputFile `json:"-"`
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
HasSpoiler bool `json:"has_spoiler,omitempty"`
}
InputMediaPhoto is a photo to be sent.
type InputMediaType ¶
type InputMediaType string
InputMediaType discriminates an InputMedia variant.
const ( InputMediaPhotoType InputMediaType = "photo" InputMediaVideoType InputMediaType = "video" InputMediaAnimationType InputMediaType = "animation" InputMediaAudioType InputMediaType = "audio" InputMediaDocumentType InputMediaType = "document" )
type InputMediaVideo ¶
type InputMediaVideo struct {
Type InputMediaType `json:"type"`
Media InputFile `json:"-"`
Thumbnail InputFile `json:"-"`
Caption string `json:"caption,omitempty"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
SupportsStreaming bool `json:"supports_streaming,omitempty"`
HasSpoiler bool `json:"has_spoiler,omitempty"`
}
InputMediaVideo is a video to be sent.
type InputMessageContent ¶
type InputMessageContent interface {
// contains filtered or unexported methods
}
InputMessageContent is a sealed union describing the content of a message to be sent as the result of an inline query.
Concrete variants: *InputTextMessageContent, *InputLocationMessageContent, *InputVenueMessageContent, *InputContactMessageContent.
type InputSticker ¶
type InputSticker struct {
// Sticker is the sticker file: a file_id from UploadStickerFile, or a local
// upload. URLs are not accepted.
Sticker InputFile
// Format is the sticker file format.
Format StickerFormat
// EmojiList are the emoji associated with the sticker (1-20).
EmojiList []string
// Keywords are optional search keywords, comma-joined on the wire.
Keywords []string
}
InputSticker describes a sticker to be added to a set.
type InputTextMessageContent ¶
type InputTextMessageContent struct {
MessageText string `json:"message_text"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}
InputTextMessageContent is the content of a text message.
type InputVenueMessageContent ¶
type InputVenueMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
}
InputVenueMessageContent is the content of a venue message.
type InviteLinkOption ¶
type InviteLinkOption func(*peers.ExportLinkOptions)
InviteLinkOption configures a create/edit invite-link call.
func WithInviteLinkExpire ¶
func WithInviteLinkExpire(unixTime int) InviteLinkOption
WithInviteLinkExpire sets the Unix time when the link will expire.
func WithInviteLinkJoinRequest ¶
func WithInviteLinkJoinRequest() InviteLinkOption
WithInviteLinkJoinRequest requires administrators to approve users joining via this link.
func WithInviteLinkMemberLimit ¶
func WithInviteLinkMemberLimit(limit int) InviteLinkOption
WithInviteLinkMemberLimit caps how many users may join via this link.
func WithInviteLinkName ¶
func WithInviteLinkName(name string) InviteLinkOption
WithInviteLinkName sets the invite link name (0-32 characters).
type InvoiceParams ¶
type InvoiceParams struct {
Title string `json:"title"`
Description string `json:"description"`
Payload string `json:"payload"` // bot-defined, not shown to the user
ProviderToken string `json:"provider_token"`
Currency string `json:"currency"`
Prices []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"` // JSON for the payment provider
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"`
}
InvoiceParams describes an invoice to send with SendInvoice.
type KeyboardButton ¶
type KeyboardButton struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact,omitempty"`
RequestLocation bool `json:"request_location,omitempty"`
RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
WebApp *WebAppInfo `json:"web_app,omitempty"`
}
KeyboardButton is one button of a reply (custom) keyboard. Text is sent as a plain message when no request/web-app field is set.
func Button ¶
func Button(text string) KeyboardButton
Button builds a plain-text reply-keyboard button.
func ButtonContact ¶
func ButtonContact(text string) KeyboardButton
ButtonContact builds a reply-keyboard button that requests the user's contact.
func ButtonLocation ¶
func ButtonLocation(text string) KeyboardButton
ButtonLocation builds a reply-keyboard button that requests the user's location.
func Row ¶
func Row(buttons ...KeyboardButton) []KeyboardButton
Row groups reply-keyboard buttons into a single row.
type KeyboardButtonPollType ¶
type KeyboardButtonPollType struct {
Type PollType `json:"type,omitempty"`
}
KeyboardButtonPollType is the poll-type constraint of a poll-request button.
type LabeledPrice ¶
type LabeledPrice struct {
Label string `json:"label"`
// Amount is the price in the smallest units of the currency (integer), e.g.
// for $1.45 pass amount = 145.
Amount int `json:"amount"`
}
LabeledPrice represents a portion of the price for goods or services.
type LiveLocationOption ¶
type LiveLocationOption func(*liveLocationConfig)
LiveLocationOption configures a live-location edit.
func WithHeading ¶
func WithHeading(degrees int) LiveLocationOption
WithHeading sets the direction in which the user is moving, 1-360 degrees.
func WithHorizontalAccuracy ¶
func WithHorizontalAccuracy(meters float64) LiveLocationOption
WithHorizontalAccuracy sets the radius of uncertainty for the location, in meters (0-1500).
func WithLiveLocationMarkup ¶
func WithLiveLocationMarkup(markup ReplyMarkup) LiveLocationOption
WithLiveLocationMarkup attaches or replaces the inline keyboard on the edited message.
func WithProximityAlertRadius ¶
func WithProximityAlertRadius(meters int) LiveLocationOption
WithProximityAlertRadius sets the maximum distance, in meters, for proximity alerts about another chat member.
type Location ¶
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading,omitempty"`
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
Location represents a point on the map.
func (Location) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Location) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type MenuButton ¶
type MenuButton interface {
// contains filtered or unexported methods
}
MenuButton is a sealed union describing the bot's menu button.
Concrete variants: MenuButtonCommands, MenuButtonWebApp, MenuButtonDefault.
type MenuButtonCommands ¶
type MenuButtonCommands struct {
Type MenuButtonType `json:"type"`
}
MenuButtonCommands opens the bot's command list.
type MenuButtonDefault ¶
type MenuButtonDefault struct {
Type MenuButtonType `json:"type"`
}
MenuButtonDefault is the default menu button.
type MenuButtonType ¶
type MenuButtonType string
MenuButtonType discriminates a MenuButton variant.
const ( MenuButtonCommandsType MenuButtonType = "commands" MenuButtonWebAppType MenuButtonType = "web_app" MenuButtonDefaultType MenuButtonType = "default" )
type MenuButtonWebApp ¶
type MenuButtonWebApp struct {
Type MenuButtonType `json:"type"`
Text string `json:"text"`
WebApp WebAppInfo `json:"web_app"`
}
MenuButtonWebApp opens a Web App.
type Message ¶
type Message struct {
MessageID int `json:"message_id"`
MessageThreadID int `json:"message_thread_id,omitempty"`
From *User `json:"from,omitempty"`
SenderChat *Chat `json:"sender_chat,omitempty"`
Date int `json:"date"`
Chat Chat `json:"chat"`
ForwardOrigin MessageOrigin `json:"forward_origin,omitempty"`
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
ViaBot *User `json:"via_bot,omitempty"`
EditDate int `json:"edit_date,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
MediaGroupID string `json:"media_group_id,omitempty"`
AuthorSignature string `json:"author_signature,omitempty"`
Text string `json:"text,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
Caption string `json:"caption,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Animation *Animation `json:"animation,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Document *Document `json:"document,omitempty"`
Photo []PhotoSize `json:"photo,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
Video *Video `json:"video,omitempty"`
VideoNote *VideoNote `json:"video_note,omitempty"`
Voice *Voice `json:"voice,omitempty"`
Contact *Contact `json:"contact,omitempty"`
Dice *Dice `json:"dice,omitempty"`
Poll *Poll `json:"poll,omitempty"`
Venue *Venue `json:"venue,omitempty"`
Location *Location `json:"location,omitempty"`
NewChatMembers []User `json:"new_chat_members,omitempty"`
LeftChatMember *User `json:"left_chat_member,omitempty"`
NewChatTitle string `json:"new_chat_title,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
Message represents a message.
func (*Message) Decode ¶ added in v0.2.0
Decode parses the message from a JSON object, resolving the polymorphic forward_origin field to its concrete MessageOrigin variant.
func (*Message) Encode ¶ added in v0.2.0
Encode writes the message as a JSON object, omitting zero-value optional fields to match the Bot API wire format.
func (*Message) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Message) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type MessageEntity ¶
type MessageEntity struct {
Type MessageEntityType `json:"type"`
Offset int `json:"offset"`
Length int `json:"length"`
URL string `json:"url,omitempty"`
User *User `json:"user,omitempty"`
Language string `json:"language,omitempty"`
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
}
MessageEntity represents one special entity in a text message (e.g. a hashtag, link, or formatted run).
func (*MessageEntity) Decode ¶ added in v0.2.0
func (s *MessageEntity) Decode(d *jx.Decoder) error
Decode parses the message entity from a JSON object.
func (*MessageEntity) Encode ¶ added in v0.2.0
func (s *MessageEntity) Encode(e *jx.Encoder)
Encode writes the message entity as a JSON object.
func (MessageEntity) MarshalJSON ¶ added in v0.2.0
func (s MessageEntity) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*MessageEntity) UnmarshalJSON ¶ added in v0.2.0
func (s *MessageEntity) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type MessageEntityType ¶
type MessageEntityType string
MessageEntityType is the kind of a MessageEntity.
const ( EntityMention MessageEntityType = "mention" EntityHashtag MessageEntityType = "hashtag" EntityCashtag MessageEntityType = "cashtag" EntityBotCommand MessageEntityType = "bot_command" EntityURL MessageEntityType = "url" EntityEmail MessageEntityType = "email" EntityPhoneNumber MessageEntityType = "phone_number" EntityBold MessageEntityType = "bold" EntityItalic MessageEntityType = "italic" EntityUnderline MessageEntityType = "underline" EntityStrikethrough MessageEntityType = "strikethrough" EntitySpoiler MessageEntityType = "spoiler" EntityBlockquote MessageEntityType = "blockquote" EntityExpandableBlockquote MessageEntityType = "expandable_blockquote" EntityCode MessageEntityType = "code" EntityPre MessageEntityType = "pre" EntityTextLink MessageEntityType = "text_link" EntityTextMention MessageEntityType = "text_mention" EntityCustomEmoji MessageEntityType = "custom_emoji" )
type MessageOrigin ¶
type MessageOrigin interface {
// Encode writes the origin as a JSON object, including its "type"
// discriminator, through the jx encoder.
Encode(e *jx.Encoder)
// contains filtered or unexported methods
}
MessageOrigin is a sealed union describing the original sender of a forwarded message.
Concrete variants: *MessageOriginUser, *MessageOriginHiddenUser, *MessageOriginChat, *MessageOriginChannel.
type MessageOriginChannel ¶
type MessageOriginChannel struct {
Type MessageOriginType `json:"type"`
Date int `json:"date"`
Chat Chat `json:"chat"`
MessageID int `json:"message_id"`
AuthorSignature string `json:"author_signature,omitempty"`
}
MessageOriginChannel is a message originally sent to a channel.
func (*MessageOriginChannel) Decode ¶ added in v0.2.0
func (s *MessageOriginChannel) Decode(d *jx.Decoder) error
Decode parses the channel origin from a JSON object.
func (*MessageOriginChannel) Encode ¶ added in v0.2.0
func (s *MessageOriginChannel) Encode(e *jx.Encoder)
Encode writes the channel origin as a JSON object.
func (*MessageOriginChannel) MarshalJSON ¶ added in v0.2.0
func (s *MessageOriginChannel) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*MessageOriginChannel) UnmarshalJSON ¶ added in v0.2.0
func (s *MessageOriginChannel) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type MessageOriginChat ¶
type MessageOriginChat struct {
Type MessageOriginType `json:"type"`
Date int `json:"date"`
SenderChat Chat `json:"sender_chat"`
AuthorSignature string `json:"author_signature,omitempty"`
}
MessageOriginChat is a message originally sent on behalf of a chat.
func (*MessageOriginChat) Decode ¶ added in v0.2.0
func (s *MessageOriginChat) Decode(d *jx.Decoder) error
Decode parses the chat origin from a JSON object.
func (*MessageOriginChat) Encode ¶ added in v0.2.0
func (s *MessageOriginChat) Encode(e *jx.Encoder)
Encode writes the chat origin as a JSON object.
func (*MessageOriginChat) MarshalJSON ¶ added in v0.2.0
func (s *MessageOriginChat) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*MessageOriginChat) UnmarshalJSON ¶ added in v0.2.0
func (s *MessageOriginChat) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type MessageOriginHiddenUser ¶
type MessageOriginHiddenUser struct {
Type MessageOriginType `json:"type"`
Date int `json:"date"`
SenderUserName string `json:"sender_user_name"`
}
MessageOriginHiddenUser is a message originally sent by a user who hid their account.
func (*MessageOriginHiddenUser) Decode ¶ added in v0.2.0
func (s *MessageOriginHiddenUser) Decode(d *jx.Decoder) error
Decode parses the hidden-user origin from a JSON object.
func (*MessageOriginHiddenUser) Encode ¶ added in v0.2.0
func (s *MessageOriginHiddenUser) Encode(e *jx.Encoder)
Encode writes the hidden-user origin as a JSON object.
func (*MessageOriginHiddenUser) MarshalJSON ¶ added in v0.2.0
func (s *MessageOriginHiddenUser) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*MessageOriginHiddenUser) UnmarshalJSON ¶ added in v0.2.0
func (s *MessageOriginHiddenUser) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type MessageOriginType ¶
type MessageOriginType string
MessageOriginType discriminates a MessageOrigin variant.
const ( OriginUser MessageOriginType = "user" OriginHiddenUser MessageOriginType = "hidden_user" OriginChat MessageOriginType = "chat" OriginChannel MessageOriginType = "channel" )
type MessageOriginUser ¶
type MessageOriginUser struct {
Type MessageOriginType `json:"type"`
Date int `json:"date"`
SenderUser User `json:"sender_user"`
}
MessageOriginUser is a message originally sent by a known user.
func (*MessageOriginUser) Decode ¶ added in v0.2.0
func (s *MessageOriginUser) Decode(d *jx.Decoder) error
Decode parses the user origin from a JSON object.
func (*MessageOriginUser) Encode ¶ added in v0.2.0
func (s *MessageOriginUser) Encode(e *jx.Encoder)
Encode writes the user origin as a JSON object.
func (*MessageOriginUser) MarshalJSON ¶ added in v0.2.0
func (s *MessageOriginUser) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*MessageOriginUser) UnmarshalJSON ¶ added in v0.2.0
func (s *MessageOriginUser) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type Middleware ¶
Middleware wraps a Handler, returning a new one. Middleware registered with Bot.Use runs for every handled update, outermost first.
func Logging ¶
func Logging() Middleware
Logging wraps a handler to log each handled update at debug level, and at warn level when the handler returns an error.
func Recover ¶
func Recover() Middleware
Recover wraps a handler so a panic is recovered, logged with its stack, and converted into an error instead of crashing the update loop.
func Timeout ¶
func Timeout(d time.Duration) Middleware
Timeout wraps a handler so its context is canceled after d.
type Options ¶
type Options struct {
// AppID and AppHash identify the MTProto application. Required: even bots
// need an app identity to connect to MTProto (obtain one at
// https://my.telegram.org). They are NOT the bot token.
AppID int
AppHash string
// Logger is the structured logger the bot writes to, via the
// github.com/gotd/log port. Defaults to a no-op logger. Wrap a *zap.Logger
// with github.com/gotd/log/logzap.New, or a *slog.Logger with logslog.New.
Logger log.Logger
// Device describes the client to Telegram. Optional.
Device telegram.DeviceConfig
// Storage persists session, peers and update state. Optional; in-memory if
// nil (nothing survives a restart).
Storage Storage
// OnStart is called once, after the bot is authorized and update gap
// recovery is live. Optional.
OnStart func(ctx context.Context)
// FloodWait enables transparent flood-wait handling: a request that hits a
// FLOOD_WAIT limit is retried after sleeping for the indicated duration,
// instead of failing with a 429 error. Off by default.
FloodWait bool
// MaxFloodWaitRetries bounds how many times a flood-waited request is retried
// when FloodWait is enabled. Zero uses the underlying library default.
MaxFloodWaitRetries int
// RequestsPerSecond, when greater than zero, proactively rate-limits outgoing
// MTProto requests to this many per second via a global token bucket. It is a
// coarse guard against hitting Telegram's limits; off by default.
RequestsPerSecond float64
// RequestBurst is the token-bucket burst size for RequestsPerSecond. Defaults
// to 1 when RequestsPerSecond is set.
RequestBurst int
// DisableCommandRegistration stops Run from publishing the commands
// registered via OnCommand to Telegram (SetMyCommands, default scope). By
// default the bot's command menu is kept in sync with its OnCommand handlers.
DisableCommandRegistration bool
// contains filtered or unexported fields
}
Options configures a Bot.
type OrderInfo ¶
type OrderInfo struct {
Name string `json:"name,omitempty"`
PhoneNumber string `json:"phone_number,omitempty"`
Email string `json:"email,omitempty"`
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
OrderInfo represents information about an order.
type ParseMode ¶
type ParseMode string
ParseMode is the formatting mode for message text and captions.
See https://core.telegram.org/bots/api#formatting-options.
const ( // ParseModeNone sends text without any entity parsing. ParseModeNone ParseMode = "" // ParseModeHTML parses a subset of HTML tags. ParseModeHTML ParseMode = "HTML" // ParseModeMarkdownV2 parses MarkdownV2-style formatting. ParseModeMarkdownV2 ParseMode = "MarkdownV2" // ParseModeMarkdown is the legacy Markdown mode; prefer ParseModeMarkdownV2. ParseModeMarkdown ParseMode = "Markdown" )
type PassportElementError ¶
type PassportElementError interface {
// contains filtered or unexported methods
}
PassportElementError is a sealed union describing one error in a Telegram Passport element. The user will not be able to resubmit the element until the error is resolved.
Concrete variants mirror the Bot API: *PassportElementErrorDataField, *PassportElementErrorFrontSide, *PassportElementErrorReverseSide, *PassportElementErrorSelfie, *PassportElementErrorFile, *PassportElementErrorFiles, *PassportElementErrorTranslationFile, *PassportElementErrorTranslationFiles, *PassportElementErrorUnspecified.
type PassportElementErrorDataField ¶
type PassportElementErrorDataField struct {
Type string `json:"type"`
FieldName string `json:"field_name"`
DataHash string `json:"data_hash"`
Message string `json:"message"`
}
PassportElementErrorDataField is an error in a data field.
type PassportElementErrorFile ¶
type PassportElementErrorFile struct {
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorFile is an error in a document scan.
type PassportElementErrorFiles ¶
type PassportElementErrorFiles struct {
Type string `json:"type"`
FileHashes []string `json:"file_hashes"`
Message string `json:"message"`
}
PassportElementErrorFiles is an error in a list of document scans.
type PassportElementErrorFrontSide ¶
type PassportElementErrorFrontSide struct {
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorFrontSide is an error in the document's front side.
type PassportElementErrorReverseSide ¶
type PassportElementErrorReverseSide struct {
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorReverseSide is an error in the document's reverse side.
type PassportElementErrorSelfie ¶
type PassportElementErrorSelfie struct {
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorSelfie is an error in the selfie with the document.
type PassportElementErrorTranslationFile ¶
type PassportElementErrorTranslationFile struct {
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorTranslationFile is an error in a translation scan.
type PassportElementErrorTranslationFiles ¶
type PassportElementErrorTranslationFiles struct {
Type string `json:"type"`
FileHashes []string `json:"file_hashes"`
Message string `json:"message"`
}
PassportElementErrorTranslationFiles is an error in a list of translation scans.
type PassportElementErrorUnspecified ¶
type PassportElementErrorUnspecified struct {
Type string `json:"type"`
ElementHash string `json:"element_hash"`
Message string `json:"message"`
}
PassportElementErrorUnspecified is an error in an unspecified place.
type PeerRef ¶ added in v0.2.0
type PeerRef struct {
Kind string `json:"kind"` // "user", "chat" or "channel"
ID int64 `json:"id"`
AccessHash int64 `json:"access_hash,omitempty"`
}
PeerRef is a serializable reference to a chat that carries its access hash.
Sending to a chat requires its MTProto access hash. The bot harvests and persists access hashes for peers it has seen, but addressing a chat after a restart otherwise depends on that stored peer data. A PeerRef captures the id and access hash in a self-contained, JSON-serializable form: persist it yourself (in a DB, a file, …) and, after a restart, send to it with Peer — directly from the reference, no re-resolution.
ref, _ := bot.PeerRef(ctx, botapi.ID(chatID)) // resolve once, capture the hash data, _ := json.Marshal(ref) // persist it // … restart … var ref botapi.PeerRef _ = json.Unmarshal(data, &ref) bot.SendMessage(ctx, botapi.Peer(ref), "still works")
type PhotoSize ¶
type PhotoSize struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
FileSize int `json:"file_size,omitempty"`
}
PhotoSize represents one size of a photo or a file/sticker thumbnail.
func (PhotoSize) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*PhotoSize) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Poll ¶
type Poll struct {
ID string `json:"id"`
Question string `json:"question"`
Options []PollOption `json:"options"`
TotalVoterCount int `json:"total_voter_count"`
IsClosed bool `json:"is_closed,omitempty"`
IsAnonymous bool `json:"is_anonymous,omitempty"`
Type PollType `json:"type"`
AllowsMultipleAnswers bool `json:"allows_multiple_answers,omitempty"`
CorrectOptionID int `json:"correct_option_id,omitempty"`
Explanation string `json:"explanation,omitempty"`
ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
OpenPeriod int `json:"open_period,omitempty"`
}
Poll represents a poll.
func (Poll) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Poll) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type PollAnswer ¶
type PollAnswer struct {
PollID string `json:"poll_id"`
VoterChat *Chat `json:"voter_chat,omitempty"`
User *User `json:"user,omitempty"`
OptionIDs []int `json:"option_ids"`
}
PollAnswer represents a change of a user's answer in a non-anonymous poll.
type PollOption ¶
PollOption represents one answer option in a poll.
func (*PollOption) Decode ¶ added in v0.2.0
func (s *PollOption) Decode(d *jx.Decoder) error
Decode parses the poll option from a JSON object.
func (*PollOption) Encode ¶ added in v0.2.0
func (s *PollOption) Encode(e *jx.Encoder)
Encode writes the poll option as a JSON object.
func (PollOption) MarshalJSON ¶ added in v0.2.0
func (s PollOption) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*PollOption) UnmarshalJSON ¶ added in v0.2.0
func (s *PollOption) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
type PreCheckoutAnswerOption ¶
type PreCheckoutAnswerOption func(*preCheckoutAnswerConfig)
PreCheckoutAnswerOption configures an AnswerPreCheckoutQuery call.
func WithPreCheckoutError ¶
func WithPreCheckoutError(message string) PreCheckoutAnswerOption
WithPreCheckoutError sets the reason the checkout can't proceed (used when ok is false).
type PreCheckoutQuery ¶
type PreCheckoutQuery struct {
ID string `json:"id"`
From User `json:"from"`
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
ShippingOptionID string `json:"shipping_option_id,omitempty"`
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}
PreCheckoutQuery contains information about an incoming pre-checkout query.
type Predicate ¶
Predicate reports whether a Handler should run for an update. A Handler runs only if all of its predicates return true.
func CallbackData ¶
CallbackData matches a callback query whose data equals s.
func CallbackPrefix ¶
CallbackPrefix matches a callback query whose data starts with prefix.
func ChatTypeIs ¶
ChatTypeIs matches a message sent in a chat of the given type.
func Command ¶
Command matches a message whose first token is the given bot command (with or without a leading slash).
A command may be targeted at a specific bot with a trailing @username ("/start@my_bot"), as Telegram clients do in groups. An untargeted command always matches; a targeted one matches only when the @username is this bot's own — so the bot ignores commands aimed at other bots.
func Regex ¶
Regex matches a message whose text matches the pattern. It panics if the pattern does not compile (a programming error caught at registration).
func TextEquals ¶
TextEquals matches a message whose text equals s exactly.
type ReactionType ¶
type ReactionType interface {
// contains filtered or unexported methods
}
ReactionType is a sealed union of reaction kinds.
Concrete variants: ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid.
func CustomEmoji ¶
func CustomEmoji(id string) ReactionType
CustomEmoji builds a custom-emoji reaction.
type ReactionTypeCustomEmoji ¶
type ReactionTypeCustomEmoji struct {
Type ReactionTypeKind `json:"type"`
CustomEmojiID string `json:"custom_emoji_id"`
}
ReactionTypeCustomEmoji is a reaction with a custom emoji.
type ReactionTypeEmoji ¶
type ReactionTypeEmoji struct {
Type ReactionTypeKind `json:"type"`
Emoji string `json:"emoji"`
}
ReactionTypeEmoji is a reaction with a standard emoji.
type ReactionTypeKind ¶
type ReactionTypeKind string
ReactionTypeKind discriminates a ReactionType variant.
const ( ReactionEmoji ReactionTypeKind = "emoji" ReactionCustomEmoji ReactionTypeKind = "custom_emoji" ReactionPaid ReactionTypeKind = "paid" )
type ReactionTypePaid ¶
type ReactionTypePaid struct {
Type ReactionTypeKind `json:"type"`
}
ReactionTypePaid is a paid (star) reaction.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct {
Keyboard [][]KeyboardButton `json:"keyboard"`
IsPersistent bool `json:"is_persistent,omitempty"`
ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardMarkup is a custom keyboard with reply options.
func Keyboard ¶
func Keyboard(rows ...[]KeyboardButton) *ReplyKeyboardMarkup
Keyboard builds a reply keyboard from rows of buttons.
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct {
// RemoveKeyboard is always true; the type itself signals removal.
RemoveKeyboard bool `json:"remove_keyboard"`
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardRemove removes the current custom keyboard.
func RemoveKeyboard ¶
func RemoveKeyboard() *ReplyKeyboardRemove
RemoveKeyboard builds a ReplyKeyboardRemove.
type ReplyMarkup ¶
type ReplyMarkup interface {
// contains filtered or unexported methods
}
ReplyMarkup is a sealed union of the markup objects a message can carry. The unexported marker method makes the set closed: only the types in this package can satisfy it, so a type switch over a ReplyMarkup is exhaustive.
Concrete variants: *InlineKeyboardMarkup, *ReplyKeyboardMarkup, *ReplyKeyboardRemove, *ForceReply.
type ResponseParameters ¶
type ResponseParameters struct {
// MigrateToChatID is the new chat identifier when the group was migrated to a
// supergroup. Zero when not applicable.
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
// RetryAfter is the number of seconds to wait before repeating the request
// when a flood-wait limit was hit. Zero when not applicable.
RetryAfter int `json:"retry_after,omitempty"`
}
ResponseParameters describes why a request failed and how to recover, mirroring the Bot API "ResponseParameters" object.
type SendOption ¶
type SendOption func(*sendConfig)
SendOption configures an outgoing send. Options are shared across the send methods; pass any combination.
func DisableWebPagePreview ¶
func DisableWebPagePreview() SendOption
DisableWebPagePreview disables the link preview for messages with links.
func ProtectContent ¶
func ProtectContent() SendOption
ProtectContent prevents the message content from being forwarded or saved.
func ReplyTo ¶
func ReplyTo(messageID int) SendOption
ReplyTo makes the message a reply to the message with the given id.
func WithParseMode ¶
func WithParseMode(m ParseMode) SendOption
WithParseMode selects the formatting mode for the text or caption.
func WithReplyMarkup ¶
func WithReplyMarkup(m ReplyMarkup) SendOption
WithReplyMarkup attaches an inline/reply keyboard (or removes one).
type SetGameScoreOption ¶
type SetGameScoreOption func(*gameScoreConfig)
SetGameScoreOption configures a SetGameScore call.
func WithForceScore ¶
func WithForceScore() SetGameScoreOption
WithForceScore updates the score even if it is lower than the user's current best.
func WithoutEditMessage ¶
func WithoutEditMessage() SetGameScoreOption
WithoutEditMessage leaves the game message unchanged instead of updating it with the new score.
type ShippingAddress ¶
type ShippingAddress struct {
CountryCode string `json:"country_code"`
State string `json:"state"`
City string `json:"city"`
StreetLine1 string `json:"street_line1"`
StreetLine2 string `json:"street_line2"`
PostCode string `json:"post_code"`
}
ShippingAddress represents a shipping address.
type ShippingAnswerOption ¶
type ShippingAnswerOption func(*shippingAnswerConfig)
ShippingAnswerOption configures an AnswerShippingQuery call.
func WithShippingError ¶
func WithShippingError(message string) ShippingAnswerOption
WithShippingError sets the human-readable reason shipping is impossible (used when ok is false).
func WithShippingOptions ¶
func WithShippingOptions(options ...ShippingOption) ShippingAnswerOption
WithShippingOptions sets the available shipping options (required when ok).
type ShippingOption ¶
type ShippingOption struct {
ID string `json:"id"`
Title string `json:"title"`
Prices []LabeledPrice `json:"prices"`
}
ShippingOption represents one shipping option.
type ShippingQuery ¶
type ShippingQuery struct {
ID string `json:"id"`
From User `json:"from"`
InvoicePayload string `json:"invoice_payload"`
ShippingAddress ShippingAddress `json:"shipping_address"`
}
ShippingQuery contains information about an incoming shipping query.
type Sticker ¶
type Sticker struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Type StickerType `json:"type"`
Width int `json:"width"`
Height int `json:"height"`
IsAnimated bool `json:"is_animated,omitempty"`
IsVideo bool `json:"is_video,omitempty"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
Emoji string `json:"emoji,omitempty"`
SetName string `json:"set_name,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Sticker represents a sticker.
func (Sticker) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Sticker) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type StickerFormat ¶
type StickerFormat string
StickerFormat is the format of a sticker file.
const ( // StickerFormatStatic is a static .WEBP or .PNG sticker. StickerFormatStatic StickerFormat = "static" // StickerFormatAnimated is an animated .TGS sticker. StickerFormatAnimated StickerFormat = "animated" // StickerFormatVideo is a video .WEBM sticker. StickerFormatVideo StickerFormat = "video" )
type StickerSet ¶
type StickerSet struct {
Name string `json:"name"`
Title string `json:"title"`
StickerType StickerType `json:"sticker_type"`
Stickers []Sticker `json:"stickers"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
}
StickerSet represents a set of stickers.
type StickerSetOption ¶
type StickerSetOption func(*stickerSetConfig)
StickerSetOption configures CreateNewStickerSet.
func WithMaskStickers ¶
func WithMaskStickers() StickerSetOption
WithMaskStickers marks the new set as a set of mask stickers.
type StickerType ¶
type StickerType string
StickerType is the kind of a sticker (or sticker set).
const ( StickerRegular StickerType = "regular" StickerMask StickerType = "mask" StickerCustomEmoji StickerType = "custom_emoji" )
type Storage ¶
type Storage interface {
telegram.SessionStorage
peers.Storage
peers.Cache
updates.StateStorage
}
Storage persists everything a bot needs across restarts: the MTProto session, peer access hashes and peer cache, and the update gap state.
A single implementation must satisfy all of these; storage.BBoltStorage does. When Options.Storage is nil the bot keeps all of this in memory.
type Update ¶
type Update struct {
UpdateID int `json:"update_id"`
Message *Message `json:"message,omitempty"`
EditedMessage *Message `json:"edited_message,omitempty"`
ChannelPost *Message `json:"channel_post,omitempty"`
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
InlineQuery *InlineQuery `json:"inline_query,omitempty"`
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
Poll *Poll `json:"poll,omitempty"`
PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
// contains filtered or unexported fields
}
Update represents one incoming update. At most one of the optional fields is present in any given update.
func (*Update) EffectiveMessage ¶
EffectiveMessage returns the message carried by the update, regardless of whether it is a new/edited message or channel post. It is nil for updates that carry no message (e.g. callback or inline queries).
type User ¶
type User struct {
ID int64 `json:"id"`
IsBot bool `json:"is_bot,omitempty"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Username string `json:"username,omitempty"`
LanguageCode string `json:"language_code,omitempty"`
IsPremium bool `json:"is_premium,omitempty"`
AddedToAttachmentMenu bool `json:"added_to_attachment_menu,omitempty"`
CanJoinGroups bool `json:"can_join_groups,omitempty"`
CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
}
User represents a Telegram user or bot.
func (User) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*User) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type UserProfilePhotos ¶
type UserProfilePhotos struct {
TotalCount int `json:"total_count"`
Photos [][]PhotoSize `json:"photos"`
}
UserProfilePhotos represents a user's profile pictures.
type Venue ¶
type Venue struct {
Location Location `json:"location"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
}
Venue represents a venue.
func (Venue) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Venue) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Video ¶
type Video struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Video represents a video file.
func (Video) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Video) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type VideoNote ¶
type VideoNote struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Length int `json:"length"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
VideoNote represents a rounded, square video message.
func (VideoNote) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*VideoNote) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type Voice ¶
type Voice struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
MIMEType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Voice represents a voice note.
func (Voice) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler via jx.
func (*Voice) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler via jx.
type WebAppInfo ¶
type WebAppInfo struct {
URL string `json:"url"`
}
WebAppInfo describes a Web App to be opened from a button.
func (*WebAppInfo) Decode ¶ added in v0.2.0
func (s *WebAppInfo) Decode(d *jx.Decoder) error
Decode parses the web app info from a JSON object.
func (*WebAppInfo) Encode ¶ added in v0.2.0
func (s *WebAppInfo) Encode(e *jx.Encoder)
Encode writes the web app info as a JSON object.
func (WebAppInfo) MarshalJSON ¶ added in v0.2.0
func (s WebAppInfo) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler via jx.
func (*WebAppInfo) UnmarshalJSON ¶ added in v0.2.0
func (s *WebAppInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler via jx.
Source Files
¶
- answer.go
- bot.go
- chat_admin.go
- chat_info.go
- chat_member.go
- chat_member_methods.go
- chat_permissions.go
- chat_photo.go
- codec.go
- codec_markup.go
- codec_media.go
- codec_message.go
- codec_misc.go
- codec_origin.go
- codec_user_chat.go
- commands.go
- context.go
- convert.go
- convert_media.go
- convert_member.go
- copy.go
- doc.go
- edit.go
- edit_media.go
- entities.go
- enums.go
- errors.go
- errors_map.go
- file.go
- forward_delete.go
- games.go
- group.go
- handler.go
- inline_query_result.go
- input_media.go
- input_message_content.go
- invite_links.go
- live_location.go
- markup.go
- markup_to_tg.go
- media.go
- media_group.go
- media_typed.go
- message_origin.go
- middleware.go
- on.go
- options.go
- passport.go
- payments.go
- peerref.go
- poll.go
- predicates.go
- ratelimit.go
- resolve.go
- rich.go
- send.go
- send_action.go
- send_invoice.go
- send_other.go
- sticker.go
- sticker_set.go
- styled.go
- types_media.go
- types_message.go
- types_payment.go
- types_query.go
- types_user_chat.go
- unions.go
- update.go
- updates_map.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
botdoc
command
Command botdoc fetches the published Telegram Bot API documentation and inspects the structured types and methods extracted from it.
|
Command botdoc fetches the published Telegram Bot API documentation and inspects the structured types and methods extracted from it. |
|
examples
|
|
|
advanced
command
Command advanced is a full-featured demo bot that exercises most of the github.com/gotd/botapi surface: commands (auto-registered), formatting, inline and reply keyboards, callback queries, inline mode, the media send methods, incoming-media handling, editing, forwarding, chat actions, polls, dice, location/venue/contact and the predicate/middleware framework.
|
Command advanced is a full-featured demo bot that exercises most of the github.com/gotd/botapi surface: commands (auto-registered), formatting, inline and reply keyboards, callback queries, inline mode, the media send methods, incoming-media handling, editing, forwarding, chat actions, polls, dice, location/venue/contact and the predicate/middleware framework. |
|
background
command
Command background demonstrates proactive, restart-surviving sends with github.com/gotd/botapi: messages that are NOT replies to an incoming update.
|
Command background demonstrates proactive, restart-surviving sends with github.com/gotd/botapi: messages that are NOT replies to an incoming update. |
|
buttons
command
Command buttons is a bot built on github.com/gotd/botapi that demonstrates inline keyboards and callback queries: /menu shows a keyboard, and tapping a button answers the callback and edits the message.
|
Command buttons is a bot built on github.com/gotd/botapi that demonstrates inline keyboards and callback queries: /menu shows a keyboard, and tapping a button answers the callback and edits the message. |
|
echo
command
Command echo is a minimal bot built on github.com/gotd/botapi: it greets on /start and echoes any other text message back as a reply.
|
Command echo is a minimal bot built on github.com/gotd/botapi: it greets on /start and echoes any other text message back as a reply. |
|
inline
command
Command inline is an inline bot built on github.com/gotd/botapi.
|
Command inline is an inline bot built on github.com/gotd/botapi. |
|
media
command
Command media is a bot built on github.com/gotd/botapi that demonstrates sending and receiving media:
|
Command media is a bot built on github.com/gotd/botapi that demonstrates sending and receiving media: |
|
rich
command
Command rich is a showcase of Telegram rich messages (Bot API 10.1) built with github.com/gotd/td/telegram/message/rich.
|
Command rich is a showcase of Telegram rich messages (Bot API 10.1) built with github.com/gotd/td/telegram/message/rich. |
|
internal
|
|
|
botdoc
Package botdoc implement types definition extraction from documentation.
|
Package botdoc implement types definition extraction from documentation. |
|
Package pool runs and multiplexes many bots by token over a single process, lazily starting a Bot per token and garbage-collecting idle ones.
|
Package pool runs and multiplexes many bots by token over a single process, lazily starting a Bot per token and garbage-collecting idle ones. |
|
Package storage contains gotd/td storage implementations for Telegram bots (session, peers and updates state), backed by bbolt.
|
Package storage contains gotd/td storage implementations for Telegram bots (session, peers and updates state), backed by bbolt. |