Add 'usd' fallback to coin data request
This commit is contained in:
parent
a08d5f07dc
commit
4da84cb452
|
@ -55,7 +55,12 @@ class Coins(Plugin):
|
||||||
if currency not in self.CURRENCIES or crypto == currency:
|
if currency not in self.CURRENCIES or crypto == currency:
|
||||||
return '\x02[{}]\x02 Can\'t convert or invalid currency: {}'.format(crypto.upper(), currency)
|
return '\x02[{}]\x02 Can\'t convert or invalid currency: {}'.format(crypto.upper(), currency)
|
||||||
|
|
||||||
data = requests.get(self.API_URL.format(crypto=crypto, market=market, currency=currency))
|
def get_data(cur):
|
||||||
|
return requests.get(self.API_URL.format(crypto=crypto, market=market, currency=cur))
|
||||||
|
|
||||||
|
data = get_data(currency)
|
||||||
|
if not data and currency != 'usd':
|
||||||
|
data = get_data('usd')
|
||||||
if not data:
|
if not data:
|
||||||
return '\x02[{}]\x02 No data received for currency {}'.format(crypto, currency)
|
return '\x02[{}]\x02 No data received for currency {}'.format(crypto, currency)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user