Skip to content

Commit 53dc414

Browse files
committed
Switch currency symbol handling to a dict
1 parent 58dc519 commit 53dc414

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

plugins/cryptocurrency.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
API_URL = "https://api.coinmarketcap.com/v1/ticker/{}"
2020

21+
CURRENCY_SYMBOLS = {
22+
'USD': '$',
23+
'GBP': '£',
24+
'EUR': '€',
25+
}
26+
2127

2228
def get_request(ticker, currency):
2329
return requests.get(API_URL.format(quote_plus(ticker)), params={'convert': currency})
@@ -84,14 +90,7 @@ def crypto_command(text):
8490
else:
8591
change_str = "{}%".format(change)
8692

87-
if currency == 'GBP':
88-
currency_sign = '£'
89-
elif currency == 'EUR':
90-
currency_sign = '€'
91-
elif currency == 'USD':
92-
currency_sign = '$'
93-
else:
94-
currency_sign = ''
93+
currency_sign = CURRENCY_SYMBOLS.get(currency, '')
9594

9695
try:
9796
converted_value = data['price_' + currency.lower()]

0 commit comments

Comments
 (0)