Fixed top and xmr
This commit is contained in:
parent
6af75e9049
commit
8da04665ca
34
price.py
34
price.py
|
@ -375,32 +375,27 @@ def cmc(bot, trigger):
|
|||
|
||||
@sopel.module.commands('top')
|
||||
def top(bot, trigger):
|
||||
if not trigger.group(2):
|
||||
bot.say("You want to see the CMC top... how many? Pick a number 1 through 20")
|
||||
else:
|
||||
topXstring = ""
|
||||
try:
|
||||
try:
|
||||
r = requests.get('https://api.coinmarketcap.com/v1/global/')
|
||||
j = r.json()
|
||||
usd_total_mkt_cap = float(j['total_market_cap_usd'])
|
||||
total_mcap_short = int(int(round(usd_total_mkt_cap,-9))/int(1e9))
|
||||
rounded_total_mcap = str(total_mcap_short)+"B"
|
||||
topXstring += "Total market cap $" + rounded_total_mcap + " | "
|
||||
except:
|
||||
bot.say("Can't connect to coinmarketcap API")
|
||||
if not trigger.group(2):
|
||||
limit = 20
|
||||
else:
|
||||
limit = int(trigger.group(2))
|
||||
if limit > 20:
|
||||
bot.say("Too high! Max is 20!")
|
||||
elif limit < 1:
|
||||
bot.say("Dude...")
|
||||
else:
|
||||
topXstring = ""
|
||||
try:
|
||||
r = requests.get('https://api.coinmarketcap.com/v1/global/')
|
||||
j = r.json()
|
||||
usd_total_mkt_cap = float(j[0]['total_market_cap_usd'])
|
||||
total_mcap_short = int(int(round(usd_total_mkt_cap,-9))/int(1e9)
|
||||
rounded_total_mcap = str(total_mcap_short)+"B"
|
||||
topXstring += "Total market cap $" + rounded_total_mcap + " | "
|
||||
except:
|
||||
bot.say("Can't connect to coinmarketcap API")
|
||||
try:
|
||||
r = requests.get('https://api.coinmarketcap.com/v1/ticker?limit={}'.format(limit))
|
||||
j = r.json()
|
||||
except:
|
||||
bot.say("Can't connect to API")
|
||||
|
||||
for i in j:
|
||||
symbol = i['symbol']
|
||||
name = i['name']
|
||||
|
@ -641,13 +636,12 @@ def xmrtall(bot, trigger):
|
|||
bot.say("Something borked ¤\( `⌂´ )/¤")
|
||||
|
||||
# Binance
|
||||
|
||||
try:
|
||||
r = requests.get(binanceurl)
|
||||
j = r.json()
|
||||
found = False
|
||||
for i in j:
|
||||
if i["symbol"] == XMR+BTC:
|
||||
if i["symbol"] == "XMRBTC":
|
||||
last=float(i['lastPrice'])
|
||||
vol=float(i['volume'])
|
||||
stringtosend += ("Binance last: {0:.6f} on {1:.2f} BTC volume |".format(last, vol*last))
|
||||
|
|
Loading…
Reference in New Issue