Skip to content

Commit

Permalink
Handled errors that made the bot crash.
Browse files Browse the repository at this point in the history
When the explorer went down due to the lastest wallet crashes the bot crashed as well.
  • Loading branch information
andrewtookay authored Dec 21, 2017
1 parent 101c11a commit e79c7ae
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Creedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,23 @@ async def on_message(message):
def getMnRoi(no_mn):
final_message = ''

json_cmc = requests.get('https://api.coinmarketcap.com/v1/ticker/').json()
btc_usd = float(json_cmc[0]['price_usd'])
try:
json_cmc = requests.get('https://api.coinmarketcap.com/v1/ticker/').json()
btc_usd = float(json_cmc[0]['price_usd'])

json_coinsm = requests.get('https://coinsmarkets.com/apicoin.php').json()
crds_btc = float(json_coinsm['BTC_CRDS']['last'])
json_coinsm = requests.get('https://coinsmarkets.com/apicoin.php').json()
crds_btc = float(json_coinsm['BTC_CRDS']['last'])

crds_usd = crds_btc * btc_usd
mncount = requests.get('http://explorer.crds.co/mncount.txt')
mncount = float(mncount.text)

mncount = requests.get('http://explorer.crds.co/mncount.txt')
mncount = float(mncount.text)
blockcount = requests.get('http://explorer.crds.co/blockcount.txt')
blockcount = int(blockcount.text)
except:
final_message = 'Command unavailable due to downtime of explorer or APIs.'
return final_message

blockcount = requests.get('http://explorer.crds.co/blockcount.txt')
blockcount = int(blockcount.text)
crds_usd = crds_btc * btc_usd

if blockcount <= 493088:
reward = 1
Expand Down

0 comments on commit e79c7ae

Please # to comment.