Permalink
Browse files

Merge pull request #257 from christierney/master

Don't try to add or remove roles for empty names
  • Loading branch information...
2 parents a66563a + e057881 commit 07316362fb68687f17ec73bb8fbde213e1eb07f2 @tombell tombell committed Mar 20, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/scripts/roles.coffee
@@ -35,10 +35,10 @@ module.exports = (robot) ->
msg.send "#{name}? Never heard of 'em"
robot.respond /@?([\w .-_]+) is (["'\w: -_]+)[.!]*$/i, (msg) ->
- name = msg.match[1]
+ name = msg.match[1].trim()
newRole = msg.match[2].trim()
- unless name in ['who', 'what', 'where', 'when', 'why']
+ unless name in ['', 'who', 'what', 'where', 'when', 'why']
unless newRole.match(/^not\s+/i)
users = robot.usersForFuzzyName(name)
if users.length is 1
@@ -59,10 +59,10 @@ module.exports = (robot) ->
msg.send "I don't know anything about #{name}."
robot.respond /@?([\w .-_]+) is not (["'\w: -_]+)[.!]*$/i, (msg) ->
- name = msg.match[1]
+ name = msg.match[1].trim()
newRole = msg.match[2].trim()
- unless name in ['who', 'what', 'where', 'when', 'why']
+ unless name in ['', 'who', 'what', 'where', 'when', 'why']
users = robot.usersForFuzzyName(name)
if users.length is 1
user = users[0]

0 comments on commit 0731636

Please sign in to comment.