telebot

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "telebot"
)

Variables

This section is empty.

Functions

func ToContext

func ToContext(ctx context.Context, client *Client) context.Context

Types

type Action

type Action func(ctx context.Context, update telegram.Update) (Keyword, error)

func ErrorMiddleware

func ErrorMiddleware(next Action) Action

func LangMiddleware

func LangMiddleware(next Action) Action

type Client

type Client struct {
	Configs
	// contains filtered or unexported fields
}

func FromContext

func FromContext(ctx context.Context) *Client

func New

func New(configs Configs) *Client

func (*Client) Command

func (c *Client) Command(cmd Command)

func (*Client) DelState added in v2.1.1

func (c *Client) DelState(ctx context.Context, chatID int64) error

func (*Client) Event

func (c *Client) Event(on telegram.UpdateType, event Event)

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, chatID int64, data any) error

func (*Client) GetState

func (c *Client) GetState(ctx context.Context, chatID int64, state *State) error

func (*Client) Middleware

func (c *Client) Middleware(middleware ...Middleware)

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

func (*Client) SetSession

func (c *Client) SetSession(ctx context.Context, chatID int64, data any) error

func (*Client) SetState added in v2.1.1

func (c *Client) SetState(ctx context.Context, chatID int64, state *State) error

type Command

type Command interface {
	Name() Keyword
	Alias() []Keyword
	Actions() map[Keyword]Route
	Init(ctx context.Context, update telegram.Update) (Keyword, error)
}

type Configs

type Configs struct {
	TelegramStoragePrefix string        `env:"TELEGRAM_STORAGE_PREFIX" envDefault:"telegram"`
	TelegramPullInterval  time.Duration `env:"TELEGRAM_PULL_INTERVAL" envDefault:"30s"`
	TelegramConcurrency   uint8         `env:"TELEGRAM_CONCURRENCY" envDefault:"10"`
}

type Event

type Event func(ctx context.Context, update telegram.Update) error

type InlineKeyboard

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

func NewInlineKeyboard

func NewInlineKeyboard() *InlineKeyboard

func (*InlineKeyboard) AddCol

func (*InlineKeyboard) AddRow

func (*InlineKeyboard) Render

type Keyword

type Keyword string
const (
	Empty Keyword = ""
)

func (Keyword) String

func (k Keyword) String() string

type Middleware

type Middleware func(next Action) Action

func ActionMiddleware

func ActionMiddleware(action telegram.Action) Middleware

type ReplyKeyboard

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

func NewReplyKeyboard

func NewReplyKeyboard() *ReplyKeyboard

func (*ReplyKeyboard) AddCol

func (*ReplyKeyboard) AddRow

func (*ReplyKeyboard) Render

type Route

type Route struct {
	Action       Action
	AllowUpdates []telegram.UpdateType
}

type State

type State struct {
	Command   Keyword  `json:"command,omitempty"`
	Action    Keyword  `json:"action,omitempty"`
	Arguments []string `json:"arguments,omitempty"`
}

Jump to

Keyboard shortcuts

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