aichaos / rivescript-js

A RiveScript interpreter for JavaScript. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
377 stars 145 forks source link

Bug in working draft document #373

Open johnnymast opened 3 years ago

johnnymast commented 3 years ago

While developing Rivescript-php I noticed a bug in the working draft document for Rivescript.

Here is the script:

  + <input1>
  * <input1> eq <input2> => That's the second time you've repeated yourself.
  * <input1> eq <input3> => If you repeat yourself again I'll stop talking to you.
  * <input1> eq <input4> => That's it. I'm done talking to you.{topic=blocked}
  - Please don't repeat yourself.

All lines past are unreachable.

 * <input1> eq <input2> => That's the second time you've repeated yourself.

Fix:

Update document accordingly.

kirsle commented 3 years ago

Hey, thanks for pointing this out. That code example was probably written without testing when I was writing the working draft. 😅

The input checks had to be flipped in a different order (<input4> first):

+ <input1>
* <input1> eq <input4> => That's it. I'm done talking to you.{topic=blocked}
* <input1> eq <input3> => If you repeat yourself again I'll stop talking to you.
* <input1> eq <input2> => That's the second time you've repeated yourself.
- Please don't repeat yourself.

> topic blocked
    // NOTE: "<noreply>" is handled in your bot's code, to not
    // show a reply to the user; it isn't a RiveScript tag.
    + *
    - <noreply>

    + sorry
    - {topic=random}Ok I'll forgive you.
< topic

Playground link: https://play.rivescript.com/s/4LBzyPNBRz

I've updated the Working Draft to fix this example with a more fleshed out version: https://github.com/aichaos/rivescript-wd/blob/master/WD.rst#input1-input9-reply1-reply9

Also, the <noreply> tag is now officially guaranteed to never be used by RiveScript; in my chatbots I've always returned a literal <noreply> string to my program so it would know not to deliver a response back to my message. That use case comes in handy sometimes!

(the Playground site doesn't handle <noreply> tags yet and tries to show it as literal HTML and you get an empty response bubble)

johnnymast commented 3 years ago

Thanks, I will check this out and might even make it a test case in my project.