types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 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) 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 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(context.Context, *telegram.Update, *telegram.BotAPI) error
}

Handler of telegram update message.

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)
}

type StateOp

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

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