*dance*
This commit is contained in:
parent
be3df6718f
commit
57e53e8eb7
1 changed files with 33 additions and 29 deletions
|
@ -1,38 +1,41 @@
|
||||||
from util import http, hook
|
from util import http, hook
|
||||||
|
|
||||||
|
## CONSTANTS
|
||||||
|
|
||||||
|
exchanges = {
|
||||||
|
"blockchain": {
|
||||||
|
"api_url": "https://blockchain.info/ticker",
|
||||||
|
"func": lambda data: u"Blockchain // Buy: \x0307${:,.2f}\x0f - Sell: \x0307${:,.2f}\x0f".format(data["USD"]["buy"], \
|
||||||
|
data["USD"]["sell"])
|
||||||
|
},
|
||||||
|
"mtgox": {
|
||||||
|
"api_url": "https://mtgox.com/api/1/BTCUSD/ticker",
|
||||||
|
"func": lambda data: u"MtGox // Current: \x0307{}\x0f - High: \x0307{}\x0f - Low: \x0307{}\x0f - Best Ask: \x0307{}\x0f - Volume: {}".format(data['return']['last']['display'], \
|
||||||
|
data['return']['high']['display'], data['return']['low']['display'], data['return']['buy']['display'], \
|
||||||
|
data['return']['vol']['display'])
|
||||||
|
},
|
||||||
|
"coinbase":{
|
||||||
|
"api_url": "https://coinbase.com/api/v1/prices/spot_rate",
|
||||||
|
"func": lambda data: u"Coinbase // Current: \x0307${:,.2f}\x0f".format(float(data['amount']))
|
||||||
|
},
|
||||||
|
"bitpay": {
|
||||||
|
"api_url": "https://bitpay.com/api/rates",
|
||||||
|
"func": lambda data: u"Bitpay // Current: \x0307${:,.2f}\x0f".format(data[0]['rate'])
|
||||||
|
},
|
||||||
|
"bitstamp": {
|
||||||
|
"api_url": "https://www.bitstamp.net/api/ticker/",
|
||||||
|
"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']))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## HOOK FUNCTIONS
|
||||||
|
|
||||||
@hook.command("butt", autohelp=False)
|
|
||||||
@hook.command("btc", autohelp=False)
|
@hook.command("btc", autohelp=False)
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def bitcoin(inp):
|
def bitcoin(inp):
|
||||||
"bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp."
|
"""bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp."""
|
||||||
exchanges = {
|
|
||||||
"blockchain": {
|
|
||||||
"api_url": "https://blockchain.info/ticker",
|
|
||||||
"func": lambda data: u"Blockchain // Buy: \x0307${:,.2f}\x0f - Sell: \x0307${:,.2f}\x0f".format(data["USD"]["buy"], \
|
|
||||||
data["USD"]["sell"])
|
|
||||||
},
|
|
||||||
"mtgox": {
|
|
||||||
"api_url": "https://mtgox.com/api/1/BTCUSD/ticker",
|
|
||||||
"func": lambda data: u"MtGox // Current: \x0307{}\x0f - High: \x0307{}\x0f - Low: \x0307{}\x0f - Best Ask: \x0307{}\x0f - Volume: {}".format(data['return']['last']['display'], \
|
|
||||||
data['return']['high']['display'], data['return']['low']['display'], data['return']['buy']['display'], \
|
|
||||||
data['return']['vol']['display'])
|
|
||||||
},
|
|
||||||
"coinbase":{
|
|
||||||
"api_url": "https://coinbase.com/api/v1/prices/spot_rate",
|
|
||||||
"func": lambda data: u"Coinbase // Current: \x0307${:,.2f}\x0f".format(float(data['amount']))
|
|
||||||
},
|
|
||||||
"bitpay": {
|
|
||||||
"api_url": "https://bitpay.com/api/rates",
|
|
||||||
"func": lambda data: u"Bitpay // Current: \x0307${:,.2f}\x0f".format(data[0]['rate'])
|
|
||||||
},
|
|
||||||
"bitstamp": {
|
|
||||||
"api_url": "https://www.bitstamp.net/api/ticker/",
|
|
||||||
"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']))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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"""
|
||||||
|
|
Reference in a new issue