Move __currency out of Coins class
This commit is contained in:
parent
3f6c840d86
commit
0c7697e33b
21
bot/coins.py
21
bot/coins.py
|
@ -6,13 +6,7 @@ from irc3.utils import IrcString
|
|||
|
||||
from . import Plugin
|
||||
|
||||
|
||||
|
||||
class Coins(Plugin):
|
||||
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||
|
||||
@staticmethod
|
||||
def __currency(name, prefix=None, suffix=None):
|
||||
def _currency(name, prefix=None, suffix=None):
|
||||
def tostr(value):
|
||||
return '{prefix}{value:,.2f}{suffix}'.format(
|
||||
prefix=prefix or '',
|
||||
|
@ -20,12 +14,15 @@ class Coins(Plugin):
|
|||
value=value)
|
||||
return tostr
|
||||
|
||||
class Coins(Plugin):
|
||||
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||
|
||||
CURRENCIES = {
|
||||
'usd': Coins.__currency('usd', prefix='$'),
|
||||
'eur': Coins.__currency('eur', suffix='€'),
|
||||
'eth': Coins.__currency('eth', suffix='Ξ'),
|
||||
'btc': Coins.__currency('btc', suffix='฿'),
|
||||
'xmr': Coins.__currency('xmr'),
|
||||
'usd': _currency('usd', prefix='$'),
|
||||
'eur': _currency('eur', suffix='€'),
|
||||
'eth': _currency('eth', suffix='Ξ'),
|
||||
'btc': _currency('btc', suffix='฿'),
|
||||
'xmr': _currency('xmr'),
|
||||
}
|
||||
|
||||
@command
|
||||
|
|
Loading…
Reference in New Issue
Block a user