File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,8 @@ node_modules
2
2
.DS_Store *
3
3
.hubot_history
4
4
app.json
5
+
6
+
7
+ # vimmy horribleness
8
+ * .swp
9
+ * ~
Original file line number Diff line number Diff line change
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} "
You can’t perform that action at this time.
0 commit comments