Commit 4297154 1 parent d1c5515 commit 4297154 Copy full SHA for 4297154
File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -28,3 +28,28 @@ Run `npm install`
28
28
user1>> hubot user2 has jester role
29
29
hubot>> OK, user2 has the jester role.
30
30
```
31
+
32
+ ## Sample Usage
33
+ ### Restricting commands
34
+ ``` coffee
35
+ module .exports = (robot ) ->
36
+ # Command listener
37
+ robot .respond / some command/ i , (msg ) ->
38
+ role = ' some-role'
39
+ user = robot .brain .userForName (msg .message .user .name )
40
+ return msg .reply " #{ name} does not exist" unless user?
41
+ unless robot .auth .hasRole (user, role)
42
+ msg .reply " Access Denied. You need role #{ role} to perform this action."
43
+ return
44
+ # Some commandy stuff
45
+ msg .reply ' Command done!'
46
+ ```
47
+ ### Example Interaction
48
+ ```
49
+ user2>> hubot some command
50
+ hubot>> Access Denied. You need role some-role to perform this action.
51
+ user1>> hubot user2 has some-role role
52
+ hubot>> OK, user2 has the some-role role.
53
+ user2>> hubot some command
54
+ hubot>> Command done!
55
+ ```
You can’t perform that action at this time.
0 commit comments