Permalink
Browse files

Script to fetch stock prices

  • Loading branch information...
1 parent 84eb4b2 commit e7e679f8361a346723378ea808574510009982be Eli Perkins committed May 22, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/scripts/stock.coffee
View
@@ -0,0 +1,14 @@
+# Get a stock price
+#
+# stock <info|quote|price> for <ticker> - Get a stock price
+#
+# Developed by One Mighty Roar - http://github.com/onemightyroar
+
+module.exports = (robot) ->
+ robot.respond /stock (info|price|quote) for @?([\w .-_]+)/i, (msg) ->
+ ticker = escape(msg.match[2])
+ msg.http('http://finance.google.com/finance/info?client=ig&q=' + ticker)
+ .get() (err, res, body) ->
+ result = JSON.parse(body.replace(/\/\/ /, ''))
+
+ msg.send result[0].l_cur + "(#{result[0].c})"

0 comments on commit e7e679f

Please sign in to comment.