types

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: 4 Imported by: 0

Documentation

Overview

Package types provides base public types used by bot.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets added in v1.1.0

type Assets interface {
	// LoadAsset loads the asset with the given key.
	LoadAsset(ctx context.Context, key string) (io.ReadCloser, error)
}

Assets provider interface.

type Bot

type Bot interface {
	// Handle register bot's handler with filter.
	Handle(EventFilter, Handler)

	// Start bot.
	Start() error

	// Stop bot.
	Stop() error
}

Bot instance.

type ChatID

type ChatID int64

ChatID is a chat identifier.

func (ChatID) Int64 added in v1.2.0

func (cid ChatID) Int64() int64

func (ChatID) String added in v1.0.0

func (cid ChatID) String() string

type Context

type Context interface {

	// Set context value.
	Set(ctx.Context, string) error

	// Reset context.
	Reset(ctx.Context) error

	// Check context value.
	Check(ctx.Context, string) (bool, error)
}

type ContextProvider

type ContextProvider interface {
	UserContext(ChatID) Context
}

type DataContainer added in v1.6.0

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

func (*DataContainer) Get added in v1.6.0

func (c *DataContainer) Get() any

func (*DataContainer) Set added in v1.6.0

func (c *DataContainer) Set(data any)

type DataLoader added in v1.6.0

type DataLoader interface {
	Load(ctx context.Context, c *DataContainer, upd *telegram.Update) error
}

type EventFilter

type EventFilter interface {
	Check(context.Context, *telegram.Update) (bool, error)
}

EventFilter checks that telegram update could be handlerd.

type Handler

type Handler interface {
	// Handle update message.
	// telegram.BotAPI is deprecated and will be removed in future versions.
	Handle(context.Context, *telegram.Update, *telegram.BotAPI) error
}

Handler of telegram update message.

type PaymentProviders added in v1.2.0

type PaymentProviders interface {
	PaymentToken(name string) string
}

type Secret added in v1.5.0

type Secret string

Secret is a string that should not be printed

func (Secret) String added in v1.5.0

func (s Secret) String() string

func (Secret) Value added in v1.5.0

func (s Secret) Value() string

type Secrets added in v1.5.0

type Secrets interface {
	// Get secret map, returns error if not found.
	Get(ctx context.Context) (map[string]Secret, error)
}

Secrets is a collection of secrets.

type State

type State interface {
	Get(key string) (string, bool)
	Set(key, value string)
	Delete(key string)
	Map() map[string]string
	Fill(map[string]string)
	Changes() StateChanges
}

type StateChanges added in v1.2.0

type StateChanges struct {
	Added   []string
	Removed []string
}

func (*StateChanges) IsEmpty added in v1.2.0

func (s *StateChanges) IsEmpty() bool

type StateOp

type StateOp interface {
	Apply(State, ...func(string) string) error
}

type StateProvider

type StateProvider interface {
	Load(context.Context, ChatID, State) error
	Update(context.Context, ChatID, State) error
}

Jump to

Keyboard shortcuts

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