Move __currency out of Coins class
This commit is contained in:
parent
3f6c840d86
commit
0c7697e33b
27
bot/coins.py
27
bot/coins.py
|
@ -6,26 +6,23 @@ from irc3.utils import IrcString
|
|||
|
||||
from . import Plugin
|
||||
|
||||
|
||||
def _currency(name, prefix=None, suffix=None):
|
||||
def tostr(value):
|
||||
return '{prefix}{value:,.2f}{suffix}'.format(
|
||||
prefix=prefix or '',
|
||||
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
|
||||
value=value)
|
||||
return tostr
|
||||
|
||||
class Coins(Plugin):
|
||||
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||
|
||||
@staticmethod
|
||||
def __currency(name, prefix=None, suffix=None):
|
||||
def tostr(value):
|
||||
return '{prefix}{value:,.2f}{suffix}'.format(
|
||||
prefix=prefix or '',
|
||||
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
|
||||
value=value)
|
||||
return tostr
|
||||
|
||||
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