added Monreo
This commit is contained in:
parent
d792452d22
commit
d3b01bcf97
21
bot/coins.py
21
bot/coins.py
|
@ -8,12 +8,13 @@ from . import Plugin
|
|||
|
||||
|
||||
class Coins(Plugin):
|
||||
API_URL = 'https://api.cryptowat.ch/markets/coinbase/{crypto}{currency}/summary'
|
||||
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
|
||||
CURRENCIES = {
|
||||
'usd': '$',
|
||||
'eur': '€',
|
||||
'eth': 'Ξ',
|
||||
'btc': '฿',
|
||||
'xmr': 'xmr',
|
||||
}
|
||||
|
||||
@command
|
||||
|
@ -22,23 +23,31 @@ class Coins(Plugin):
|
|||
|
||||
%%btc [<currency>]
|
||||
"""
|
||||
return self.cryptowat_summary('btc', args)
|
||||
|
||||
return self.cryptowat_summary('btc', 'coinbase', args)
|
||||
|
||||
@command
|
||||
def eth(self, mask: IrcString, target: IrcString, args: Dict):
|
||||
"""Gets the Ethereum values from cryptowatch.
|
||||
|
||||
%%eth [<currency>]
|
||||
"""
|
||||
return self.cryptowat_summary('eth', args)
|
||||
return self.cryptowat_summary('eth', 'coinbase', args)
|
||||
|
||||
@command
|
||||
def xmr(self, mask: IrcString, target: IrcString, args: Dict):
|
||||
"""Gets the Monreo values from cryptowatch.
|
||||
|
||||
def cryptowat_summary(self, crypto: str, args: Dict):
|
||||
%%xmr [<currency>]
|
||||
"""
|
||||
return self.cryptowat_summary('xmr', 'bitfinex', args)
|
||||
|
||||
def cryptowat_summary(self, crypto: str, market: market, args: Dict):
|
||||
currency = args.get('<currency>', 'usd')
|
||||
|
||||
if currency not in self.CURRENCIES or crypto == currency:
|
||||
return '\x02[{}]\x02 Can\'t convert or invalid currency: {}'.format(crypto.upper(), currency)
|
||||
|
||||
data = requests.get(self.API_URL.format(crypto=crypto, currency=currency))
|
||||
data = requests.get(self.API_URL.format(crypto=crypto, market=market, currency=currency))
|
||||
if not data:
|
||||
return '\x02[{}]\x02 No data received'.format(crypto)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user