From d15a3d5a8ac4f62a8878234c00e96dc601570ef9 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 2 Jan 2018 05:18:11 +0000 Subject: [PATCH] update before pull --- network.py | 12 +++++++++++ price.py | 60 +++++++++++++++++++++++++++++++++++++++-------------- trifling.py | 6 ++++++ 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/network.py b/network.py index efd0e08..b0c5854 100644 --- a/network.py +++ b/network.py @@ -76,6 +76,18 @@ def mine(bot, trigger): except: bot.say("Mining is for suckers.") +@sopel.module.commands('solo') +def solo(bot, trigger): + try: + r=requests.get('https://supportxmr.com/api/network/stats') + j=r.json() + diff=float(j['difficulty']) + hashrate=float(trigger.group(2)) + timetoblock=(diff/hashrate) + bot.say("At {:.0f} h/s with network diff of {:.2e} your expected time for find a block is {:.2e} s or {:.2f} days.".format(hashrate, diff, timetoblock, timetoblock/(60*60*24))) + except: + bot.say("Mining is for suckers.") + @sopel.module.commands('b2x') def b2x(bot, trigger): bot.say("Fuck off \\x") diff --git a/price.py b/price.py index 7ddfe14..6068b8c 100644 --- a/price.py +++ b/price.py @@ -26,26 +26,22 @@ bitflyerurl = 'https://api.bitflyer.jp/v1/ticker' thumbxmrurl = 'https://api.bithumb.com/public/ticker/xmr' # measured natively in KRW thumbbtcurl = 'https://api.bithumb.com/public/ticker/btc' # measured natively in KRW - -@sopel.module.commands('bch', 'bitcointrash') -def bch(bot, trigger): +@sopel.module.commands('forksum') +def forksum(bot, trigger): url = 'https://api.coinmarketcap.com/v1/ticker/?bch' try: r = requests.get(url) j = r.json() for i in j: try: + if i['id'] == 'bitcoin': + btcprice = float(i['price_usd']) if i['id'] == 'bitcoin-cash': - coin = i + bcashprice = float(i['price_usd']) + if i['id'] == 'bitcoin-gold': + bgoldprice = float(i['price_usd']) except: pass - symbol = coin['symbol'] - name = coin['name'] - rank = coin['rank'] - price_usd = float(coin['price_usd']) - price_btc = float(coin['price_btc']) - volume_usd = float(coin['24h_volume_usd']) - percent_change_24h = float(coin['percent_change_24h']) - bot.say("{0} ({1}) is #{2}. Last price ${3:.2f} / ฿{4:.8f}. 24h volume ${5:,.0f} changed {6}%.".format(name, symbol, rank, price_usd, price_btc, volume_usd, percent_change_24h)) + bot.say("The sum of USD price of BTC, BCH, and BTG is ${:.2f}".format(btcprice+bcashprice+bgoldprice)) except: bot.say("Error parsing ticker") @@ -475,10 +471,12 @@ def tall(bot, trigger): try: gdaxresult = requests.get(gdaxurl) gdaxjson = gdaxresult.json() + gdaxprice = float(gdaxjson['price']) + gdaxvolume = float(gdaxjson['volume']) except: gdaxjson = False if gdaxjson: - stringtosend += "GDAX price: {0:,.2f}, vol: {1:,.1f} | ".format(float(gdaxjson['price']), float(gdaxjson['volume'])) + stringtosend += "GDAX price: {0:,.2f}, vol: {1:,.1f} | ".format(gdaxprice, gdaxvolume) # Bitfinex try: finexresult = requests.get(finexurl) @@ -525,7 +523,7 @@ def tall(bot, trigger): bot.say(stringtosend) -@sopel.module.commands('xmrtall') +@sopel.module.commands('xmrtall', 'xmr') def xmrtall(bot, trigger): stringtosend = '' @@ -882,7 +880,7 @@ def log(bot, trigger): @sopel.module.commands('price') def price(bot, trigger): try: - bot.say("1 XMR = $1,000 USD (Offer valid in participating locations)") + bot.say("1 XMR = $12,345 USD (Offer valid in participating locations)") except: bot.say("C-cex sucks") @@ -910,3 +908,35 @@ def commodity(bot, trigger): except: bot.say("Monerobux fails again...") +@sopel.module.commands('xmy') +def xmy(bot, trigger): + try: + r = requests.get('https://api.coinmarketcap.com/v1/ticker?limit=500') + j = r.json() + except: + bot.say("Can't connect to API") + symbol = 'XMY' + try: + for i in j: + try: + if i['symbol'] == symbol: + coin = i + except: pass + try: + if i['rank'] == str(rank): + coin = i + except: pass + symbol = coin['symbol'] + name = coin['name'] + rank = coin['rank'] + price_usd = float(coin['price_usd']) + price_btc = float(coin['price_btc']) + volume_usd = float(coin['24h_volume_usd']) + market_cap_usd = float(coin['market_cap_usd']) + available_supply = float(coin['available_supply']) + total_supply = float(coin['total_supply']) + percent_change_24h = float(coin['percent_change_24h']) + bot.say("{0} ({1}) is #{2}. Last price ${3:.2f} / ฿{4:.8f}. 24h volume ${5:,.0f} changed {6}%. Market cap ${7:,.0f}. Available / total coin supply {8:,.0f} / {9:,.0f}.".format(name, symbol, rank, price_usd, price_btc, volume_usd, percent_change_24h, market_cap_usd, available_supply, total_supply)) + except: + bot.say("Error parsing ticker") + diff --git a/trifling.py b/trifling.py index f53ead1..a553e28 100644 --- a/trifling.py +++ b/trifling.py @@ -11,6 +11,12 @@ from threading import Timer def fourmatter(bot, trigger): bot.say('Irish I be fookin <3 Milo') +@sopel.module.commands('allah') +def allah(bot, trigger): + bot.say('allah is doing') + bot.say('sun is not doing allah is doing') + bot.say('to accept Islam say that i bear witness that there is no deity worthy of worship except Allah and Muhammad peace be upon him is his slave and messenger') + @sopel.module.commands('aminorex') def aminorex(bot, trigger): bot.say('if i could replace my wife with a robot... i might seriously think about it')