From fa2bc85082fd7d27b6d6a9549f88747762253787 Mon Sep 17 00:00:00 2001 From: Bryan Koroleski Date: Mon, 25 Mar 2013 18:52:00 -0500 Subject: [PATCH] Fixes .bitcoin command to use the new mtgox API. --- plugins/bitcoin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/bitcoin.py b/plugins/bitcoin.py index cdcb339..21625b6 100644 --- a/plugins/bitcoin.py +++ b/plugins/bitcoin.py @@ -4,7 +4,13 @@ from util import http, hook @hook.command(autohelp=False) def bitcoin(inp, say=None): ".bitcoin -- gets current exchange rate for bitcoins from mtgox" - data = http.get_json("https://mtgox.com/code/data/ticker.php") - ticker = data['ticker'] - say("Current: \x0307$%(buy).2f\x0f - High: \x0307$%(high).2f\x0f" - " - Low: \x0307$%(low).2f\x0f - Volume: %(vol)s" % ticker) + data = http.get_json("https://data.mtgox.com/api/2/BTCUSD/money/ticker") + data = data['data'] + ticker = { + 'buy': data['buy']['display_short'], + 'high': data['high']['display_short'], + 'low': data['low']['display_short'], + 'vol': data['vol']['display_short'], + } + say("Current: \x0307%(buy)s\x0f - High: \x0307%(high)s\x0f" + " - Low: \x0307%(low)s\x0f - Volume: %(vol)s" % ticker)