rivescript - A command line frontend to the Perl RiveScript interpreter.
$ rivescript [options] [path to RiveScript documents]
This is a command line front-end to the RiveScript interpreter. This script
obsoletes the old rsdemo
, and can also be used non-interactively by third
party programs. To that end, it supports a variety of input/output and session
handling methods.
If no RiveScript document path is given, it will default to the example brain that ships with the RiveScript module, which is based on the Eliza bot.
Enables debug mode. This will print all debug data from RiveScript to your
terminal. If you'd like it to log to a file instead, use the --log
option
instead of --debug
.
Enables debug mode and prints the debug output to FILE
instead of to your
terminal.
Runs rivescript
in JSON mode, for running the script in a non-interactive
way (for example, to use RiveScript in a programming language that doesn't have
a native RiveScript library). See JSON Mode for details.
Enables strict mode for the RiveScript parser. It's enabled by default, use
--nostrict
to disable it. Strict mode prevents the parser from continuing
when it finds a syntax error in the RiveScript documents.
Override the default recursion depth limit. This controls how many times
RiveScript will recursively follow redirects to other replies. The default is
50
.
Displays this documentation in your terminal.
This is the default mode used when you run rivescript
without specifying
another mode. This mode behaves similarly to the old rsdemo
script and lets
you chat one-on-one with your RiveScript bot.
This mode can be used to test your RiveScript bot. Example:
$ rivescript /path/to/rs/files
This mode should be used when calling from a third party program. In this mode, data that enters and leaves the script are encoded in JSON.
Example:
$ rivescript --json /path/to/rs/files
The format for incoming JSON data is as follows:
{ "username": "localuser", "message": "Hello bot!", "vars": { "name": "Aiden" } }
Here, username
is a unique name for the user, message
is their message to
the bot, and vars
is a hash of any user variables your program might be
keeping track of (such as the user's name and age).
The response from rivescript
will look like the following:
{ "status": "ok", "reply": "Hello, human!", "vars": { "name": "Aiden" } }
Here, status
will be "ok"
or "error"
, reply
is the bot's response to
your message, and vars
is a hash of the current variables for the user (so
that your program can save them somewhere).
There are two ways you can use the JSON mode: "fire and forget," or keep a stateful session open.
In "fire and forget," you open the program, print your JSON input and send the
EOF signal, and then rivescript
sends you the JSON response and exits.
In a stateful session mode, you must send the text __END__
on a line by
itself after you finish sending your JSON data. Then rivescript
will
process it, return its JSON response and then also say __END__
at the end.
Example:
{ "username": "localuser", "message": "Hello bot!", "vars": {} } __END__
And the response:
{ "status": "ok", "reply": "Hello, human!", "vars": {} } __END__
This way you can reuse the same pipe to send and receive multiple messages.
RiveScript, the Perl RiveScript interpreter.
Noah Petherbridge, http://www.kirsle.net
RiveScript - Rendering Intelligence Very Easily Copyright (C) 2008 Casey Kirsle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA