Permalink
Browse files

Replace !fb with $fb, which works for all stock tickers: $aapl, $goog…

…, etc
  • Loading branch information...
1 parent 60ba96c commit dee547394dce3333d86a84f65ac6b5dfdc7ec766 @jamiew committed May 21, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 fatbot.rb
View
9 fatbot.rb
@@ -213,10 +213,15 @@ def ops?(nick)
end
on :channel, /^!(fb|facebook)$/i do
- url = "http://download.finance.yahoo.com/d/quotes.csv?s=FB&f=sb2b3jk"
+ msg channel, "DEPRECATED, type \"$fb\" instead. That syntax works for any stock ticker"
+end
+
+on :channel, /^\$(.*)$/i do
+ ticker = match[0].to_s.upcase
+ url = "http://download.finance.yahoo.com/d/quotes.csv?s=#{ticker}&f=sb2b3jk"
raw = open(url).read.chomp
data = raw.split(',')
- msg channel, "Current $FB price: #{data[1]} -- http://bit.ly/nasdaq_fb"
+ msg channel, "Current $#{ticker} price: #{data[1]} -- http://www.google.com/finance?q=#{ticker}"
end

0 comments on commit dee5473

Please sign in to comment.