Last active
January 4, 2016 18:29
-
-
Save Aareon/409bd74c2f41352db5e5 to your computer and use it in GitHub Desktop.
Shitcoin: MPOS API IRC Bot - Aareon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
#Requires /util/parse.py & /util/__init__.py | |
""" | |
"pool <coin>"; | |
Ex: ".pool doge" | |
Sends pool information from API for coin to channel | |
""" | |
import urllib2, json | |
from parse import parse_json | |
from util.hook import * | |
from decimal import * | |
parse_json('data.json') | |
data = parse_json.data | |
a_key = "&api_key=" | |
@hook(cmds=['pool']) | |
def getpoolstatus(code,trigger): | |
command = trigger.split(' ')[0] | |
user_coin = trigger.split(' ')[1] | |
try: | |
coin_lower = user_coin.lower() | |
if coin_lower in ["boli","bolivarcoin","bolivar"]: | |
user_coin = "BOLIVAR" | |
elif coin_lower in ["infx","influx","influxcoin"]: | |
user_coin = "INFLUX" | |
elif coin_lower in ["soon","sooncoin"]: | |
user_coin = "SOON" | |
elif coin_lower in ["sprouts","sproutscoin","sprts"]: | |
user_coin = "SPROUTS" | |
elif coin_lower in ["sandg","saveandgain","saveandgaincoin"]: | |
user_coin = "SANDG" | |
elif coin_lower in ["ham","hamradio","hamradiocoin"]: | |
user_coin = "HAMRADIO" | |
elif coin_lower in ["btcs","btcscrypt"]: | |
user_coin = "BTCSCRYPT" | |
elif coin_lower in ["btcf","btcfast"]: | |
user_coin = "BTCFAST" | |
elif coin_lower in ["petro","xpd","petrodollar"]: | |
user_coin = "XPD" | |
action = "getpoolstatus" | |
route = "http://"+user_coin+'.'+data["URL"]+action+a_key+data["KEY"] | |
response = urllib2.urlopen(route) | |
page = response.read() | |
page_contents = json.loads(page) | |
page_data = page_contents["getpoolstatus"]["data"] | |
page_hash = page_data["hashrate"] | |
hashrate = int(page_hash) / 1000. | |
block = page_data["currentnetworkblock"] | |
pool_diff = page_data["networkdiff"] | |
workers = page_data["workers"] | |
code.say("Pool: {blue}"+user_coin+"{black} | Block: #"+str(block)+" | Hashrate: {blue}"+str(hashrate)+"{black}MH/s | Pool Diff: "+str(pool_diff)+" | Workers: "+str(workers)) | |
except urllib2.HTTPError: | |
code.reply("The page was either unreachable or you do not have access to that information") |
Split modules up to make writing new ones easier.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires /util/parse.py