From 42e7fffc49dc90093b71514359e730a9d866a83c Mon Sep 17 00:00:00 2001 From: scoobybejesus <21372487+scoobybejesus@users.noreply.github.com> Date: Tue, 24 Aug 2021 17:27:13 -0400 Subject: [PATCH] Fix Ogre parsing --- price.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/price.py b/price.py index 8c6708e..a02e549 100644 --- a/price.py +++ b/price.py @@ -404,13 +404,19 @@ def ogre(bot, trigger): try: r = requests.get(ogreurl) j = r.json() - for i in j: - if pair == i.keys()[0]: - last=float(i[pair]['price']) - vol=float(i[pair]['volume']) - bot.say("{0} on Tradeogre at {1:.8f} BTC on {2:.3f} BTC volume".format(pair, last, vol)) except: bot.say("Error retrieving data from Ogre") + last = 0.0 + vol = 0.0 + try: + for i in j: + for key in i: + if pair == key: + last=float(i[pair]['price']) + vol=float(i[pair]['volume']) + bot.say("{0} on Tradeogre at {1:.8f} BTC on {2:.3f} BTC volume".format(pair, last, vol)) + except: + bot.say("Error parsing data from Ogre") @sopel.module.commands('trex', 'bittrex')