From ec452298704d36a98b1c64ca449bc27b48cd56f6 Mon Sep 17 00:00:00 2001 From: random-access7 Date: Wed, 28 Feb 2018 01:17:09 +0530 Subject: [PATCH] labhub: Change regex pattern for 'invite_cmd' The original file used regex with '\s*' responsible for matching 0 or more whitespaces and led to matches like 'invite @userto developers' as there are 0 backspaces between '@user' and 'to'. With '\s+' atleast 1 whitespace is required for the regex to match such commands. Added a test to verify. Fixes https://github.com/coala/corobo/issues/512 --- plugins/labhub.py | 2 +- tests/labhub_test.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/labhub.py b/plugins/labhub.py index e9b2f54b..9402909c 100644 --- a/plugins/labhub.py +++ b/plugins/labhub.py @@ -72,7 +72,7 @@ def TEAMS(self, new): self._teams = new # Ignore LineLengthBear, PycodestyleBear - @re_botcmd(pattern=r'^(?:(?:welcome)|(?:inv)|(?:invite))\s+(?:(?:@?([\w-]+)(?:\s*(?:to)\s+(\w+))?)|(me))$', + @re_botcmd(pattern=r'^(?:(?:welcome)|(?:inv)|(?:invite))\s+(?:(?:@?([\w-]+)(?:\s+(?:to)\s+(\w+))?)|(me))$', re_cmd_name_help='invite ([@] [to ]|me)') def invite_cmd(self, msg, match): """ diff --git a/tests/labhub_test.py b/tests/labhub_test.py index ac5362d9..7bf87eab 100644 --- a/tests/labhub_test.py +++ b/tests/labhub_test.py @@ -59,6 +59,8 @@ def test_invite_cmd(self): testbot.assertCommand('!invite meet to developers', ':poop:') + testbot.assertCommand('!invite meetto newcomers', + 'Command "invite" / "invite meetto" not found.') def test_hello_world_callback(self): teams = { 'coala newcomers': self.mock_team,