Skip to content

Instantly share code, notes, and snippets.

@Aareon
Last active January 1, 2016 21:24
Show Gist options
  • Save Aareon/08d1403b53b9348bcba1 to your computer and use it in GitHub Desktop.
Save Aareon/08d1403b53b9348bcba1 to your computer and use it in GitHub Desktop.
u
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