Skip to content

Commit

Permalink
Merge branch 'master' into groupme
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Oct 6, 2011
2 parents 6b88a90 + 8136360 commit 237e209
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hubot/scripts/math.coffee
@@ -0,0 +1,16 @@
# Allows Hubot to do mathematics.
#
# math me <expression> - Calculate the given expression.
# convert me <expression> to <units> - Convert expression to given units.
module.exports = (robot) ->
robot.respond /(calc|calculate|convert|math)( me)? (.*)/i, (msg) ->
msg
.http('http://www.google.com/ig/calculator')
.query(hl: 'en', q: msg.match[3])
.headers
'Accept-Language' : 'en-us,en;q=0.5',
'Accept-Charset' : 'utf-8',
'User-Agent' : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"
.get() (err, res, body) ->
json = eval("(#{body})") # non-string json keys
msg.send json.rhs

0 comments on commit 237e209

Please sign in to comment.