This commit is contained in:
Luke Rogers 2013-12-02 23:16:34 +13:00
parent be3df6718f
commit 57e53e8eb7

View file

@ -1,12 +1,8 @@
from util import http, hook from util import http, hook
## CONSTANTS
@hook.command("butt", autohelp=False) exchanges = {
@hook.command("btc", autohelp=False)
@hook.command(autohelp=False)
def bitcoin(inp):
"bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp."
exchanges = {
"blockchain": { "blockchain": {
"api_url": "https://blockchain.info/ticker", "api_url": "https://blockchain.info/ticker",
"func": lambda data: u"Blockchain // Buy: \x0307${:,.2f}\x0f - Sell: \x0307${:,.2f}\x0f".format(data["USD"]["buy"], \ "func": lambda data: u"Blockchain // Buy: \x0307${:,.2f}\x0f - Sell: \x0307${:,.2f}\x0f".format(data["USD"]["buy"], \
@ -31,8 +27,15 @@ def bitcoin(inp):
"func": lambda data: u"BitStamp // Current: \x0307${:,.2f}\x0f - High: \x0307${:,.2f}\x0f - Low: \x0307${:,.2f}\x0f - Volume: {:,.2f} BTC".format(float(data['last']), float(data['high']), float(data['low']), \ "func": lambda data: u"BitStamp // Current: \x0307${:,.2f}\x0f - High: \x0307${:,.2f}\x0f - Low: \x0307${:,.2f}\x0f - Volume: {:,.2f} BTC".format(float(data['last']), float(data['high']), float(data['low']), \
float(data['volume'])) float(data['volume']))
} }
} }
## HOOK FUNCTIONS
@hook.command("btc", autohelp=False)
@hook.command(autohelp=False)
def bitcoin(inp):
"""bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp."""
inp = inp.lower() inp = inp.lower()
if inp: if inp:
@ -48,6 +51,7 @@ def bitcoin(inp):
return func(data) return func(data)
@hook.command("ltc", autohelp=False)
@hook.command(autohelp=False) @hook.command(autohelp=False)
def litecoin(inp, message=None): def litecoin(inp, message=None):
"""litecoin -- gets current exchange rate for litecoins from BTC-E""" """litecoin -- gets current exchange rate for litecoins from BTC-E"""