Documentation ¶
Overview ¶
Package rivescript contains all of the private use functions of RiveScript.
Do Not Use This Package Directly ¶
You should not use any exported symbols from this package directly. They are not stable and are subject to change at any time without notice.
As an end user of the RiveScript library you should stick purely to the exported API functions of the base RiveScript package and any other subpackages (for example: parser and ast) but leave the src package alone!
Documentation for most exported functions is available in the root RiveScript package, which acts as a wrapper. Go there for documentation. Stop looking at this package lest you be tempted to use it (don't).
You've been warned. Here be dragons.
Index ¶
- Constants
- Variables
- type RiveScript
- func (rs *RiveScript) ClearAllUservars()
- func (rs *RiveScript) ClearUservars(username string)
- func (rs *RiveScript) Configure(debug, strict, utf8 bool, depth uint, sessions sessions.SessionManager)
- func (rs *RiveScript) CurrentUser() (string, error)
- func (rs *RiveScript) DeleteSubroutine(name string)
- func (rs *RiveScript) DumpSorted()
- func (rs *RiveScript) DumpTopics()
- func (rs *RiveScript) FreezeUservars(username string) error
- func (rs *RiveScript) GetAllUservars() map[string]*sessions.UserData
- func (rs *RiveScript) GetGlobal(name string) (string, error)
- func (rs *RiveScript) GetUservar(username, name string) (string, error)
- func (rs *RiveScript) GetUservars(username string) (*sessions.UserData, error)
- func (rs *RiveScript) GetVariable(name string) (string, error)
- func (rs *RiveScript) LastMatch(username string) (string, error)
- func (rs *RiveScript) LoadDirectory(path string, extensions ...string) error
- func (rs *RiveScript) LoadFile(path string) error
- func (rs *RiveScript) RemoveHandler(lang string)
- func (rs *RiveScript) Reply(username, message string) (string, error)
- func (rs *RiveScript) SetGlobal(name, value string)
- func (rs *RiveScript) SetHandler(lang string, handler macro.MacroInterface)
- func (rs *RiveScript) SetPerson(name, value string)
- func (rs *RiveScript) SetSubroutine(name string, fn Subroutine)
- func (rs *RiveScript) SetSubstitution(name, value string)
- func (rs *RiveScript) SetUnicodePunctuation(value string)
- func (rs *RiveScript) SetUservar(username, name, value string)
- func (rs *RiveScript) SetUservars(username string, data map[string]string)
- func (rs *RiveScript) SetVariable(name, value string)
- func (rs *RiveScript) SortReplies() error
- func (rs *RiveScript) Stream(code string) error
- func (rs *RiveScript) ThawUservars(username string, action sessions.ThawAction) error
- type Subroutine
Constants ¶
const ( // UNDEFINED is the text "undefined", the default text for variable getters. UNDEFINED = "undefined" // UNDEFTAG is the "<undef>" tag for unsetting variables in !Definitions. UNDEFTAG = "<undef>" )
Forms of undefined.
Variables ¶
var ( ErrDeepRecursion = errors.New("Deep Recursion Detected") ErrRepliesNotSorted = errors.New("Replies Not Sorted") ErrNoDefaultTopic = errors.New("No default topic 'random' was found") ErrNoTriggerMatched = errors.New("No Trigger Matched") ErrNoReplyFound = errors.New("The trigger matched but yielded no reply") )
The types of errors returned by RiveScript.
Functions ¶
This section is empty.
Types ¶
type RiveScript ¶
type RiveScript struct { // Parameters Debug bool // Debug mode Strict bool // Strictly enforce RiveScript syntax Depth uint // Max depth for recursion UTF8 bool // Support UTF-8 RiveScript code Quiet bool // Suppress all warnings from being emitted UnicodePunctuation *regexp.Regexp // contains filtered or unexported fields }
RiveScript is the bot instance.
func New ¶
func New() *RiveScript
New creates a new RiveScript instance with the default configuration.
func (*RiveScript) ClearAllUservars ¶
func (rs *RiveScript) ClearAllUservars()
ClearAllUservars deletes all variables for all users.
func (*RiveScript) ClearUservars ¶
func (rs *RiveScript) ClearUservars(username string)
ClearUservars deletes all the variables that belong to a user.
func (*RiveScript) Configure ¶ added in v0.2.0
func (rs *RiveScript) Configure(debug, strict, utf8 bool, depth uint, sessions sessions.SessionManager)
Configure is a convenience function for the public API to set all of its settings at once.
func (*RiveScript) CurrentUser ¶
func (rs *RiveScript) CurrentUser() (string, error)
CurrentUser returns the current user and can only be called from within an object macro context.
func (*RiveScript) DeleteSubroutine ¶
func (rs *RiveScript) DeleteSubroutine(name string)
DeleteSubroutine deletes a Go object macro handler.
func (*RiveScript) DumpSorted ¶
func (rs *RiveScript) DumpSorted()
DumpSorted prints the sorted structure to the terminal.
func (*RiveScript) DumpTopics ¶
func (rs *RiveScript) DumpTopics()
DumpTopics prints the topic structure to the terminal.
func (*RiveScript) FreezeUservars ¶
func (rs *RiveScript) FreezeUservars(username string) error
FreezeUservars takes a snapshot of a user's variables.
func (*RiveScript) GetAllUservars ¶
func (rs *RiveScript) GetAllUservars() map[string]*sessions.UserData
GetAllUservars gets all variables about all users.
func (*RiveScript) GetGlobal ¶
func (rs *RiveScript) GetGlobal(name string) (string, error)
GetGlobal retrieves the value of a global variable.
func (*RiveScript) GetUservar ¶
func (rs *RiveScript) GetUservar(username, name string) (string, error)
GetUservar retrieves the value of a user variable.
func (*RiveScript) GetUservars ¶
func (rs *RiveScript) GetUservars(username string) (*sessions.UserData, error)
GetUservars retrieves all variables about a user.
func (*RiveScript) GetVariable ¶
func (rs *RiveScript) GetVariable(name string) (string, error)
GetVariable retrieves the value of a bot variable.
func (*RiveScript) LastMatch ¶
func (rs *RiveScript) LastMatch(username string) (string, error)
LastMatch returns the last match of the user.
func (*RiveScript) LoadDirectory ¶
func (rs *RiveScript) LoadDirectory(path string, extensions ...string) error
LoadDirectory loads a directory of files into memory.
func (*RiveScript) LoadFile ¶
func (rs *RiveScript) LoadFile(path string) error
LoadFile loads a single file into memory.
func (*RiveScript) RemoveHandler ¶
func (rs *RiveScript) RemoveHandler(lang string)
RemoveHandler deletes support for a foreign language object macro.
func (*RiveScript) Reply ¶
func (rs *RiveScript) Reply(username, message string) (string, error)
Reply gets a reply from the bot.
func (*RiveScript) SetGlobal ¶
func (rs *RiveScript) SetGlobal(name, value string)
SetGlobal configures a global variable in RiveScript.
func (*RiveScript) SetHandler ¶
func (rs *RiveScript) SetHandler(lang string, handler macro.MacroInterface)
SetHandler registers a handler for foreign language object macros.
func (*RiveScript) SetPerson ¶
func (rs *RiveScript) SetPerson(name, value string)
SetPerson sets a person substitution.
func (*RiveScript) SetSubroutine ¶
func (rs *RiveScript) SetSubroutine(name string, fn Subroutine)
SetSubroutine defines a Go function to handle an object macro for RiveScript.
func (*RiveScript) SetSubstitution ¶
func (rs *RiveScript) SetSubstitution(name, value string)
SetSubstitution sets a substitution pattern.
func (*RiveScript) SetUnicodePunctuation ¶
func (rs *RiveScript) SetUnicodePunctuation(value string)
SetUnicodePunctuation allows for overriding the regexp for punctuation.
func (*RiveScript) SetUservar ¶
func (rs *RiveScript) SetUservar(username, name, value string)
SetUservar sets a user variable to a value.
func (*RiveScript) SetUservars ¶
func (rs *RiveScript) SetUservars(username string, data map[string]string)
SetUservars sets many user variables at a time.
func (*RiveScript) SetVariable ¶
func (rs *RiveScript) SetVariable(name, value string)
SetVariable configures a bot variable in RiveScript.
func (*RiveScript) SortReplies ¶
func (rs *RiveScript) SortReplies() error
SortReplies prepares the internal sort buffers to get ready for replying.
func (*RiveScript) Stream ¶
func (rs *RiveScript) Stream(code string) error
Stream dynamically loads RiveScript source from a string.
func (*RiveScript) ThawUservars ¶
func (rs *RiveScript) ThawUservars(username string, action sessions.ThawAction) error
ThawUservars restores a snapshot of user variables.
type Subroutine ¶
type Subroutine func(*RiveScript, []string) string
Subroutine is a Golang function type for defining an object macro in Go. TODO: get this exportable to third party devs somehow