Skip to content

Commit

Permalink
explain.py: Recognize beginning and end of string
Browse files Browse the repository at this point in the history
Add ^ and $ to the regex so the command is not triggered
from anywhere in the capture string

Closes #364
  • Loading branch information
supergr35 committed Nov 27, 2017
1 parent 35587aa commit 340bf99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Explain(BotPlugin):
'\n- '.join(MSGS.keys())
)

@re_botcmd(pattern=r'explain\s+(\w+)(?:\s+to\s+@?([\w-]+))?',
@re_botcmd(pattern=r'^explain\s+(\w+)(?:\s+to\s+@?([\w-]+))?$',
re_cmd_name_help='explain <term>',
flags=re.IGNORECASE)
def explain(self, msg, match):
Expand Down
2 changes: 2 additions & 0 deletions tests/explain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ def test_explain(testbot):
text.convert(Explain.ERROR_MSG))
testbot.assertCommand("!explain review to @meet",
'@meet')
testbot.assertCommand("!please explain review",
"Command \"please\" / \"please explain\" not found.")

0 comments on commit 340bf99

Please sign in to comment.