-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from aichaos/bugfixes
Low-hanging bugs, unit test and code restructure
- Loading branch information
Showing
37 changed files
with
1,703 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package rivescript | ||
|
||
import "github.com/aichaos/rivescript-go/sessions" | ||
|
||
/* | ||
Type Config provides options to configure the RiveScript bot. | ||
Create a pointer to this type and send it to the New() constructor to change | ||
the default settings. You only need to provide settings you want to override; | ||
the zero-values of all the options are handled appropriately by the RiveScript | ||
library. | ||
The default values are documented below. | ||
*/ | ||
type Config struct { | ||
// Debug enables verbose logging to standard output. Default false. | ||
Debug bool | ||
|
||
// Strict enables strict syntax checking, where a syntax error in RiveScript | ||
// code is considered fatal at parse time. Default true. | ||
Strict bool | ||
|
||
// UTF8 enables UTF-8 mode within the bot. Default false. | ||
// | ||
// When UTF-8 mode is enabled, triggers in the RiveScript source files are | ||
// allowed to contain foreign characters. Additionally, the user's incoming | ||
// messages are left *mostly* intact, so that they send messages with | ||
// foreign characters to the bot. | ||
UTF8 bool | ||
|
||
// Depth controls the global limit for recursive functions within | ||
// RiveScript. Default 50. | ||
Depth uint | ||
|
||
// SessionManager is an implementation of the same name for managing user | ||
// variables for the bot. The default is the in-memory session handler. | ||
SessionManager sessions.SessionManager | ||
} | ||
|
||
// WithUTF8 provides a Config object that enables UTF-8 mode. | ||
func WithUTF8() *Config { | ||
return &Config{ | ||
UTF8: true, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package rivescript | ||
|
||
// deprecated.go is where functions that are deprecated move to. | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// common function to put the deprecated note. | ||
func deprecated(name, since string) { | ||
fmt.Fprintf( | ||
os.Stderr, | ||
"Use of 'rivescript.%s()' is deprecated since v%s (this is v%s)\n", | ||
name, | ||
since, | ||
VERSION, | ||
) | ||
} | ||
|
||
// SetDebug enables or disable debug mode. | ||
func (self *RiveScript) SetDebug(value bool) { | ||
deprecated("SetDebug", "0.1.0") | ||
self.rs.Debug = value | ||
} | ||
|
||
// GetDebug tells you the current status of the debug mode. | ||
func (self *RiveScript) GetDebug() bool { | ||
deprecated("GetDebug", "0.1.0") | ||
return self.rs.Debug | ||
} | ||
|
||
// SetUTF8 enables or disabled UTF-8 mode. | ||
func (self *RiveScript) SetUTF8(value bool) { | ||
deprecated("SetUTF8", "0.1.0") | ||
self.rs.UTF8 = value | ||
} | ||
|
||
// GetUTF8 returns the current status of UTF-8 mode. | ||
func (self *RiveScript) GetUTF8() bool { | ||
deprecated("GetUTF8", "0.1.0") | ||
return self.rs.UTF8 | ||
} | ||
|
||
// SetDepth lets you override the recursion depth limit (default 50). | ||
func (self *RiveScript) SetDepth(value uint) { | ||
deprecated("SetDepth", "0.1.0") | ||
self.rs.Depth = value | ||
} | ||
|
||
// GetDepth returns the current recursion depth limit. | ||
func (self *RiveScript) GetDepth() uint { | ||
deprecated("GetDepth", "0.1.0") | ||
return self.rs.Depth | ||
} | ||
|
||
// SetStrict enables strict syntax checking when parsing RiveScript code. | ||
func (self *RiveScript) SetStrict(value bool) { | ||
deprecated("SetStrict", "0.1.0") | ||
self.rs.Strict = value | ||
} | ||
|
||
// GetStrict returns the strict syntax check setting. | ||
func (self *RiveScript) GetStrict() bool { | ||
deprecated("GetStrict", "0.1.0") | ||
return self.rs.Strict | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.