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
|
from . import Plugin
|
||||||
|
|
||||||
|
def _currency(name, prefix=None, suffix=None):
|
||||||
|
|
||||||
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):
|
def tostr(value):
|
||||||
return '{prefix}{value:,.2f}{suffix}'.format(
|
return '{prefix}{value:,.2f}{suffix}'.format(
|
||||||
prefix=prefix or '',
|
prefix=prefix or '',
|
||||||
|
@ -20,12 +14,15 @@ class Coins(Plugin):
|
||||||
value=value)
|
value=value)
|
||||||
return tostr
|
return tostr
|
||||||
|
|
||||||
|
class Coins(Plugin):
|
||||||
|
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||||
|
|
||||||
CURRENCIES = {
|
CURRENCIES = {
|
||||||
'usd': Coins.__currency('usd', prefix='$'),
|
'usd': _currency('usd', prefix='$'),
|
||||||
'eur': Coins.__currency('eur', suffix='€'),
|
'eur': _currency('eur', suffix='€'),
|
||||||
'eth': Coins.__currency('eth', suffix='Ξ'),
|
'eth': _currency('eth', suffix='Ξ'),
|
||||||
'btc': Coins.__currency('btc', suffix='฿'),
|
'btc': _currency('btc', suffix='฿'),
|
||||||
'xmr': Coins.__currency('xmr'),
|
'xmr': _currency('xmr'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@command
|
@command
|
||||||
|
|
Loading…
Reference in New Issue
Block a user