Merge pull request #63 from scoobybejesus/patch-9

Make friendly for python3
This commit is contained in:
jw 2021-07-11 11:47:22 -04:00 committed by GitHub
commit 224b2c1604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 22 deletions

View File

@ -225,10 +225,10 @@ def krak(bot, trigger):
try: try:
r=requests.get(kraktrig+coin+'XBT') r=requests.get(kraktrig+coin+'XBT')
j=r.json() j=r.json()
stringtosay += "{0} at {1:.8f} on {2:.2f} 24 h {0} volume. ".format(coin, float(j['result']['X'+str(coin)+'XXBT']['c'][0]), float(j['result']['X'+str(coin)+'XXBT']['v'][1])) stringtosay += "{0} at {1:.8f} on {2:.2f} 24 h {0} volume. ".format(coin, float(j['result']['X'+str(coin)+'XXBT']['c'][0]), float(j['result']['X'+str(coin)+'XXBT']['v'][1]))
except: except:
bot.say("Error connecting to Kraken") bot.say("Error connecting to Kraken")
try: try:
bot.say(stringtosay) bot.say(stringtosay)
except: except:
bot.say("Error getting data") bot.say("Error getting data")
@ -243,11 +243,11 @@ def lending(bot, trigger):
currenttime=time.time() currenttime=time.time()
for i in j['offers']: for i in j['offers']:
amnt+=float(i['amount']) amnt+=float(i['amount'])
bot.say("Total amount of XMR available {0:,.2f}. Changed by {1:.2f} in the last {2:.2f} hours".format(amnt, amnt-prevamnt, (currenttime-prevtime)/3600))
global prevamnt global prevamnt
prevamnt=amnt prevamnt=amnt
global prevtime global prevtime
prevtime=currenttime prevtime=currenttime
bot.say("Total amount of XMR available {0:,.2f}. Changed by {1:.2f} in the last {2:.2f} hours".format(amnt, amnt-prevamnt, (currenttime-prevtime)/3600))
except: except:
bot.say("Something bad happened :o") bot.say("Something bad happened :o")
@ -276,7 +276,6 @@ def metal(bot, trigger):
@sopel.module.commands('polo', 'poloniex', 'marco', 'plol') @sopel.module.commands('polo', 'poloniex', 'marco', 'plol')
@sopel.module.interval(3600)
def polo(bot, trigger): def polo(bot, trigger):
if not trigger.group(2): if not trigger.group(2):
try: try:
@ -290,21 +289,21 @@ def polo(bot, trigger):
sign = '+' sign = '+'
else: else:
sign = '' sign = ''
face = '' face = u'\u0000'
if change > 0.10: if change > 0.10:
face = u'\u263d'.encode('utf8') face = u'\u263d'
if 0.10 >= change > 0.05: if 0.10 >= change > 0.05:
face = u'\u2661'.encode('utf8') face = u'\u2661'
if 0.05 >= change > 0.02: if 0.05 >= change > 0.02:
face = u'\u263a'.encode('utf8') face = u'\u263a'
if 0.02 >= change > -0.02: if 0.02 >= change > -0.02:
face = u'\u2694'.encode('utf8') face = u'\u2694'
if -0.02 >= change > -0.05: if -0.02 >= change > -0.05:
face = u'\u2639'.encode('utf8') face = u'\u2639'
if -0.05 >= change > -0.1: if -0.05 >= change > -0.1:
face = u'\u2620'.encode('utf8') face = u'\u2620'
if change < -0.1: if change < -0.1:
face = u'\u262d'.encode('utf8') face = u'\u262d'
bot.say("Poloniex at {0:.8f} BTC; {1}{2:.2f}% over 24 hours on {3:.3f} BTC volume {4}".format(last, sign, change*100, vol, face)) bot.say("Poloniex at {0:.8f} BTC; {1}{2:.2f}% over 24 hours on {3:.3f} BTC volume {4}".format(last, sign, change*100, vol, face))
except: except:
bot.say("Error retrieving data from Poloniex") bot.say("Error retrieving data from Poloniex")
@ -469,8 +468,8 @@ def top(bot, trigger):
elif limit < 1: elif limit < 1:
bot.say("Dude...") bot.say("Dude...")
return return
r = requests.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page={}&page=1&sparkline=false'.format(limit)) r = requests.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page={}&page=1&sparkline=false'.format(limit))
j = r.json() j = r.json()
for i in j: for i in j:
symbol = i['symbol'] symbol = i['symbol']
name = i['name'] name = i['name']
@ -519,7 +518,7 @@ def tall(bot, trigger):
stampresult = requests.get(stampurl) stampresult = requests.get(stampurl)
stampjson = stampresult.json() stampjson = stampresult.json()
except: except:
stampjson = False stampjson = False
if stampjson: if stampjson:
stringtosend += "Bitstamp last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(stampjson['last']), float(stampjson['volume'])) stringtosend += "Bitstamp last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(stampjson['last']), float(stampjson['volume']))
# Gemini # Gemini
@ -527,7 +526,7 @@ def tall(bot, trigger):
gemiresult = requests.get(gemiurl) gemiresult = requests.get(gemiurl)
gemijson = gemiresult.json() gemijson = gemiresult.json()
except: except:
gemijson = False gemijson = False
if gemijson: if gemijson:
try: try:
stringtosend += "Gemini last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(gemijson['last']), float(gemijson['volume']['BTC'])) stringtosend += "Gemini last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(gemijson['last']), float(gemijson['volume']['BTC']))
@ -540,7 +539,7 @@ def tall(bot, trigger):
gdaxprice = float(gdaxjson['price']) gdaxprice = float(gdaxjson['price'])
gdaxvolume = float(gdaxjson['volume']) gdaxvolume = float(gdaxjson['volume'])
except: except:
gdaxjson = False gdaxjson = False
if gdaxjson: if gdaxjson:
stringtosend += "CBP last: ${0:,.2f}, vol: {1:,.1f} | ".format(gdaxprice, gdaxvolume) stringtosend += "CBP last: ${0:,.2f}, vol: {1:,.1f} | ".format(gdaxprice, gdaxvolume)
# Binance # Binance
@ -552,7 +551,7 @@ def tall(bot, trigger):
binanceprice = float(i['lastPrice']) binanceprice = float(i['lastPrice'])
binancevolume = float(i['volume']) binancevolume = float(i['volume'])
except: except:
binancejson = False binancejson = False
if binancejson: if binancejson:
stringtosend += "Binance last: ${0:,.2f}, vol: {1:,.1f} | ".format(binanceprice, binancevolume) stringtosend += "Binance last: ${0:,.2f}, vol: {1:,.1f} | ".format(binanceprice, binancevolume)
# Bitfinex # Bitfinex
@ -560,7 +559,7 @@ def tall(bot, trigger):
finexresult = requests.get(finexurl) finexresult = requests.get(finexurl)
finexjson = finexresult.json() finexjson = finexresult.json()
except: except:
finexjson = False finexjson = False
try: try:
if finexjson: if finexjson:
stringtosend += "Bitfinex last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(finexjson['last_price']), float(finexjson['volume'])) stringtosend += "Bitfinex last: ${0:,.2f}, vol: {1:,.1f} | ".format(float(finexjson['last_price']), float(finexjson['volume']))
@ -659,13 +658,13 @@ def xmrtall(bot, trigger):
# Polo # Polo
try: try:
r=requests.get(polourl) r=requests.get(polourl)
j=r.json() j=r.json()
xmr=j["BTC_XMR"] xmr=j["BTC_XMR"]
last=float(xmr['last']) last=float(xmr['last'])
# change=float(xmr['percentChange']) # change=float(xmr['percentChange'])
vol=float(xmr['baseVolume']) vol=float(xmr['baseVolume'])
stringtosend += "Poloniex last: {0:.6f} BTC on {1:.2f} BTC volume | ".format(last, vol) stringtosend += "Poloniex last: {0:.6f} BTC on {1:.2f} BTC volume | ".format(last, vol)
except: except:
bot.say("Something borked ¯\(º_o)/¯") bot.say("Something borked ¯\(º_o)/¯")