Permalink
Browse files

Merge pull request #98 from mexitek/coderwall

Coderwall Script
  • Loading branch information...
2 parents 8185e65 + 990be33 commit ad3ac71c63d4720a6643dea91a385bb311c5f0fb Tom Bell committed Nov 4, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 src/scripts/coderwall.coffee
@@ -0,0 +1,24 @@
+# Messing around with the Coderwall API.
+#
+# coderwall <coderwall username> - Returns coder achievements from coderwall.com
+#
+module.exports = (robot) ->
+ robot.respond /(coderwall)( me)? (.*)/i, (msg) ->
+ user = msg.match[3]
+ msg.http("http://coderwall.com/"+user+".json")
+ .get() (err, res, body) ->
+ # If not response bad username
+ if res.headers['content-length'] <= 1
+ letter_s = if user.substr(-1)=='s' then '' else 's'
+ msg.send "Sorry I cannot find "+user+"'"+letter_s+" coderwall"
+ # Else return the coder badges
+ else
+ profile = JSON.parse(body)
+ # Give an intro to the coderwall profile
+ resp_str = "";
+ resp_str += user + "'s coderwall -> http://coderwall.com/"+user + "\n"
+ # Iterate all badges and continue building string
+ profile.badges.forEach (badge) ->
+ resp_str += badge.name + " - " + badge.description + "\n"
+ # Return response
+ msg.send resp_str

0 comments on commit ad3ac71

Please sign in to comment.