@@ -64,13 +64,13 @@ module.exports = (robot) ->
64
64
65
65
robot .auth = new Auth
66
66
67
- robot .respond / @? (. + ) ha(s| ve) (["'\w : -_ ] + ) role/ i , (msg ) ->
67
+ robot .respond / @? ([ ^ \s ] + ) ha(?: s| ve) (["'\w : -_ ] + ) role/ i , (msg ) ->
68
68
unless robot .auth .isAdmin msg .message .user
69
69
msg .reply " Sorry, only admins can assign roles."
70
70
else
71
71
name = msg .match [1 ].trim ()
72
72
if name .toLowerCase () is ' i' then name = msg .message .user .name
73
- newRole = msg .match [3 ].trim ().toLowerCase ()
73
+ newRole = msg .match [2 ].trim ().toLowerCase ()
74
74
75
75
unless name .toLowerCase () in [' ' , ' who' , ' what' , ' where' , ' when' , ' why' ]
76
76
user = robot .brain .userForName (name)
@@ -87,13 +87,13 @@ module.exports = (robot) ->
87
87
user .roles .push (newRole)
88
88
msg .reply " OK, #{ name} has the '#{ newRole} ' role."
89
89
90
- robot .respond / @? (. + ) do(n ['’] t| esn ['’] t| es)( not)? have (["'\w : -_ ] + ) role/ i , (msg ) ->
90
+ robot .respond / @? ([ ^ \s ] + ) (?:don ['’] t| doesn ['’] t| do not) have (["'\w : -_ ] + ) role/ i , (msg ) ->
91
91
unless robot .auth .isAdmin msg .message .user
92
92
msg .reply " Sorry, only admins can remove roles."
93
93
else
94
94
name = msg .match [1 ].trim ()
95
95
if name .toLowerCase () is ' i' then name = msg .message .user .name
96
- newRole = msg .match [4 ].trim ().toLowerCase ()
96
+ newRole = msg .match [2 ].trim ().toLowerCase ()
97
97
98
98
unless name .toLowerCase () in [' ' , ' who' , ' what' , ' where' , ' when' , ' why' ]
99
99
user = robot .brain .userForName (name)
@@ -107,7 +107,7 @@ module.exports = (robot) ->
107
107
user .roles = (role for role in user .roles when role isnt newRole)
108
108
msg .reply " OK, #{ name} doesn't have the '#{ newRole} ' role."
109
109
110
- robot .respond / what roles? do(es)? @? (. + ) have\? * $ / i , (msg ) ->
110
+ robot .respond / what roles? do(es)? @? ([ ^ \s ] + ) have\? * $ / i , (msg ) ->
111
111
name = msg .match [2 ].trim ()
112
112
if name .toLowerCase () is ' i' then name = msg .message .user .name
113
113
user = robot .brain .userForName (name)
0 commit comments