Skip to content

Commit 9fc7ed3

Browse files
authored
Merge pull request aichaos#97 from Dinh-Hung-Tu/aichaos#86
Fix aichaos#86 and allow continue ^ in triggers
2 parents a2d0137 + 3d13551 commit 9fc7ed3

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

rivescript/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def parse(self, filename, code):
215215
continue
216216
lookCmd = lookahead[0]
217217
lookahead = lookahead[1:].strip()
218+
lookahead = re.sub(RE.space, ' ', lookahead) # Replace the `\s` in the message
218219

219220
# Only continue if the lookahead line has any data.
220221
if len(lookahead) != 0:

rivescript/regexp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class RE(object):
1515
equals = re.compile('\s*=\s*')
1616
ws = re.compile('\s+')
17+
space = re.compile('\\\\s')
1718
objend = re.compile('^\s*<\s*object')
1819
weight = re.compile(r'\s*\{weight=(\d+)\}\s*')
1920
inherit = re.compile('\{inherits=(\d+)\}')

tests/test_options.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ def test_concat(self):
3636
- Hello
3737
^ world!
3838
39+
! local concat = none
40+
+ test concat
41+
^ in trigger
42+
- Hello
43+
^ world!
44+
45+
! local concat = none
46+
+ [test] concat
47+
^ \sin trigger with space and optional
48+
- Hello
49+
^ \sworld!
50+
51+
! local concat = space
52+
+ test concat space
53+
^ in trigger
54+
- Hello
55+
^ world!
56+
3957
// the option is file scoped so it can be left at
4058
// any setting and won't affect subsequent parses
4159
! local concat = newline
@@ -53,3 +71,6 @@ def test_concat(self):
5371
self.reply("test concat none", "Helloworld!")
5472
self.reply("test concat newline", "Hello\nworld!")
5573
self.reply("test concat second file", "Helloworld!")
74+
self.reply("test concatin trigger", "Helloworld!")
75+
self.reply("test concat in trigger with space and optional", "Hello world!")
76+
self.reply("test concat space in trigger", "Hello world!")

0 commit comments

Comments
 (0)