scene

package
v0.1.4-alpha-114b082 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCommand         = Command(0)
	ApplyStashedScene = Command(1)
	FinishScene       = Command(2)
	StashScene        = Command(3)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSceneError

type BaseSceneError struct {
	Scene Scene
}

func (BaseSceneError) GetErrorScene

func (bse BaseSceneError) GetErrorScene() Scene

func (BaseSceneError) GetErrorText

func (bse BaseSceneError) GetErrorText() string

func (BaseSceneError) IsErrorScene

func (bse BaseSceneError) IsErrorScene() bool

type BaseTextError

type BaseTextError struct {
	Message string
}

func (BaseTextError) GetErrorScene

func (bte BaseTextError) GetErrorScene() Scene

func (BaseTextError) GetErrorText

func (bte BaseTextError) GetErrorText() string

func (BaseTextError) IsErrorScene

func (bte BaseTextError) IsErrorScene() bool

type Command

type Command uint64

type Context

type Context struct {
	context.Context
	Request       Request
	Info          UserInfo
	GlobalContext context.Context
}

func NewContext

func NewContext(request Request, info UserInfo, ctx context.Context, GlobalContext context.Context) *Context

func (*Context) Get

func (c *Context) Get(key ContextKey) (value any, exists bool)

Get returns the value for the given key, ie: (value, true). If the value does not exist it returns (nil, false)

func (*Context) GetBool

func (c *Context) GetBool(key ContextKey) (b bool)

GetBool returns the value associated with the key as a boolean.

func (*Context) GetDuration

func (c *Context) GetDuration(key ContextKey) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (*Context) GetFloat64

func (c *Context) GetFloat64(key ContextKey) (f64 float64)

GetFloat64 returns the value associated with the key as a float64.

func (*Context) GetInt

func (c *Context) GetInt(key ContextKey) (i int)

GetInt returns the value associated with the key as an integer.

func (*Context) GetInt64

func (c *Context) GetInt64(key ContextKey) (i64 int64)

GetInt64 returns the value associated with the key as an integer.

func (*Context) GetString

func (c *Context) GetString(key ContextKey) (s string)

GetString returns the value associated with the key as a string.

func (*Context) GetStringMap

func (c *Context) GetStringMap(key ContextKey) (sm map[string]any)

GetStringMap returns the value associated with the key as a map of interfaces.

func (*Context) GetStringMapString

func (c *Context) GetStringMapString(key ContextKey) (sms map[string]string)

GetStringMapString returns the value associated with the key as a map of strings.

func (*Context) GetStringMapStringSlice

func (c *Context) GetStringMapStringSlice(key ContextKey) (smss map[string][]string)

GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.

func (*Context) GetStringSlice

func (c *Context) GetStringSlice(key ContextKey) (ss []string)

GetStringSlice returns the value associated with the key as a slice of strings.

func (*Context) GetTime

func (c *Context) GetTime(key ContextKey) (t time.Time)

GetTime returns the value associated with the key as time.

func (*Context) GetUint

func (c *Context) GetUint(key ContextKey) (ui uint)

GetUint returns the value associated with the key as an unsigned integer.

func (*Context) GetUint64

func (c *Context) GetUint64(key ContextKey) (ui64 uint64)

GetUint64 returns the value associated with the key as an unsigned integer.

func (*Context) MustGet

func (c *Context) MustGet(key ContextKey) any

MustGet returns the value for the given key if it exists, otherwise it panics.

func (*Context) Set

func (c *Context) Set(key ContextKey, value any)

Set is used to store a new key/value pair exclusively for this context. It also lazy initializes c.Keys if it was not used previously.

type ContextKey

type ContextKey string

type Error

type Error interface {
	GetErrorText() string
	GetErrorScene() Scene
	IsErrorScene() bool
}

type Info

type Info struct {
	Text             director.Text
	Buttons          []director.Button
	ExpectedMessages []MessageMatcher
	Err              Error
}

type MessageMatcher

type MessageMatcher interface {
	Match(message string) (isMatch bool, searchedString string)
	GetMatchedName() string
}

type NLU

type NLU struct {
	Tokens   []string
	Entities []string
}

NLU - parsing user input to language token

type Request

type Request struct {
	SearchedMessage string
	NameMatched     string
	FullMessage     string
	WasButton       bool
	ApplicationType marusia.ApplicationType
	Payload         json.RawMessage
	NLU             NLU
}

type Scene

type Scene interface {
	GetSceneInfo(ctx *Context) (sceneInfo Info, withReact bool)
	React(ctx *Context) Command
	Next() Scene
}

type UserInfo

type UserInfo struct {
	UserId    string
	SessionId string
	UserVKId  string
}

Jump to

Keyboard shortcuts

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