This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/bitcoin.py

17 lines
743 B
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
from util import http, hook
@hook.command(autohelp=False)
2013-10-01 05:55:18 +02:00
def bitcoin(inp, message=None):
2013-09-04 12:30:04 +02:00
"""bitcoin -- gets current exchange rate for bitcoins from mtgox"""
data = http.get_json("https://data.mtgox.com/api/2/BTCUSD/money/ticker")
data = data['data']
ticker = {
2013-09-06 05:20:34 +02:00
'buy': data['buy']['display_short'].encode('ascii','ignore'),
'high': data['high']['display_short'].encode('ascii','ignore'),
'low': data['low']['display_short'].encode('ascii','ignore'),
'vol': data['vol']['display_short'].encode('ascii','ignore'),
}
2013-10-01 05:55:18 +02:00
message("Current: \x0307{!s}\x0f - High: \x0307{!s}\x0f"
2013-09-06 05:20:34 +02:00
" - Low: \x0307{!s}\x0f - Volume: {!s}".format(ticker['buy'],ticker['high'],ticker['low'],ticker['vol']))