bot

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

Bot is a main bot instance.

func New

func New(botAPI *telegram.BotAPI, state types.StateProvider,
	context types.ContextProvider, assets types.Assets,
	paymentProviders types.PaymentProviders, secrets types.Secrets,
	apiAddr string, log zerolog.Logger,
) *Bot

New creates a new bot instance with default values for empty options. deprecated: use NewWithOptions instead

func NewFromSpec

func NewFromSpec(s *spec.Bot) (*Bot, error)

func NewWithOptions added in v1.15.0

func NewWithOptions(botAPI *telegram.BotAPI, opts ...Option) *Bot

NewWithOptions creates a new bot instance with options or default values for empty options.

func (*Bot) ApiHandler

func (b *Bot) ApiHandler(id string, h api.Handler)

func (*Bot) Handle

func (b *Bot) Handle(filter types.EventFilter, h types.Handler)

func (*Bot) HandleUpdate

func (b *Bot) HandleUpdate(ctx context.Context, upd *telegram.Update)

HandleUpdate handles telegram update and log error if any. Deprecated: use HandleUpdateErr instead, in next major release HandlerUpdateErr will be renamed to HandleUpdate.

func (*Bot) HandleUpdateErr added in v1.4.0

func (b *Bot) HandleUpdateErr(ctx context.Context, upd *telegram.Update) error

HandleUpdateErr handles telegram update and returns error if any.

func (*Bot) HandleWithData added in v1.6.0

func (b *Bot) HandleWithData(filter types.EventFilter, h types.Handler, dl types.DataLoader)

func (*Bot) HandlerAPI added in v1.7.0

func (b *Bot) HandlerAPI(cfg api.Config) *api.Service

func (*Bot) SetupApiHandlersFromSpec

func (b *Bot) SetupApiHandlersFromSpec(src []*spec.ApiHandler) error

func (*Bot) SetupHandlersFromSpec

func (b *Bot) SetupHandlersFromSpec(src []*spec.Handler) error

func (*Bot) Start

func (b *Bot) Start() error

func (*Bot) Stop

func (b *Bot) Stop() error

type Option added in v1.15.0

type Option func(*Bot)

Option is a functional option for Bot.

func WithAPIAddr added in v1.15.0

func WithAPIAddr(addr string) Option

WithAPIAddr option sets API address for bot.

func WithAssets added in v1.15.0

func WithAssets(assets types.Assets) Option

WithAssets option sets assets provider for bot.

func WithContextProvider added in v1.15.0

func WithContextProvider(cp types.ContextProvider) Option

WithContextProvider option sets context provider for bot.

func WithHTTPClient added in v1.15.0

func WithHTTPClient(cli *http.Client) Option

WithHTTPClient option sets HTTP client for bot.

func WithLogger added in v1.15.0

func WithLogger(log zerolog.Logger) Option

WithLogger option sets logger for bot.

func WithPaymentProviders added in v1.15.0

func WithPaymentProviders(payments types.PaymentProviders) Option

WithPaymentProviders option sets payment providers for bot.

func WithSecrets added in v1.15.0

func WithSecrets(secrets types.Secrets) Option

WithSecrets option sets secrets provider for bot.

func WithStateProvider added in v1.15.0

func WithStateProvider(sp types.StateProvider) Option

WithStateProvider option sets state provider for bot.

Jump to

Keyboard shortcuts

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