Merge pull request #148 from thenoodle68/develop
Better help, fixed bitcoin, bones of better steam.
This commit is contained in:
commit
382b76ca26
4 changed files with 49 additions and 15 deletions
|
@ -32,7 +32,8 @@
|
||||||
"wunderground": "",
|
"wunderground": "",
|
||||||
"googletranslate": "",
|
"googletranslate": "",
|
||||||
"rdio_key": "",
|
"rdio_key": "",
|
||||||
"rdio_secret": ""
|
"rdio_secret": "",
|
||||||
|
"steam_key": ""
|
||||||
},
|
},
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"admins": {
|
"admins": {
|
||||||
|
|
|
@ -7,10 +7,10 @@ def bitcoin(inp, say=None):
|
||||||
data = http.get_json("https://data.mtgox.com/api/2/BTCUSD/money/ticker")
|
data = http.get_json("https://data.mtgox.com/api/2/BTCUSD/money/ticker")
|
||||||
data = data['data']
|
data = data['data']
|
||||||
ticker = {
|
ticker = {
|
||||||
'buy': data['buy']['display_short'],
|
'buy': data['buy']['display_short'].encode('ascii','ignore'),
|
||||||
'high': data['high']['display_short'],
|
'high': data['high']['display_short'].encode('ascii','ignore'),
|
||||||
'low': data['low']['display_short'],
|
'low': data['low']['display_short'].encode('ascii','ignore'),
|
||||||
'vol': data['vol']['display_short'],
|
'vol': data['vol']['display_short'].encode('ascii','ignore'),
|
||||||
}
|
}
|
||||||
say("Current: \x0307{}\x0f - High: \x0307{}\x0f"
|
say("Current: \x0307{!s}\x0f - High: \x0307{!s}\x0f"
|
||||||
" - Low: \x0307{}\x0f - Volume: {}".format(data['buy'],data['high'],data['low'],data['vol']))
|
" - Low: \x0307{!s}\x0f - Volume: {!s}".format(ticker['buy'],ticker['high'],ticker['low'],ticker['vol']))
|
||||||
|
|
|
@ -23,20 +23,23 @@ def help(inp, notice=None, input=None, conn=None, bot=None):
|
||||||
commands = dict((value, key) for key, value in funcs.iteritems())
|
commands = dict((value, key) for key, value in funcs.iteritems())
|
||||||
|
|
||||||
if not inp:
|
if not inp:
|
||||||
out = ["", ""]
|
out = [""]
|
||||||
well = []
|
well = []
|
||||||
for x in commands:
|
for x in commands:
|
||||||
well.append(x)
|
well.append(x)
|
||||||
well.sort()
|
well.sort()
|
||||||
|
count = 0
|
||||||
for x in well:
|
for x in well:
|
||||||
if len(out[0]) + len(str(x)) > 405:
|
if len(out[count]) + len(str(x)) > 405:
|
||||||
out[1] += " " + str(x)
|
count += 1
|
||||||
|
out.append(str(x))
|
||||||
else:
|
else:
|
||||||
out[0] += " " + str(x)
|
out[count] += " " + str(x)
|
||||||
|
|
||||||
notice("Commands I recognise: " + out[0][1:])
|
notice("Commands I recognise: " + out[0][1:])
|
||||||
if out[1]:
|
if len(out) > 1:
|
||||||
notice(out[1][1:])
|
for x in out[1:]:
|
||||||
|
notice(x)
|
||||||
notice("For detailed help, do '%shelp <example>' where <example> "
|
notice("For detailed help, do '%shelp <example>' where <example> "
|
||||||
"is the name of the command you want help for." % conn.conf["command_prefix"])
|
"is the name of the command you want help for." % conn.conf["command_prefix"])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
import urllib2
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
from xml.dom import minidom
|
||||||
from util import hook, http, web, text
|
from util import hook, http, web, text
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import re
|
|
||||||
|
|
||||||
db_ready = False
|
db_ready = False
|
||||||
|
|
||||||
|
@ -20,6 +24,32 @@ def db_init(db):
|
||||||
db_ready = True
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
|
def get_steam_info(name):
|
||||||
|
dom = minidom.parse(urllib2.urlopen(re.sub("{USER}", name, "http://steamcommunity.com/id/{USER}/?xml=1")))
|
||||||
|
ID = int(dom.getElementsByTagName("steamID64")[0].firstChild.data)
|
||||||
|
key = bot.config.get("api_keys", {}).get("steam_key")
|
||||||
|
url = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={}&steamid={}&format=json".format(key,
|
||||||
|
ID)
|
||||||
|
data = json.load(urllib2.urlopen(url))
|
||||||
|
useable = data['response']['games']
|
||||||
|
games = []
|
||||||
|
played = []
|
||||||
|
data = {}
|
||||||
|
playtime = 0
|
||||||
|
for x in useable:
|
||||||
|
games.append(x)
|
||||||
|
if x['playtime_forever'] > 0:
|
||||||
|
played.append(x)
|
||||||
|
playtime += x['playtime_forever']
|
||||||
|
played.sort(key=lambda x: x['playtime_forever'])
|
||||||
|
played.reverse()
|
||||||
|
data['playtime'] = int(playtime / 60.0)
|
||||||
|
data['played'] = played
|
||||||
|
data['games'] = games
|
||||||
|
data['%played'] = round(float(len(played)) / len(games) * 100, 2)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
@hook.command('sc', autohelp=False)
|
@hook.command('sc', autohelp=False)
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def steamcalc(inp, nick='', db=None):
|
def steamcalc(inp, nick='', db=None):
|
||||||
|
@ -65,7 +95,7 @@ def steamcalc(inp, nick='', db=None):
|
||||||
print e
|
print e
|
||||||
return u"\x02Unable to retrieve info for {}!\x02 Is it a valid SteamCommunity profile username ({})? " \
|
return u"\x02Unable to retrieve info for {}!\x02 Is it a valid SteamCommunity profile username ({})? " \
|
||||||
"Check if your profile is private, or go here to search: {}".format(
|
"Check if your profile is private, or go here to search: {}".format(
|
||||||
inp, web.try_isgd("http://steamcommunity.com/id/%s" % inp), web.try_isgd(url))
|
inp, web.try_isgd("http://steamcommunity.com/id/%s" % inp), web.try_isgd(url))
|
||||||
|
|
||||||
nextone = False
|
nextone = False
|
||||||
status = "Unknown"
|
status = "Unknown"
|
||||||
|
|
Reference in a new issue