Skip to content

Commit 858dd6d

Browse files
authored
Merge pull request aichaos#99 from Dinh-Hung-Tu/aichaos#98
aichaos#98 Strip space in options
2 parents 9fc7ed3 + 7c87e41 commit 858dd6d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

rivescript/brain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def reply_regexp(self, user, regexp):
447447
parts = match.split("|")
448448
new = []
449449
for p in parts:
450-
p = r'(?:\\s|\\b)+{}(?:\\s|\\b)+'.format(p)
450+
p = r'(?:\\s|\\b)+{}(?:\\s|\\b)+'.format(p.strip())
451451
new.append(p)
452452

453453
# If this optional had a star or anything in it, make it

tests/test_format.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ def test_invalid_character_raise_exception(self):
6666
my ($rs, $args) = @_;
6767
my $method = shift @{$args};
6868
<object
69-
""") # No exception raised for uppercase character in object
69+
""") # No exception raised for uppercase character in object
70+
71+
def test_space_tolerance_with_pipe(self):
72+
self.new("""
73+
+ hey [ a | b|c ]
74+
- hi
75+
""")
76+
for message in ['hey a', 'hey b', 'hey c']:
77+
self.reply(message, "hi")

0 commit comments

Comments
 (0)