pub struct RiveScript {
pub debug: bool,
pub utf8: bool,
pub depth: i32,
/* private fields */
}
Expand description
RiveScript represents a single chatbot personality in memory.
Fields§
§debug: bool
§utf8: bool
§depth: i32
Implementations§
Source§impl RiveScript
impl RiveScript
Sourcepub fn new() -> Self
pub fn new() -> Self
Initialize a new RiveScript chatbot personality.
A single instance of RiveScript is able to have its own set of responses (“brain”) independently of other instances of RiveScript. Also, by default, RiveScript keeps track of temporary user variables (such as recent reply history and any variables the bot has learned about them) at in local memory of this instance, with each instance keeping its own separate data store.
Sourcepub fn load_directory(&self, path: &str) -> Result<bool, Box<dyn Error>>
pub fn load_directory(&self, path: &str) -> Result<bool, Box<dyn Error>>
Load a directory of RiveScript documents (.rive or .rs extension) from a folder on disk. Example
let mut bot = RiveScript::new();
bot.load_directory("./eg/brain").expect("Couldn't load directory!");
Sourcepub fn load_file(&self, path: &str) -> Result<bool, Box<dyn Error>>
pub fn load_file(&self, path: &str) -> Result<bool, Box<dyn Error>>
Load a RiveScript document by filename on disk. Example
let mut bot = RiveScript::new();
bot.load_file("./eg/brain/eliza.rive").expect("Couldn't load file from disk!");
Sourcepub fn stream(&self, source: String) -> Result<bool, Box<dyn Error>>
pub fn stream(&self, source: String) -> Result<bool, Box<dyn Error>>
Stream a string containing RiveScript syntax into the bot, rather than read from the filesystem. Example
let mut bot = RiveScript::new();
let code = String::from(
"
+ hello bot
- Hello, human!
",
);
bot.stream(code).expect("Couldn't parse code!");
Sourcepub fn sort_triggers(&self)
pub fn sort_triggers(&self)
After loading RiveScript source documents, this function will pre-populate sort buffers in memory.