state

package
v0.0.0-...-e36e409 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Root = RootState{BaseState{TheName: "root", TheLast: nil}}

Functions

func Register

func Register(state State)

Types

type BaseState

type BaseState struct {
	TheName string
	TheLast State
}

func (BaseState) Last

func (s BaseState) Last() State

func (BaseState) Name

func (s BaseState) Name() string

func (BaseState) String

func (s BaseState) String() string

type Command

type Command string
var (
	Back Command = "返回"
	Help Command = "帮助"
)

func (Command) String

func (c Command) String() string

type MessageHandler

type MessageHandler func(msg model.Message) (State, model.Message)

func DefaultText

func DefaultText(s State, h MessageHandler) MessageHandler

func HelpHandler

func HelpHandler(s State) MessageHandler

type OptionList

type OptionList struct {
	What    string
	Options []fmt.Stringer
}

func (OptionList) Find

func (o OptionList) Find(input string) fmt.Stringer

func (OptionList) String

func (o OptionList) String() string

type RootState

type RootState struct {
	BaseState
}

func (RootState) Handle

func (s RootState) Handle(msgType string) MessageHandler

func (RootState) Help

func (s RootState) Help() string

type State

type State interface {
	Name() string
	String() string // name
	Help() string
	Last() State
	Handle(msgType string) MessageHandler
}

Jump to

Keyboard shortcuts

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