Last active
January 1, 2016 21:24
-
-
Save Aareon/08d1403b53b9348bcba1 to your computer and use it in GitHub Desktop.
u
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
import urllib | |
import logging | |
import json | |
def u_run_cmd(line, config): | |
logger = logging.getLogger('bot.cmd.u') | |
userNick = line.split(':')[2].split(' ') | |
get_coin = line.split(' ')[0] | |
logger.debug(userNick) | |
if len(userNick) == 2: | |
userNick = userNick[1] | |
url = urllib.urlopen('http://'+get_coin+'.'+config['api_url'] + '&action=getuserstatus&api_key=' + config['api_key'] + '&id=' + userNick) | |
if url.getcode() != 200: | |
logger.error('Request failed with http error: ' + str(url.getcode())) | |
return False | |
jsonData = json.loads(url.read()) | |
logger.info('Completed command') | |
return 'PRIVMSG ' + config['channel'] + ' :' + 'Username: ' + str(jsonData['getuserstatus']['data']['username']) + ' | Hashrate: ' + str(jsonData['getuserstatus']['data']['hashrate']) + ' kh/s' + ' | Shares Valid: ' + str(jsonData['getuserstatus']['data']['shares']['valid']) + ' | Shares Invalid: ' + str(jsonData['getuserstatus']['data']['shares']['invalid']) | |
logger.info('Completed command') | |
return 'PRIVMSG ' + config['channel'] + ' : Unable to coin info in: '+get_coin+' for '+userNick | |
#http://bolivar.mineforthewin.com/index.php?page=api&action=getuserstatus&api_key=(API_KEY)&id=(id(4)(username)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment