Skip to content

Commit

Permalink
labhub: Change regex pattern for 'invite_cmd'
Browse files Browse the repository at this point in the history
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 coala#512
  • Loading branch information
aabhaas-vaish committed Mar 4, 2018
1 parent 2cdd906 commit ec45229
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([@]<username> [to <team>]|me)')
def invite_cmd(self, msg, match):
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ec45229

Please sign in to comment.