Skip to content

Commit

Permalink
Prepare v0.2.0 for release
Browse files Browse the repository at this point in the history
  • Loading branch information
kirsle committed Feb 8, 2017
1 parent 3d36e5b commit d466847
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 38 deletions.
13 changes: 11 additions & 2 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This documents the history of significant changes to `rivescript-go`.

## v0.1.1 - TBD
## v0.2.0 - Feb 7, 2016

This update focuses on bug fixes and code reorganization.

Expand Down Expand Up @@ -36,6 +36,13 @@ This update focuses on bug fixes and code reorganization.

### Changes

* Add ANSI colors to the RiveScript shell (`cmd/rivescript`); they can be
disabled with the `-nocolor` command line option.
* Add new commands to the RiveScript shell:
* `/debug [true|false]` to toggle the debug mode (`/debug` will print
the current setting of debug mode).
* `/dump <topics|sorted>` to print the internal data structures for the
topics and sorted trigger sets, respectively.
* Separate the unit tests into multiple files and put them in the `rivescript`
package instead of `rivescript_test`; this enables test code coverage
reporting (we're at 72.1% coverage!)
Expand All @@ -60,7 +67,9 @@ This update focuses on bug fixes and code reorganization.
* Fix `LoadDirectory()` to return an error when doesn't find any RiveScript
source files to load, which helps protect against the common error that you
gave it the wrong directory.
* New unit tests: object macros
* New unit tests: object macros.
* An internal optimization that allowed for cleaning up a redundant storage
location for triggers that have `%Previous` commands (PR #20)

## v0.1.0 - Dec 11, 2016

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Noah Petherbridge
Copyright (c) 2017 Noah Petherbridge

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
58 changes: 33 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RiveScript-Go

[![GoDoc](https://godoc.org/github.com/aichaos/rivescript-go?status.svg)](https://godoc.org/github.com/aichaos/rivescript-go)
[![Gitter](https://badges.gitter.im/aichaos/rivescript-go.svg)](https://gitter.im/aichaos/rivescript-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build Status](https://travis-ci.org/aichaos/rivescript-go.svg?branch=master)](https://travis-ci.org/aichaos/rivescript-go)

Expand Down Expand Up @@ -41,20 +42,23 @@ To test drive RiveScript in your web browser, try the

## Documentation

* RiveScript Library: <http://godoc.org/github.com/aichaos/rivescript-go>
* RiveScript Stand-alone Interpreter: <http://godoc.org/github.com/aichaos/rivescript-go/cmd/rivescript>
* JavaScript Object Macros: <http://godoc.org/github.com/aichaos/rivescript-go/lang/javascript>
* RiveScript Library: <https://godoc.org/github.com/aichaos/rivescript-go>
* RiveScript Stand-alone Interpreter: <https://godoc.org/github.com/aichaos/rivescript-go/cmd/rivescript>
* JavaScript Object Macros: <https://godoc.org/github.com/aichaos/rivescript-go/lang/javascript>
* RiveScript Parser: <https://godoc.org/github.com/aichaos/rivescript-go/parser>

Also check out the [**RiveScript Community Wiki**](https://github.com/aichaos/rivescript/wiki)
for common design patterns and tips & tricks for RiveScript.

## Installation

For the development library:

`go get github.com/aichaos/rivescript-go`

For the stand-alone binary for testing a RiveScript bot:
For the stand-alone `rivescript` binary for testing a bot:

`go install github.com/aichaos/rivescript-go/cmd/rivescript`
`go get github.com/aichaos/rivescript-go/cmd/rivescript`

## Usage

Expand All @@ -70,7 +74,7 @@ $ rivescript eg/brain
> rivescript.exe eg/brain
```

See `rivescript --help` for options it accepts, including debug mode and UTF-8
See `rivescript -help` for options it accepts, including debug mode and UTF-8
mode.

When used as a library for writing your own chatbot, the synopsis is as follows:
Expand All @@ -81,11 +85,14 @@ package main
import (
"fmt"
"github.com/aichaos/rivescript-go"
"github.com/aichaos/rivescript-go/config"
)

func main() {
bot := rivescript.New(config.Basic())
// Create a new bot with the default settings.
bot := rivescript.New(nil)

// To enable UTF-8 mode, you'd have initialized the bot like:
bot = rivescript.New(rivescript.WithUTF8())

// Load a directory full of RiveScript documents (.rive files)
err := bot.LoadDirectory("eg/brain")
Expand All @@ -94,7 +101,7 @@ func main() {
}

// Load an individual file.
err = bot.LoadFile("brain/testsuite.rive")
err = bot.LoadFile("./testsuite.rive")
if err != nil {
fmt.Printf("Error loading from file: %s", err)
}
Expand All @@ -103,8 +110,12 @@ func main() {
bot.SortReplies()

// Get a reply.
reply := bot.Reply("local-user", "Hello, bot!")
fmt.Printf("The bot says: %s", reply)
reply, err := bot.Reply("local-user", "Hello, bot!")
if err != nil {
fmt.Printf("Error: %s\n", err)
} else {
fmt.Printf("The bot says: %s", reply)
}
}
```

Expand All @@ -115,7 +126,7 @@ all the supported options. You only need to provide keys that are different to
the defaults.

```go
bot := rs.New(&config.Config{
bot := rivescript.New(&rivescript.Config{
Debug: false, // Debug mode, off by default
Strict: false, // No strict syntax checking
UTF8: false, // No UTF-8 support enabled by default
Expand All @@ -124,17 +135,14 @@ bot := rs.New(&config.Config{
})
```

For convenience, the `config` package provides two config templates:
For convenience, you can use a shortcut:

```go
// Basic has all the defaults, plus Strict=true
bot := rs.New(config.Basic())

// UTF8 has all of Basic's settings, plus UTF8=true
bot := rs.New(config.UTF8())
// A nil config uses all the defaults.
bot = rivescript.New(nil)

// You can also provide a nil configuration, which defaults to Basic()
bot := rs.New(nil)
// WithUTF8 enables UTF-8 mode (other settings left as default).
bot = rivescript.New(rivescript.WithUTF8())
```

## Object Macros
Expand All @@ -152,7 +160,7 @@ JavaScript object macros using the Otto library.
## UTF-8 Support

UTF-8 support in RiveScript is considered an experimental feature. It is
disabled by default. Enable it by setting `RiveScript.SetUTF8(true)`.
disabled by default.

By default (without UTF-8 mode on), triggers may only contain basic ASCII
characters (no foreign characters), and the user's message is stripped of all
Expand All @@ -170,10 +178,10 @@ string literal to the `RiveScript.SetUnicodePunctuation` function. Example:

```go
// Make a new bot with UTF-8 mode enabled.
bot := rivescript.New(config.UTF8())
bot := rivescript.New(rivescript.WithUTF8())

// Override the punctuation characters that get stripped from the
// user's message.
// Override the punctuation characters that get stripped
// from the user's message.
bot.SetUnicodePunctuation(`[.,!?;:]`);
```

Expand Down Expand Up @@ -263,7 +271,7 @@ The distributable directory contains only the following types of files:
```
The MIT License (MIT)
Copyright (c) 2016 Noah Petherbridge
Copyright (c) 2017 Noah Petherbridge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion cmd/rivescript/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
flag.BoolVar(&version, "version", false, "Show the version number and exit.")
flag.BoolVar(&debug, "debug", false, "Enable debug mode.")
flag.BoolVar(&utf8, "utf8", false, "Enable UTF-8 mode.")
flag.UintVar(&depth, "depth", 50, "Recursion depth limit (default 50)")
flag.UintVar(&depth, "depth", 50, "Recursion depth limit")
flag.BoolVar(&nostrict, "nostrict", false, "Disable strict syntax checking")
flag.BoolVar(&nocolor, "nocolor", false, "Disable ANSI colors")
}
Expand Down
13 changes: 8 additions & 5 deletions eg/json-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/aichaos/rivescript-go"
"github.com/aichaos/rivescript-go/config"
"github.com/aichaos/rivescript-go/lang/javascript"
)

Expand All @@ -32,7 +31,7 @@ func main() {
flag.Parse()

// Set up the RiveScript bot.
Bot = rivescript.New(&config.Config{
Bot = rivescript.New(&rivescript.Config{
Debug: *debug,
UTF8: *utf8,
})
Expand All @@ -48,14 +47,14 @@ func main() {
log.Fatal(http.ListenAndServe(addr, nil))
}

// Type Request describes the JSON arguments to the API.
// Request describes the JSON arguments to the API.
type Request struct {
Username string `json:"username"`
Message string `json:"message"`
Vars map[string]string `json:"vars"`
}

// Type Response describes the JSON output from the API.
// Response describes the JSON output from the API.
type Response struct {
Status string `json:"status"` // 'ok' or 'error'
Error string `json:"error,omitempty"`
Expand Down Expand Up @@ -98,7 +97,11 @@ func ReplyHandler(w http.ResponseWriter, r *http.Request) {
}

// Get a reply from the bot.
reply := Bot.Reply(params.Username, params.Message)
reply, err := Bot.Reply(params.Username, params.Message)
if err != nil {
writeError(w, err.Error(), http.StatusInternalServerError)
return
}

// Retrieve all user variables from the bot.
var vars map[string]string
Expand Down
5 changes: 2 additions & 3 deletions eg/json-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (
"reflect"
"testing"

rivescript "github.com/aichaos/rivescript-go"
"github.com/aichaos/rivescript-go/config"
"github.com/aichaos/rivescript-go"
)

func init() {
Bot = rivescript.New(config.UTF8())
Bot = rivescript.New(rivescript.WithUTF8())
Bot.Stream(`
+ hello bot
- Hello human.
Expand Down
2 changes: 1 addition & 1 deletion rivescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

// VERSION describes the module version.
const VERSION string = "0.1.1"
const VERSION string = "0.2.0"

// RiveScript represents an individual chatbot instance.
type RiveScript struct {
Expand Down

0 comments on commit d466847

Please sign in to comment.