Skip to content

Commit aa26f13

Browse files
committed
elvis hometown dpritchett
1 parent 0713571 commit aa26f13

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ node_modules
22
.DS_Store*
33
.hubot_history
44
app.json
5+
6+
7+
# vimmy horribleness
8+
*.swp
9+
*~

scripts/hometown.coffee

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Description:
2+
# Show slack user's hometown from github.com/memtech/people
3+
#
4+
# Dependencies:
5+
# None
6+
#
7+
# Configuration:
8+
# None
9+
#
10+
# Commands:
11+
# elvis hometown dpritchett - show slack user @dpritchett's home town on a map
12+
#
13+
# Author:
14+
# Daniel J. Pritchett <[email protected]>
15+
16+
module.exports = (robot) ->
17+
JSON_SOURCE_URI = "https://raw.githubusercontent.com/memtech/people/gh-pages/js/locations.js"
18+
REPO_URI = "https://github.com/memtech/people"
19+
MAP_URI_BASE= "http://maps.google.com/maps?z=17&q="
20+
21+
mapUri = (user) ->
22+
"#{MAP_URI_BASE}#{user.latitude},#{user.longitude}"
23+
24+
robot.respond /hometown (\w+)$/i, (msg) ->
25+
username = msg.match[1]
26+
console.log username
27+
28+
msg.http(JSON_SOURCE_URI)
29+
.get() (err, res, body) ->
30+
if res.statusCode == 404
31+
msg.send 'Map URI not responding'
32+
else
33+
hax = eval body
34+
35+
for user in locations
36+
if user.slack_handle is username
37+
return msg.send "#{user.name} hails from #{user.origin}! #{mapUri(user)}"
38+
39+
msg.send "User #{username} not found. Make sure there's a `slack_handle` listed for this user at #{REPO_URI}"

0 commit comments

Comments
 (0)