aichaos / rivescript-js

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

"?" is not handled in the triggers #331

Open rblanc99 opened 4 years ago

rblanc99 commented 4 years ago

I am using Rivescript in a Node project.

I want to make the bot recognize questions, so i would like to do something like

+ * ? 
- {topic=questions}

But unfortunately, the bot can't handle the "?", I get a Triggers may only contain lowercase letters, numbers, and these symbols: ( | ) [ ] * _ # { } < > = / error.

I would very much appreciate that feature, thanks !

(Maybe this issue belongs in the rivescript repo and not rivescript-js, wasn't sure about it, sorry)

dcsan commented 4 years ago

i think that because rivescript uses a simplified version of regex, this feature would be hard to support. the simpler form makes it really easy for non-tech authors to use, but means more sophisticated regex features are missing. there was some thought of adding true regex but not much requests for that right now. https://github.com/aichaos/rivescript-js/issues/320

kirsle commented 4 years ago

Perhaps an alternative way to detect questions is to look at the first word of the message?

+ (who|what|how|why|when) *
- {topic=questions}{@<star1> <star2>}

Alternatively, your bot code can look for the ? mark and set a user variable before calling reply().