added Monreo

This commit is contained in:
Flummi 2017-09-21 04:08:50 +00:00
parent d792452d22
commit d3b01bcf97

View File

@ -8,12 +8,13 @@ from . import Plugin
class Coins(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 = { CURRENCIES = {
'usd': '$', 'usd': '$',
'eur': '', 'eur': '',
'eth': 'Ξ', 'eth': 'Ξ',
'btc': '฿', 'btc': '฿',
'xmr': 'xmr',
} }
@command @command
@ -22,23 +23,31 @@ class Coins(Plugin):
%%btc [<currency>] %%btc [<currency>]
""" """
return self.cryptowat_summary('btc', args) return self.cryptowat_summary('btc', 'coinbase', args)
@command @command
def eth(self, mask: IrcString, target: IrcString, args: Dict): def eth(self, mask: IrcString, target: IrcString, args: Dict):
"""Gets the Ethereum values from cryptowatch. """Gets the Ethereum values from cryptowatch.
%%eth [<currency>] %%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') currency = args.get('<currency>', 'usd')
if currency not in self.CURRENCIES or crypto == currency: if currency not in self.CURRENCIES or crypto == currency:
return '\x02[{}]\x02 Can\'t convert or invalid currency: {}'.format(crypto.upper(), 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: if not data:
return '\x02[{}]\x02 No data received'.format(crypto) return '\x02[{}]\x02 No data received'.format(crypto)