Merge branch 'patch-1' into 'master'

added Monreo

See merge request !10
This commit is contained in:
Flummi 2017-09-21 10:56:48 +00:00
commit 07f7ab4f17

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': '฿',
'monreo': 'xmr',
} }
@command @command
@ -22,7 +23,7 @@ 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):
@ -30,15 +31,23 @@ class Coins(Plugin):
%%eth [<currency>] %%eth [<currency>]
""" """
return self.cryptowat_summary('eth', args) return self.cryptowat_summary('eth', 'coinbase', args)
def cryptowat_summary(self, crypto: str, args: Dict): @command
def xmr(self, mask: IrcString, target: IrcString, args: Dict):
"""Gets the Monreo values from cryptowatch.
%%xmr [<currency>]
"""
return self.cryptowat_summary('monreo', 'bitfinex', args)
def cryptowat_summary(self, crypto: str, market: str, 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)