tg_botx

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 8 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
}

func New

func New(logger log.Logger) *Bot

func (*Bot) Api

func (bot *Bot) Api() *tg_bot.BotApi

func (*Bot) ClearAllCommands

func (bot *Bot) ClearAllCommands() error

func (*Bot) RegisterCommands

func (bot *Bot) RegisterCommands(commands ...tg_bot.BotCommand) error

func (*Bot) Send

func (bot *Bot) Send(msg tg_bot.Chattable) error

func (*Bot) Serve

func (bot *Bot) Serve(ctx context.Context) error

Serve fetches updates and sends them to muxer. nolint:gocognit,cyclop,funlen

func (*Bot) Shutdown

func (bot *Bot) Shutdown()

func (*Bot) UpgradeConfig

func (bot *Bot) UpgradeConfig(logCtx context.Context, cfg Config) error

func (*Bot) UpgradeMux

func (bot *Bot) UpgradeMux(logCtx context.Context, mux Muxer)

type CommandDescription

type CommandDescription struct {
	Command     string
	Description string
	UpdateType  string
}

type Config

type Config struct {
	Token        string `schema:"Токен для бота" validate:"required,min=1" yamlschema:"secret"`
	PaymentToken string `schema:"Токен для интеграции с платёжной платформой" yamlschema:"secret"`

	// timeout in seconds
	Timeout        int      `schema:"Время получения сообщений от сервера" validate:"required,min=1,max=1000"`
	Limit          int      `schema:"Количество читаемых сообщений за раз" validate:"required,min=1,max=1000"`
	AllowedUpdates []string `schema:"Типы сообщений для получения ботом"`

	ApiEndpoint string

	RetryDelaySec int `schema:"Время через которое повторится обработка сообщений, в секундах"` // default = 3
	MaxRetryCount int `schema:"Максимальное количество повторений обработки сообщений"`         // -1 - infinity retry count
}

type Muxer

type Muxer interface {
	Handle(ctx context.Context, msg tg_bot.Update) (tg_bot.Chattable, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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