Add LocalMonero Average USD Price Ticker command

This commit is contained in:
LocalMonero 2018-07-18 17:35:39 +08:00 committed by GitHub
parent e2721b3dad
commit cf837847e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,7 @@ bitflyerurl = 'https://api.bitflyer.jp/v1/ticker'
thumbxmrurl = 'https://api.bithumb.com/public/ticker/xmr' # measured natively in KRW thumbxmrurl = 'https://api.bithumb.com/public/ticker/xmr' # measured natively in KRW
thumbbtcurl = 'https://api.bithumb.com/public/ticker/btc' # measured natively in KRW thumbbtcurl = 'https://api.bithumb.com/public/ticker/btc' # measured natively in KRW
binanceurl = 'https://api.binance.com/api/v1/ticker/24hr' binanceurl = 'https://api.binance.com/api/v1/ticker/24hr'
localmonerousd = 'https://localmonero.co/api/ticker?currencyCode=USD'
@sopel.module.commands('forksum') @sopel.module.commands('forksum')
def forksum(bot, trigger): def forksum(bot, trigger):
@ -1066,3 +1067,16 @@ def xmy(bot, trigger):
except: except:
bot.say("Error parsing ticker") bot.say("Error parsing ticker")
@sopel.module.commands('localmonero', 'localxmr', 'lxmr', 'lm', 'street')
def localmonero(bot, trigger):
stringtosay = ''
try:
r = requests.get(localmonerousd)
j = r.json()
stringtosay += "LocalMonero XMR/USD 1h-avg: ${0:.2f}, 6h-avg: ${0:.2f}, 12h-avg: ${0:.2f}, 24h-avg: ${0:.2f}.".format(float(j['USD']['avg_1h']), float(j['USD']['avg_6h']), float(j['USD']['avg_12h']), float(j['USD']['avg_24h']))
except:
bot.say("Error getting XMR/USD data")
try:
bot.say(stringtosay)
except:
bot.say("Error getting data")