types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 2 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 Bot

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

	// HandleState register bot's state handler with filter.
	HandleState(EventFilter, StateHandler)

	// Start bot.
	Start() error

	// Stop bot.
	Stop() error
}

Bot instance.

type ChatID

type ChatID int64

ChatID is a chat identifier.

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 StateHandler

type StateHandler interface {
	Handle(context.Context, *telegram.Update) error
}

StateHandler for state updates.

type StateOp

type StateOp interface {
	Apply(State)
}

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