-
Notifications
You must be signed in to change notification settings - Fork 7
/
snitch.coffee
40 lines (37 loc) · 1.03 KB
/
snitch.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Snitch adapter, displays people in the office
# Need snitch?
#
# who's in the office - List everyone in the office
# Description:
# Talks to snitch to let you know who is in the office
#
# Dependencies:
# github-credentials
#
# Configuration:
# None
#
# Commands:
# hubot who's in the office - Tells you who it sees in the office
#
# Notes:
# You need to setup a snitch server somewhere first. Get it at
# https://github.com/martinisoft/snitch
#
# Author:
# martinisoft
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?"