Permalink
Browse files

Add snitch hubot module

  • Loading branch information...
1 parent cc3ab19 commit 215233c9b8c007c3204c128ab08a999c4e5df07d @martinisoft martinisoft committed Jan 6, 2012
Showing with 28 additions and 0 deletions.
  1. +8 −0 README.md
  2. +20 −0 snitch.coffee
View
@@ -58,3 +58,11 @@ Requirements
* Ruby 1.9.x (This app comes with an rvmrc for 1.9.3-p0)
* Airport Extreme/Express router that has SNMP Enabled
+
+BONUS ROUND!
+------------
+
+Want to teach hubot how to talk to snitch? Load the snitch.coffee module into
+[Hubot](https://github.com/github/hubot). Make sure you also load the
+github-credentials.coffee module from github-scripts, because it matches
+names from there.
View
@@ -0,0 +1,20 @@
+# Snitch adapter, displays people in the office
+# Need snitch? https://github.com/martinisoft/snitch
+#
+# who's in the office - List everyone in the office
+module.exports = (robot) ->
+ robot.respond /who's in the office/i, (msg) ->
+ theReply = "Here is who I see:\n"
+ msg.http("http://localhost:9292/who")
+ .get() (err, res, body) ->
+ switch res.statusCode
+ when 200
+ people = body.split(",")
+ for person in people
+ for own key, user of robot.brain.data.users
+ if (user.githubLogin == person)
+ theReply += user.name + "\n"
+
+ msg.send theReply
+ else
+ msg.send "Unable to ask snitch, is it dead?"

0 comments on commit 215233c

Please sign in to comment.