Fix __currency
This commit is contained in:
parent
f1452c7e2a
commit
180825dfe1
18
bot/coins.py
18
bot/coins.py
|
@ -6,21 +6,23 @@ from irc3.utils import IrcString
|
||||||
|
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
def __currency(name=None, prefix=None, suffix=None):
|
|
||||||
return lambda value:
|
def __currency(name, prefix=None, suffix=None):
|
||||||
|
def str(value):
|
||||||
return '{prefix}{value:,.2f}{suffix}'.format(
|
return '{prefix}{value:,.2f}{suffix}'.format(
|
||||||
prefix=prefix or '',
|
prefix=prefix or '',
|
||||||
suffix=suffix or (' ' + name if name else ''),
|
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
|
||||||
value=value)
|
value=value)
|
||||||
|
return str
|
||||||
|
|
||||||
class Coins(Plugin):
|
class Coins(Plugin):
|
||||||
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||||
CURRENCIES = {
|
CURRENCIES = {
|
||||||
'usd': __currency(prefix='$'),
|
'usd': __currency('usd', prefix='$'),
|
||||||
'eur': __currency(suffix='€'),
|
'eur': __currency('eur', suffix='€'),
|
||||||
'eth': __currency(suffix='Ξ'),
|
'eth': __currency('eth', suffix='Ξ'),
|
||||||
'btc': __currency(suffix='฿'),
|
'btc': __currency('btc', suffix='฿'),
|
||||||
'xmr': __currency(name='xmr'),
|
'xmr': __currency('xmr'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@command
|
@command
|
||||||
|
|
Loading…
Reference in New Issue
Block a user