tgot

package module
v0.0.0-...-ca9d3f5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 8 Imported by: 0

README

tgot

tgot is a concurrent Telegram Bot API library written in Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSpecified = errors.New("handler is not specified")

ErrNotSpecified is returned by Handle if the update contains an object not specified in Handler.

Functions

func OnErrorDefault

func OnErrorDefault(c Context, result any, err error) error

OnErrorDefault represents default error handler.

It:

- panics if the JSON response cannot be parsed;

- panics if the method is not found;

- cancels the current call (using runtime.Goexit) and changes the state of the bot to an error if 401 (Not Authorized) or or 500 (Internal Server Error) status is returned;

- returns the err in any other case.

Types

type Animation

type Animation struct {
	Animation tg.Inputtable
	Thumbnail tg.Inputtable
	CaptionData
	Duration    int
	Width       int
	Height      int
	HasSpoiler  bool
	ReplyMarkup tg.ReplyMarkup
}

Animation contains information about the animation to be sent.

type Audio

type Audio struct {
	Audio     tg.Inputtable
	Thumbnail tg.Inputtable
	CaptionData
	Duration    int
	Performer   string
	Title       string
	ReplyMarkup tg.ReplyMarkup
}

Audio contains information about the audio to be sent.

type Ban

type Ban struct {
	UserID         int64
	UntilDate      *int64
	RevokeMessages bool
}

Ban contains parameters for banning a chat member.

type BaseContext

type BaseContext[c baseContext] interface {
	Child(string) c
	// contains filtered or unexported methods
}

BaseContext can infer any context type.

type Bot

type Bot struct {

	// OnError is called when an error occurs while method execution with context.
	// The returned error will be returned to the method caller.
	// If this function is nil, OnErrorDefault is used.
	OnError func(c Context, result any, err error) error

	Handler
	// contains filtered or unexported fields
}

Bot type.

func New

func New(api *api.API) (*Bot, error)

New creates new bot.

func NewWithToken

func NewWithToken(token string) (*Bot, error)

NewWithToken creates new bit with specified token and default http client.

func (*Bot) API

func (b *Bot) API() *api.API

API returns api object.

func (*Bot) Close

func (b *Bot) Close() error

Close method.

Use this method to close the bot instance before moving it from one local server to another.

func (*Bot) DeleteCommands

func (b *Bot) DeleteCommands(s tg.CommandScope, lang string) error

DeleteCommands deletes the list of the bot's commands for the given scope and user language.

func (*Bot) DeleteWebhook

func (b *Bot) DeleteWebhook(dropPending bool) (bool, error)

DeleteWebhook removes webhook integration if you decide to switch back to getUpdates.

func (*Bot) Err

func (b *Bot) Err() error

Err returns bot error.

func (*Bot) GetCommands

func (b *Bot) GetCommands(s tg.CommandScope, lang string) ([]tg.Command, error)

GetCommands returns the current list of the bot's commands for the given scope and user language.

func (*Bot) GetDefaultAdminRights

func (b *Bot) GetDefaultAdminRights(forChannels bool) (*tg.ChatAdministratorRights, error)

GetDefaultAdminRights returns the current default administrator rights of the bot.

func (*Bot) GetDefaultChatMenuButton

func (b *Bot) GetDefaultChatMenuButton() (*tg.MenuButton, error)

GetDefaultChatMenuButton returns the current value of the bot's default menu button.

This method is a wrapper for getChatMenuButton without specifying the chat id.

func (*Bot) GetDescription

func (b *Bot) GetDescription(lang string) (*tg.BotDescription, error)

GetDescription returns the current bot description for the given user language.

func (*Bot) GetMe

func (b *Bot) GetMe() (*tg.User, error)

GetMe returns basic information about the bot in form of a User object.

func (*Bot) GetName

func (b *Bot) GetName(lang string) (*tg.BotName, error)

GetName returns the current bot name for the given user language.

func (*Bot) GetShortDescription

func (b *Bot) GetShortDescription(lang string) (*tg.BotShortDescription, error)

GetShortDescription returns the current bot short description for the given user language.

func (*Bot) GetUpdates

func (b *Bot) GetUpdates(ctx context.Context, p GetUpdates) ([]tg.Update, error)

GetUpdates receives incoming updates using long polling.

func (*Bot) GetWebhookInfo

func (b *Bot) GetWebhookInfo() (*tg.WebhookInfo, error)

GetWebhookInfo returns current webhook status.

func (*Bot) Handle

func (b *Bot) Handle(upd *tg.Update) error

Handle routes the update to the matching handler.

func (*Bot) LogOut

func (b *Bot) LogOut() error

LogOut method.

Use this method to log out from the cloud Bot API server before launching the bot locally.

func (*Bot) MakeContext

func (b *Bot) MakeContext(name string) Context

MakeContext creates new context.

The context must be used in a separate goroutine because in case of fatal errors the bot will be closed and the goroutine will be terminated.

func (*Bot) Me

func (b *Bot) Me() tg.User

Me returns current bot as tg.User.

func (*Bot) SetCommands

func (b *Bot) SetCommands(cd *CommandsData) error

SetCommands changes the list of the bot's commands.

func (*Bot) SetDefaultAdminRights

func (b *Bot) SetDefaultAdminRights(rights *tg.ChatAdministratorRights, forChannels bool) error

SetDefaultAdminRights changes the default administrator rights requested by the bot when it's added as an administrator to groups or channels.

func (*Bot) SetDefaultChatMenuButton

func (b *Bot) SetDefaultChatMenuButton(menu tg.MenuButton) error

SetDefaultChatMenuButton changes the bot's default menu button.

This method is a wrapper for setChatMenuButton without specifying the chat id.

func (*Bot) SetDescription

func (b *Bot) SetDescription(description, lang string) error

SetDescription changes the bot's description, which is shown in the chat with the bot if the chat is empty.

func (*Bot) SetError

func (b *Bot) SetError(err error)

SetError changes the state of the bot to an error. It does nothing if the bot is already in an error state. The error state prevents any updates handling.

func (*Bot) SetName

func (b *Bot) SetName(name, lang string) error

SetName changes the bot's name.

func (*Bot) SetShortDescription

func (b *Bot) SetShortDescription(shortDescription, lang string) error

SetShortDescription changes the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.

func (*Bot) SetWebhook

func (b *Bot) SetWebhook(s WebhookData) (bool, error)

SetWebhook specifies a webhook URL. Use this method to specify a URL and receive incoming updates via an outgoing webhook.

type CallbackAnswer

type CallbackAnswer struct {
	Text      string
	ShowAlert bool
	URL       string
	CacheTime int
}

CallbackAnswer represents an answer to callback query.

type CallbackContext

type CallbackContext = QueryContext[CallbackAnswer]

CallbackContext type.

type CaptionData

type CaptionData struct {
	Caption   string
	ParseMode tg.ParseMode
	Entities  []tg.MessageEntity
}

CaptionData represents caption with entities and parse mode.

type Chat

type Chat struct {
	ID       int64
	Username string
}

Chat represents chat id or channel username.

func ChatID

func ChatID(id int64) Chat

ChatID makes Chat from chat id.

func Username

func Username(username string) Chat

Username makes Chat from channel username.

type ChatContext

type ChatContext struct {
	Context
	// contains filtered or unexported fields
}

ChatContext provides chat API.

func (ChatContext) ApproveJoinRequest

func (c ChatContext) ApproveJoinRequest(userID int64) error

ApproveJoinRequest approves a chat join request.

func (ChatContext) Ban

func (c ChatContext) Ban(b Ban) error

Ban bans a user in a group, a supergroup or a channel.

func (ChatContext) BanSenderChat

func (c ChatContext) BanSenderChat(senderID int64) error

BanSenderChat bans a channel chat in a supergroup or a channel.

func (ChatContext) Child

func (c ChatContext) Child(name string) ChatContext

Child creates sub context.

func (ChatContext) CloseForumTopic

func (c ChatContext) CloseForumTopic(threadID int) error

CloseForumTopic closes an open topic in a forum supergroup chat.

func (ChatContext) CloseGeneralForumTopic

func (c ChatContext) CloseGeneralForumTopic() error

CloseGeneralForumTopic closes an open 'General' topic in a forum supergroup chat.

func (ChatContext) Copy

func (c ChatContext) Copy(from Chat, cp Copy, opts ...SendOptions) (*tg.MessageID, error)

Copy copies messages of any kind. Service messages and invoice messages can't be copied.

func (ChatContext) CreateForumTopic

func (c ChatContext) CreateForumTopic(name string, iconColor int, iconEmojiID string) (*tg.ForumTopic, error)

CreateForumTopic creates a topic in a forum supergroup chat.

func (c ChatContext) CreateInviteLink(i InviteLink) (*tg.ChatInviteLink, error)

CreateInviteLink creates an additional invite link for a chat.

func (ChatContext) DeclineJoinRequest

func (c ChatContext) DeclineJoinRequest(userID int64) error

DeclineJoinRequest declines a chat join request.

func (ChatContext) DeleteForumTopic

func (c ChatContext) DeleteForumTopic(threadID int) error

DeleteForumTopic deletes a forum topic along with all its messages in a forum supergroup chat.

func (ChatContext) DeleteMessage

func (c ChatContext) DeleteMessage(msgID int) error

DeleteMessage deletes a message, including service messages.

func (ChatContext) DeletePhoto

func (c ChatContext) DeletePhoto() error

DeletePhoto deletes a chat photo.

func (ChatContext) DeleteStickerSet

func (c ChatContext) DeleteStickerSet() error

DeleteStickerSet deletes a group sticker set from a supergroup.

func (ChatContext) EditForumTopic

func (c ChatContext) EditForumTopic(threadID int, name, iconEmojiID string) error

EditForumTopic edits name and icon of a topic in a forum supergroup chat.

func (ChatContext) EditGeneralForumTopic

func (c ChatContext) EditGeneralForumTopic(name string) error

EditGeneralForumTopic edits the name of the 'General' topic in a forum supergroup chat.

func (c ChatContext) EditInviteLink(link string, i InviteLink) (*tg.ChatInviteLink, error)

EditInviteLink edits a non-primary invite link created by the bot.

func (c ChatContext) ExportInviteLink() (string, error)

ExportInviteLink generates a new primary invite link for a chat; any previously generated primary link is revoked.

func (ChatContext) Forward

func (c ChatContext) Forward(from Chat, fwd Forward) (*tg.Message, error)

Forward forwards messages of any kind. Service messages can't be forwarded.

func (ChatContext) GetAdmins

func (c ChatContext) GetAdmins() ([]tg.ChatMember, error)

GetAdmins returns a list of administrators in a chat.

func (ChatContext) GetInfo

func (c ChatContext) GetInfo() (*tg.Chat, error)

GetInfo returns up to date information about the chat.

func (ChatContext) GetMember

func (c ChatContext) GetMember(userID int64) (*tg.ChatMember, error)

GetMember returns information about a member of a chat.

func (ChatContext) GetMenuButton

func (c ChatContext) GetMenuButton() (*tg.MenuButton, error)

GetMenuButton returns the current value of the bot's menu button in a private chat.

func (ChatContext) HideGeneralForumTopic

func (c ChatContext) HideGeneralForumTopic() error

HideGeneralForumTopic hides the 'General' topic in a forum supergroup chat.

func (ChatContext) Leave

func (c ChatContext) Leave() error

Leave a group, supergroup or channel.

func (ChatContext) MemberCount

func (c ChatContext) MemberCount() (int, error)

MemberCount returns the number of members in a chat.

func (ChatContext) OpenForumTopic

func (c ChatContext) OpenForumTopic(threadID int) Topic

OpenForumTopic makes forum topic interface.

func (ChatContext) PinMessage

func (c ChatContext) PinMessage(msgID int, notify bool) error

PinMessage adds a message to the list of pinned messages in a chat.

func (ChatContext) Promote

func (c ChatContext) Promote(userID int64, rights tg.ChatAdministratorRights) error

Promote promotes or demotes a user in a supergroup or a channel.

func (ChatContext) ReopenForumTopic

func (c ChatContext) ReopenForumTopic(threadID int) error

ReopenForumTopic reopens a closed topic in a forum supergroup chat.

func (ChatContext) ReopenGeneralForumTopic

func (c ChatContext) ReopenGeneralForumTopic() error

ReopenGeneralForumTopic reopens a closed 'General' topic in a forum supergroup chat.

func (ChatContext) Reply

func (c ChatContext) Reply(to int, s Sendable) (*tg.Message, error)

Reply replies to the specified message.

func (ChatContext) ReplyE

func (c ChatContext) ReplyE(to int, s Sendable) error

ReplyE replies to the specified message and returns only an error.

func (ChatContext) Restrict

func (c ChatContext) Restrict(r RestrictChatMember) error

Restrict restricts a user in a supergroup.

func (c ChatContext) RevokeInviteLink(link string) (*tg.ChatInviteLink, error)

RevokeInviteLink revokes an invite link created by the bot.

func (ChatContext) Send

func (c ChatContext) Send(s Sendable, opts ...SendOptions) (*tg.Message, error)

Send sends any Sendable object.

func (ChatContext) SendChatAction

func (c ChatContext) SendChatAction(act tg.ChatAction) error

SendChatAction sends chat action to tell the user that something is happening on the bot's side.

func (ChatContext) SendE

func (c ChatContext) SendE(s Sendable, opts ...SendOptions) error

SendE sends the Sendable and returns only an error.

func (ChatContext) SendMediaGroup

func (c ChatContext) SendMediaGroup(mg MediaGroup, opts ...SendOptions) ([]tg.Message, error)

SendMediaGroup sends a group of photos, videos, documents or audios as an album.

func (ChatContext) SendText

func (c ChatContext) SendText(text string, pm ...tg.ParseMode) error

SendText sends just a text and returns only an error.

func (ChatContext) SetAdminTitle

func (c ChatContext) SetAdminTitle(userID int64, title string) error

SetAdminTitle sets a custom title for an administrator in a supergroup promoted by the bot.

func (ChatContext) SetDescription

func (c ChatContext) SetDescription(description string) error

SetDescription changes the description of a group, a supergroup or a channel.

func (ChatContext) SetMenuButton

func (c ChatContext) SetMenuButton(menu tg.MenuButton) error

SetMenuButton changes the bot's menu button in a private chat.

func (ChatContext) SetPermissions

func (c ChatContext) SetPermissions(perms tg.ChatPermissions, independentPerms ...bool) error

SetPermissions sets default chat permissions for all members.

func (ChatContext) SetPhoto

func (c ChatContext) SetPhoto(photo *tg.InputFile) error

SetPhoto sets a new profile photo for the chat.

func (ChatContext) SetStickerSet

func (c ChatContext) SetStickerSet(stickerSet string) error

SetStickerSet sets a new group sticker set for a supergroup.

func (ChatContext) SetTitle

func (c ChatContext) SetTitle(title string) error

SetTitle change the title of a chat.

func (ChatContext) StopPoll

func (c ChatContext) StopPoll(msgID int, replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Poll, error)

StopPoll stops a poll which was sent by the bot.

func (ChatContext) Unban

func (c ChatContext) Unban(userID int64, onlyIfBanned bool) error

Unban unbans a previously banned user in a supergroup or channel.

func (ChatContext) UnbanSenderChat

func (c ChatContext) UnbanSenderChat(senderID int64) error

UnbanSenderChat unbans a previously banned channel chat in a supergroup or channel.

func (ChatContext) UnhideGeneralForumTopic

func (c ChatContext) UnhideGeneralForumTopic() error

UnhideGeneralForumTopic unhides the 'General' topic in a forum supergroup chat.

func (ChatContext) UnpinAllMessages

func (c ChatContext) UnpinAllMessages() error

UnpinAllMessages clears the list of pinned messages in a chat.

func (ChatContext) UnpinMessage

func (c ChatContext) UnpinMessage(msgID int) error

UnpinMessage removes a message from the list of pinned messages in a chat.

type CommandsData

type CommandsData struct {
	Commands []tg.Command
	Scope    tg.CommandScope
	Lang     string
}

CommandsData contains parameters for setMyCommands method.

type Contact

type Contact struct {
	PhoneNumber string
	FirstName   string
	LastName    string
	Vcard       string
	ReplyMarkup tg.ReplyMarkup
}

Contact contains information about the contact to be sent.

type Context

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

Context type.

func (Context) AddSticker

func (c Context) AddSticker(sticker NewSticker) error

AddSticker adds a new sticker to a set created by the bot.

func (Context) Child

func (c Context) Child(name string) Context

Child creates sub context.

func (c Context) CreateInvoiceLink(l CreateInvoiceLink) (string, error)

CreateInvoiceLink creates a link for an invoice.

func (Context) CreateNewStickerSet

func (c Context) CreateNewStickerSet(newSet NewStickerSet) error

CreateNewStickerSet creates a new sticker set owned by a user.

func (Context) Ctx

func (c Context) Ctx() Context

Ctx returns Context.

func (Context) DeleteSticker

func (c Context) DeleteSticker(stickerFileID string) error

DeleteSticker deletes a sticker from a set created by the bot.

func (Context) DeleteStickerSet

func (c Context) DeleteStickerSet(setName string) error

DeleteStickerSet deletes a sticker set that was created by the bot.

func (Context) Download

func (c Context) Download(f *tg.File) ([]byte, error)

Download downloads file from Telegram servers.

func (Context) DownloadFile

func (c Context) DownloadFile(fid string) ([]byte, error)

DownloadFile downloads file from Telegram servers by file id.

func (Context) DownloadReader

func (c Context) DownloadReader(f *tg.File) (io.ReadCloser, error)

DownloadReader downloads file as io.ReadCloser from Telegram servers.

func (Context) DownloadReaderFile

func (c Context) DownloadReaderFile(fid string) (io.ReadCloser, error)

DownloadReaderFile downloads file as io.ReadCloser from Telegram servers by file id.

func (Context) GetCustomEmojiStickers

func (c Context) GetCustomEmojiStickers(ids ...string) ([]tg.Sticker, error)

GetCustomEmojiStickers returns information about custom emoji stickers by their identifiers.

func (Context) GetFile

func (c Context) GetFile(fileID string) (*tg.File, error)

GetFile returns basic information about a file and prepares it for downloading.

func (Context) GetForumTopicIconStickers

func (c Context) GetForumTopicIconStickers() ([]tg.Sticker, error)

GetForumTopicIconStickers returns custom emoji stickers, which can be used as a forum topic icon by any user.

func (Context) GetMe

func (c Context) GetMe() (*tg.User, error)

GetMe returns basic information about the bot.

func (Context) GetStickerSet

func (c Context) GetStickerSet(name string) (*tg.StickerSet, error)

GetStickerSet returns a sticker set.

func (Context) GetUserPhotos

func (c Context) GetUserPhotos(userID int64) (*tg.UserProfilePhotos, error)

GetUserPhotos returns a list of profile pictures for a user.

func (Context) Name

func (c Context) Name() string

Name returns context name.

func (Context) OpenChat

func (c Context) OpenChat(chatID Chat) ChatContext

OpenChat makes chat interface.

func (Context) OpenMessage

func (c Context) OpenMessage(sig MsgSignature) MessageContext

OpenMessage makes message interface.

func (Context) SetCustomEmojiStickerSetThumbnail

func (c Context) SetCustomEmojiStickerSetThumbnail(setName string, customEmojiID string) error

SetCustomEmojiStickerSetThumbnail sets the thumbnail of a custom emoji sticker set.

func (Context) SetStickerEmojiList

func (c Context) SetStickerEmojiList(stickerFileID string, emojiList []string) error

SetStickerEmojiList changes the list of emoji assigned to a regular or custom emoji sticker.

func (Context) SetStickerKeywords

func (c Context) SetStickerKeywords(stickerFileID string, keywords []string) error

SetStickerKeywords changes search keywords assigned to a regular or custom emoji sticker.

func (Context) SetStickerMaskPosition

func (c Context) SetStickerMaskPosition(stickerFileID string, maskPos tg.MaskPosition) error

SetStickerMaskPosition changes the mask position of a mask sticker.

func (Context) SetStickerPosition

func (c Context) SetStickerPosition(stickerFileID string, position int) error

SetStickerPosition moves a sticker in a set created by the bot to a specific position.

func (Context) SetStickerSetThumbnail

func (c Context) SetStickerSetThumbnail(setName string, userID int64, thumb tg.Inputtable) error

SetStickerSetThumbnail sets the thumbnail of a sticker set.

func (Context) SetStickerSetTitle

func (c Context) SetStickerSetTitle(setName string, title string) error

SetStickerSetTitle sets the title of a created sticker set.

func (Context) UploadStickerFile

func (c Context) UploadStickerFile(userID int64, sticker *tg.InputFile, format tg.StickerFormat) (*tg.File, error)

UploadStickerFile uploads a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods.

type Copy

type Copy struct {
	MessageID int
	CaptionData
	ReplyMarkup tg.ReplyMarkup
}

Copy contains parameters for copying the message.

type CreateInvoiceLink = tg.InputInvoiceMessageContent

CreateInvoiceLink contains parameters for creating an invoice link.

type Dice

type Dice struct {
	Emoji       tg.DiceEmoji
	ReplyMarkup tg.ReplyMarkup
}

Dice contains information about the dice to be sent.

type Document

type Document struct {
	Document  tg.Inputtable
	Thumbnail tg.Inputtable
	CaptionData
	DisableTypeDetection bool
	ReplyMarkup          tg.ReplyMarkup
}

Document contains information about the document to be sent.

type EditText

type EditText struct {
	Text                  string
	ParseMode             tg.ParseMode
	Entities              []tg.MessageEntity
	DisableWebPagePreview bool
}

EditText contains parameters for editing message text.

type Forward

type Forward struct {
	MessageID           int
	DisableNotification bool
	ProtectContent      bool
}

Forward contains paramenets for forwarding the message.

type Game

type Game struct {
	ShortName   string
	ReplyMarkup *tg.InlineKeyboardMarkup
}

Game contains information about the game to be sent.

type GetUpdates

type GetUpdates struct {
	Offset  int
	Limit   int
	Timeout int
	Allowed []string
}

GetUpdates contains parameters for getUpdates method.

type Handler

type Handler struct {
	OnMessage           func(ChatContext, *tg.Message)
	OnEditedMessage     func(ChatContext, *tg.Message)
	OnChannelPost       func(ChatContext, *tg.Message)
	OnEditedChannelPost func(ChatContext, *tg.Message)
	OnCallbackQuery     func(CallbackContext, *tg.CallbackQuery)
	OnInlineQuery       func(InlineContext, *tg.InlineQuery)
	OnInlineChosen      func(MessageContext, *tg.InlineChosen)
	OnShippingQuery     func(ShippingContext, *tg.ShippingQuery)
	OnPreCheckoutQuery  func(PreCheckoutContext, *tg.PreCheckoutQuery)
	OnPoll              func(Context, *tg.Poll)
	OnPollAnswer        func(Context, *tg.PollAnswer)
	OnMyChatMember      func(ChatContext, *tg.ChatMemberUpdated)
	OnChatMember        func(ChatContext, *tg.ChatMemberUpdated)
	OnChatJoinRequest   func(ChatContext, *tg.ChatJoinRequest)
}

Handler contains all available updates handler functions.

func (*Handler) Allowed

func (h *Handler) Allowed() []string

Allowed returns list of allowed updates. If there is any change in the handler, this function must be called to get a new list, otherwise it may cause a panic.

type InlineAnswer

type InlineAnswer struct {
	Results    []tg.InlineQueryResulter
	CacheTime  *int
	IsPersonal bool
	NextOffset string
	Button     *tg.InlineQueryResultsButton
}

InlineAnswer represents an answer to inline query.

type InlineContext

type InlineContext = QueryContext[InlineAnswer]

InlineContext type.

type InviteLink struct {
	Name               string
	ExpireDate         int64
	MemberLimit        int
	CreatesJoinRequest bool
}

InviteLink contains parameters for manipulations with invite links.

type Invoice

type Invoice struct {
	Title                     string
	Description               string
	Payload                   string
	ProviderToken             string
	Currency                  string
	Prices                    []tg.LabeledPrice
	MaxTipAmount              int
	SuggestedTipAmounts       []int
	ProviderData              string
	PhotoURL                  string
	PhotoSize                 int
	PhotoWidth                int
	PhotoHeight               int
	NeedName                  bool
	NeedPhoneNumber           bool
	NeedEmail                 bool
	NeedShippingAddress       bool
	SendPhoneNumberToProvider bool
	SendEmailToProvider       bool
	IsFlexible                bool
	StartParameter            string
	ReplyMarkup               *tg.InlineKeyboardMarkup
}

Invoice contains information about the invoice to be sent.

type LiveLocation

type LiveLocation struct {
	Long               float32
	Lat                float32
	HorizontalAccuracy *float32
	Heading            int
	AlertRadius        int
}

LiveLocation contains parameters for editing the live location.

type Location

type Location struct {
	tg.Location
	ReplyMarkup tg.ReplyMarkup
}

Location contains information about the location to be sent.

type MediaGroup

type MediaGroup struct {
	Media       []tg.MediaInputter
	ReplyMarkup *tg.InlineKeyboardMarkup
}

MediaGroup contains information about the media group to be sent.

type Message

type Message struct {
	Text                  string
	ParseMode             tg.ParseMode
	Entities              []tg.MessageEntity
	DisableWebPagePreview bool
	ReplyMarkup           tg.ReplyMarkup
}

Message contains information about the message to be sent.

func NewMessage

func NewMessage(text string) Message

NewMessage makes a new message.

type MessageContext

type MessageContext struct {
	Context
	// contains filtered or unexported fields
}

MessageContext provides api for any message.

For inline messages the result message will always be nil.

func (MessageContext) EditCaption

func (c MessageContext) EditCaption(cap CaptionData, replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Message, error)

EditCaption edits captions of messages.

func (MessageContext) EditLiveLocation

func (c MessageContext) EditLiveLocation(l LiveLocation, replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Message, error)

EditLiveLocation edits live location messages.

func (MessageContext) EditMedia

func (c MessageContext) EditMedia(m tg.MediaInputter, replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Message, error)

EditMedia edits animation, audio, document, photo, or video messages.

func (MessageContext) EditReplyMarkup

func (c MessageContext) EditReplyMarkup(replyMarkup *tg.InlineKeyboardMarkup) (*tg.Message, error)

EditReplyMarkup edits only the reply markup of messages.

func (MessageContext) EditText

func (c MessageContext) EditText(t EditText, replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Message, error)

EditText edits text and game messages.

func (MessageContext) GetGameHighScores

func (c MessageContext) GetGameHighScores(userID int64) ([]tg.GameHighScore, error)

GetGameHighScores returns data for high score tables.

func (MessageContext) SetGameScore

func (c MessageContext) SetGameScore(userID int64, s SetGameScore) (*tg.Message, error)

SetGameScore sets the score of the specified user in a game message.

func (MessageContext) StopLiveLocation

func (c MessageContext) StopLiveLocation(replyMarkup ...tg.InlineKeyboardMarkup) (*tg.Message, error)

StopLiveLocation stops updating a live location message before live_period expires.

type MsgSignature

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

MsgSignature contains inline message id or chat id with message id.

func CallbackSignature

func CallbackSignature(q *tg.CallbackQuery) MsgSignature

CallbackSignature creates a MessageSignature of any callback message type.

func InlineSignature

func InlineSignature(i *tg.InlineChosen) MsgSignature

InlineSignature creates an inline message signature.

func MessageSignature

func MessageSignature(msg *tg.Message) MsgSignature

MessageSignature creates a chat message signature.

type NewSticker

type NewSticker struct {
	UserID  int64
	SetName string
	Sticker tg.InputSticker
}

NewSticker contains parameters for adding a sticker to a set.

type NewStickerSet

type NewStickerSet struct {
	UserID          int64
	Name            string
	Title           string
	Stickers        []tg.InputSticker
	Format          tg.StickerFormat
	Type            tg.StickerType
	NeedsRepainting bool
}

NewStickerSet contains parameters for creating a sticker set.

type Photo

type Photo struct {
	Photo tg.Inputtable
	CaptionData
	HasSpoiler  bool
	ReplyMarkup tg.ReplyMarkup
}

Photo contains information about the photo to be sent.

func NewPhoto

func NewPhoto(photo tg.Inputtable) Photo

NewPhoto makes a new photo.

type Poll

type Poll struct {
	Question             string
	Options              []string
	IsAnonymous          bool
	Type                 tg.PollType
	MultipleAnswers      bool
	CorrectOption        int
	Explanation          string
	ExplanationParseMode tg.ParseMode
	ExplanationEntities  []tg.MessageEntity
	OpenPeriod           int
	CloseDate            int64
	IsClosed             bool
	ReplyMarkup          tg.ReplyMarkup
}

Poll contains information about the poll to be sent.

type PreCheckoutAnswer

type PreCheckoutAnswer struct {
	OK           bool
	ErrorMessage string
}

PreCheckoutAnswer represents an answer to pre-checkout query.

type PreCheckoutContext

type PreCheckoutContext = QueryContext[PreCheckoutAnswer]

PreCheckoutContext type.

type QueryContext

type QueryContext[T answerable] struct {
	Context
	// contains filtered or unexported fields
}

QueryContext is the common context for all queries that require an answer.

func (QueryContext[T]) Answer

func (c QueryContext[T]) Answer(answer T) (err error)

func (QueryContext[T]) Child

func (c QueryContext[T]) Child(name string) QueryContext[T]

type RestrictChatMember

type RestrictChatMember struct {
	UserID                 int64
	Permissions            tg.ChatPermissions
	IndependentPermissions bool
	Until                  int64
}

RestrictChatMember contains parameters for restrictChatMember method.

type SendOptions

type SendOptions struct {
	DisableNotification      bool
	ProtectContent           bool
	ReplyTo                  int
	AllowSendingWithoutReply bool
}

SendOptions cointains common send* parameters.

type Sendable

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

Sendable interface for Chat.Send.

type SetGameScore

type SetGameScore struct {
	Score       int
	Force       bool
	DisableEdit bool
}

SetGameScore contains parameters for setting the game score.

type ShippingAnswer

type ShippingAnswer struct {
	OK              bool
	ShippingOptions []tg.ShippingOption
	ErrorMessage    string
}

ShippingAnswer represents an answer to shipping query.

type ShippingContext

type ShippingContext = QueryContext[ShippingAnswer]

ShippingContext type.

type Sticker

type Sticker struct {
	Sticker     tg.Inputtable
	Emoji       string
	ReplyMarkup tg.ReplyMarkup
}

Sticker contains information about the sticker to be sent.

type Topic

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

Topic provides forum topics api.

func (Topic) Copy

func (t Topic) Copy(from Chat, cp Copy, opts ...SendOptions) (*tg.MessageID, error)

Copy copies messages of any kind. Service messages and invoice messages can't be copied.

func (Topic) Forward

func (t Topic) Forward(from Chat, fwd Forward) (*tg.Message, error)

Forward forwards messages of any kind. Service messages can't be forwarded.

func (Topic) Send

func (t Topic) Send(s Sendable, opts ...SendOptions) (*tg.Message, error)

Send sends any Sendable object.

func (Topic) SendChatAction

func (t Topic) SendChatAction(act tg.ChatAction) error

SendChatAction sends chat action to tell the user that something is happening on the bot's side.

func (Topic) SendMediaGroup

func (t Topic) SendMediaGroup(mg MediaGroup, opts ...SendOptions) ([]tg.Message, error)

SendMediaGroup sends a group of photos, videos, documents or audios as an album.

func (Topic) UnpinAllMessages

func (t Topic) UnpinAllMessages() error

UnpinAllMessages clears the list of pinned messages in a forum topic.

type Venue

type Venue struct {
	Lat             float32
	Long            float32
	Title           string
	Address         string
	FoursquareID    string
	FoursquareType  string
	GooglePlaceID   string
	GooglePlaceType string
	ReplyMarkup     tg.ReplyMarkup
}

Venue contains information about the venue to be sent.

type Video

type Video struct {
	Video     tg.Inputtable
	Thumbnail tg.Inputtable
	CaptionData
	Duration          int
	Width             int
	Height            int
	HasSpoiler        bool
	SupportsStreaming bool
	ReplyMarkup       tg.ReplyMarkup
}

Video contains information about the video to be sent.

type VideoNote

type VideoNote struct {
	VideoNote   tg.Inputtable
	Thumbnail   tg.Inputtable
	Duration    int
	Length      int
	ReplyMarkup tg.ReplyMarkup
}

VideoNote contains information about the video note to be sent.

type Voice

type Voice struct {
	Voice tg.Inputtable
	CaptionData
	Duration    int
	ReplyMarkup tg.ReplyMarkup
}

Voice contains information about the voice to be sent.

type WebAppAnswer

type WebAppAnswer struct {
	Result tg.InlineQueryResulter
}

WebAppAnswer represents an answer to WebApp query.

type WebAppContext

type WebAppContext = QueryContext[WebAppAnswer]

WebAppContext is the context for WebApp query.

func MakeWebAppContext

func MakeWebAppContext(ctx Context, queryID string) WebAppContext

MakeWebAppContext makes WebApp query context.

type WebhookData

type WebhookData struct {
	URL            string
	Certificate    *tg.InputFile
	IPAddress      string
	MaxConnections int
	AllowedUpdates []string
	DropPending    bool
	SecretToken    string
}

WebhookData contains parameters for setWebhook method.

Directories

Path Synopsis
api
tg

Jump to

Keyboard shortcuts

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