aichaos / rivescript-python

A RiveScript interpreter for Python. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com
MIT License
158 stars 72 forks source link

Short discussions don't work with line breaking #49

Open jps81 opened 7 years ago

jps81 commented 7 years ago

Using a slightly modified example from the documentation (with an added newline):

+ knock knock
- Who's \n
^ there?

+ *
% who * there
- <star> who?

+ *
% * who
- LOL! <star>! That's funny!

If I now follow the script, the final statement (LOL ...) is never reached. I suspect it is probably due to how the regex matching is being done here https://github.com/aichaos/rivescript-python/blob/master/rivescript/brain.py#L503. Adding the re.DOTALL flag would most likely fix this issue, but not sure if that is the correct answer here (I'm relatively new to rivescript). Any thoughts?

htdinh commented 7 years ago

Assuming there is no substitution to convert from who's to who is, this script doesn't work on my computer. When I keep the script into the explicit form who is,

+ knock knock
- Who is \n
^ there?

+ *
% who * there
- <star> who?

+ *
% * who
- LOL! <star>! That's funny!

The flow of this discussion works again.

Type /quit when you're done to exit this example.

You> knock knock 
Bot> Who is 
there?
You> orange  
Bot> orange who?
You> banana
Bot> LOL! banana! That's funny!
You> 

@kirsle As I can't reproduce the bug, can you please confirm if there is still a bug here?