Merge branch 'patch-1' into 'master'
added Monreo See merge request !10
This commit is contained in:
commit
07f7ab4f17
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': '฿',
|
||||
'monreo': '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('monreo', 'bitfinex', args)
|
||||
|
||||
def cryptowat_summary(self, crypto: str, market: str, 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