telegram

package
v0.0.0-...-5886a04 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAuthExtractor

func DefaultAuthExtractor(ctx context.Context, update *Update) (map[string]any, error)

func DefaultBotOptions

func DefaultBotOptions() []bot.Option

func DefaultErrorHandler

func DefaultErrorHandler(ctx context.Context, b *bot.Bot, update *Update, err error)

func MarshalData

func MarshalData[T any](route string, data T) string

func NewRecoveryMiddleware

func NewRecoveryMiddleware() bot.Middleware

func SendErrorMessageHandler

func SendErrorMessageHandler(ctx context.Context, b *bot.Bot, update *Update, err error)

func SendMessage

func SendMessage(ctx context.Context, b *bot.Bot, update *Update, m *Message) error

func UnmarshalData

func UnmarshalData[T any](data string) (string, *T, error)

func WithMiddleware

func WithMiddleware(h HandlerFunc, e ErrorHandlerFunc, middleware ...MiddlewareFunc) bot.HandlerFunc

Types

type AuthExtractorFunc

type AuthExtractorFunc = func(ctx context.Context, update *Update) (map[string]any, error)

type Bot

type Bot struct {
	BotOptions    func() []bot.Option
	ErrorHandler  ErrorHandlerFunc
	AuthExtractor AuthExtractorFunc
	// contains filtered or unexported fields
}

func NewApp

func NewApp(config *Config) *Bot

func (*Bot) BindCallback

func (b *Bot) BindCallback(route string, handlerFunc HandlerFunc, middlewares ...MiddlewareFunc)

func (*Bot) BindCommand

func (b *Bot) BindCommand(command string, handlerFunc HandlerFunc, middlewares ...MiddlewareFunc)

func (*Bot) Close

func (b *Bot) Close(ctx context.Context) error

func (*Bot) ExtractorAuth

func (b *Bot) ExtractorAuth(ctx context.Context, tBot *bot.Bot, update *Update) (context.Context, bool)

func (*Bot) Run

func (b *Bot) Run(ctx context.Context, options ...func(*bot.Bot) error) error

func (*Bot) SendMessage

func (b *Bot) SendMessage(ctx context.Context, update *Update, m *Message) error

type Button

type Button struct {
	Text         string
	Type         string
	CallbackData string
}

func NewButton

func NewButton[T any](text, dType string, data T) Button

type Config

type Config struct {
	Token string `json:"token" yaml:"token"`
}

type Context

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

func NewContext

func NewContext(ctx context.Context) *Context

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (c *Context) Done() <-chan struct{}

func (*Context) Err

func (c *Context) Err() error

func (*Context) SetValue

func (c *Context) SetValue(key string, value any)

func (*Context) Value

func (c *Context) Value(key any) any

type ErrorHandlerFunc

type ErrorHandlerFunc = func(ctx context.Context, bot *bot.Bot, update *Update, err error)

type HandlerFunc

type HandlerFunc = func(ctx context.Context, update *Update) error

type Message

type Message struct {
	Text      string
	Button    [][]Button
	ParseMode models.ParseMode
}

type MethodExtraData

type MethodExtraData struct {
	Command       string
	CallbackQuery string
}

func NewMethodExtraData

func NewMethodExtraData(raw map[string]string) *MethodExtraData

type MiddlewareFunc

type MiddlewareFunc = func(next HandlerFunc) HandlerFunc

func NewGroupMessageFilterMiddleware

func NewGroupMessageFilterMiddleware(b *bot.Bot, trimMention bool, infoExpire time.Duration) MiddlewareFunc

func NewSingleFlightMiddleware

func NewSingleFlightMiddleware() MiddlewareFunc

type Update

type Update models.Update

Jump to

Keyboard shortcuts

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