Misc low-hanging fruit, bug fixes and feature additions #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This knocks out various small annoying bugs and adds some quality-of-life features.
Fix Inline Redirects
This fixes a common annoying bug where an
{@redirect}
would fail if the author included a space between the@
and the trigger, for example{@ hello}
vs.{@hello}
.The redirect text is stripped of whitespace before being looked up which resolves that issue.
Fixes #145
More Documentation
Adds more documentation to the
rs.Promise
function, including a full example of how to usereplyAsync()
in conjunction with the object macro returning a promise.Also adds a link to the RiveScript Playground on the main README file.
Fixes #144
Optional Force Lowercasing of Triggers
This is a quality-of-life improvement for RiveScript authors who find it difficult to write the word
i
in lowercase for the sake of triggers (e.g.i am # years old
).This adds a
forceCase
option to the constructor which will force the parser to run all triggers through a.toLowerCase()
function. This should work for ASCII based bots and make it easier on the authors, but the documentation mentions the caveats of Unicode case folding and this option is not enabled by default for the same reason.Fixes #143
Fixes #69
Warnings with Hard Redirects
Here, a "hard redirect" refers to the top-level
@Redirect
command, as opposed to inline redirects with the{@}
tag appearing in a reply-portion of RiveScript.Hard redirects preempt all other commands, including
-Reply
and*Condition
; when a trigger has a hard redirect, the redirect is immediately followed and everything else on the initial trigger is ignored. This can be surprising behavior for some.During the parse phase, if an
@Redirect
command is found with siblings of-Reply
or*Condition
, a warning is given that you can't mix these mutually-exclusive commands.It is not a fatal warning, and the behavior of the bot is not changed from before (the
@Redirect
will still preempt any replies/conditions), but it lets the bot master know that an error was found and they should fix it.Fixes #58