Skip to content

Commit

Permalink
Prepare v0.1.0 for release
Browse files Browse the repository at this point in the history
  • Loading branch information
kirsle committed Dec 11, 2016
1 parent 7f29a68 commit 2a645ef
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
38 changes: 38 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@

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

## v0.1.0 - Dec 11, 2016

This update changes some function prototypes in the API which breaks backward
compatibility with existing code.

* **API Breaking Changes:**
* `rivescript.New()` now takes a `*config.Config` struct to configure the
instance. This is now the preferred way to configure debug mode, strict
mode, UTF-8, etc. rather than functions like `SetUTF8()`.

For RiveScript's default settings, you can do `rivescript.New(config.Basic())`
or `rivescript.New(nil)`. For UTF-8 support, `rivescript.New(config.UTF8())`
is a convenient config template to use.
* `GetDepth()` and `SetDepth()` now use a `uint` instead of an `int`. But
these functions are deprecated anyway.
* `GetUservars()` and `GetAllUservars()` return `*sessions.UserData` objects
instead of `map[string]string` for the user data.
* `ThawUservars()` now takes a `sessions.ThawAction` instead of a string to
specify the action. Valid values are `Thaw`, `Discard`, or `Keep`
(constants from the `sessions` package).
* **Deprecated Functions:**
* Configuration functions (getters and setters). Use the `Config` struct
when calling `rivescript.New(*config.Config)` instead:
* `SetDebug()`, `SetUTF8()`, `SetDepth()`, `SetStrict()`
* `GetDebug()`, `GetUTF8()`, `GetDepth()`, `GetStrict()`
* **Changes:**
* Add support for pluggable session stores for user variables. The default
one still keeps user variables in memory, but you can specify your own
implementation instead.

The interface for a `SessionManager` is in the `sessions` package. The
default in-memory manager is in `sessions/memory`. By implementing your own
session manager, you can change where RiveScript keeps track of user
variables, e.g. to put them in a database or cache.
* Make the library thread-safe with regards to getting/setting user variables
while answering a message. The default in-memory session manager implements
a mutex for accessing user variables.

## v0.0.3 - Sept 28, 2016

This update was all about restructuring the internal source code to make certain
Expand Down
17 changes: 16 additions & 1 deletion rivescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ package rivescript
*/

import (
"fmt"
"os"

"github.com/aichaos/rivescript-go/config"
"github.com/aichaos/rivescript-go/macro"
"github.com/aichaos/rivescript-go/sessions"
"github.com/aichaos/rivescript-go/src"
)

const VERSION string = "0.0.3"
const VERSION string = "0.1.0"

type RiveScript struct {
rs *rivescript.RiveScript
Expand All @@ -31,28 +34,36 @@ func New(config *config.Config) *RiveScript {
return bot
}

func deprecated(name string) {
fmt.Fprintf(os.Stderr, "Use of 'rivescript.%s()' is deprecated\n", name)
}

// Version returns the RiveScript library version.
func (self *RiveScript) Version() string {
return VERSION
}

// SetDebug enables or disable debug mode.
func (self *RiveScript) SetDebug(value bool) {
deprecated("SetDebug")
self.rs.Debug = value
}

// GetDebug tells you the current status of the debug mode.
func (self *RiveScript) GetDebug() bool {
deprecated("GetDebug")
return self.rs.Debug
}

// SetUTF8 enables or disabled UTF-8 mode.
func (self *RiveScript) SetUTF8(value bool) {
deprecated("SetUTF8")
self.rs.UTF8 = value
}

// GetUTF8 returns the current status of UTF-8 mode.
func (self *RiveScript) GetUTF8() bool {
deprecated("GetUTF8")
return self.rs.UTF8
}

Expand All @@ -65,21 +76,25 @@ func (self *RiveScript) SetUnicodePunctuation(value string) {

// SetDepth lets you override the recursion depth limit (default 50).
func (self *RiveScript) SetDepth(value uint) {
deprecated("SetDepth")
self.rs.Depth = value
}

// GetDepth returns the current recursion depth limit.
func (self *RiveScript) GetDepth() uint {
deprecated("GetDepth")
return self.rs.Depth
}

// SetStrict enables strict syntax checking when parsing RiveScript code.
func (self *RiveScript) SetStrict(value bool) {
deprecated("SetStrict")
self.rs.Strict = value
}

// GetStrict returns the strict syntax check setting.
func (self *RiveScript) GetStrict() bool {
deprecated("GetStrict")
return self.rs.Strict
}

Expand Down

0 comments on commit 2a645ef

Please sign in to comment.