Merge pull request #148 from thenoodle68/develop
Better help, fixed bitcoin, bones of better steam.
This commit is contained in:
commit
382b76ca26
|
@ -32,7 +32,8 @@
|
|||
"wunderground": "",
|
||||
"googletranslate": "",
|
||||
"rdio_key": "",
|
||||
"rdio_secret": ""
|
||||
"rdio_secret": "",
|
||||
"steam_key": ""
|
||||
},
|
||||
"permissions": {
|
||||
"admins": {
|
||||
|
|
|
@ -7,10 +7,10 @@ def bitcoin(inp, say=None):
|
|||
data = http.get_json("https://data.mtgox.com/api/2/BTCUSD/money/ticker")
|
||||
data = data['data']
|
||||
ticker = {
|
||||
'buy': data['buy']['display_short'],
|
||||
'high': data['high']['display_short'],
|
||||
'low': data['low']['display_short'],
|
||||
'vol': data['vol']['display_short'],
|
||||
'buy': data['buy']['display_short'].encode('ascii','ignore'),
|
||||
'high': data['high']['display_short'].encode('ascii','ignore'),
|
||||
'low': data['low']['display_short'].encode('ascii','ignore'),
|
||||
'vol': data['vol']['display_short'].encode('ascii','ignore'),
|
||||
}
|
||||
say("Current: \x0307{}\x0f - High: \x0307{}\x0f"
|
||||
" - Low: \x0307{}\x0f - Volume: {}".format(data['buy'],data['high'],data['low'],data['vol']))
|
||||
say("Current: \x0307{!s}\x0f - High: \x0307{!s}\x0f"
|
||||
" - 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())
|
||||
|
||||
if not inp:
|
||||
out = ["", ""]
|
||||
out = [""]
|
||||
well = []
|
||||
for x in commands:
|
||||
well.append(x)
|
||||
well.sort()
|
||||
count = 0
|
||||
for x in well:
|
||||
if len(out[0]) + len(str(x)) > 405:
|
||||
out[1] += " " + str(x)
|
||||
if len(out[count]) + len(str(x)) > 405:
|
||||
count += 1
|
||||
out.append(str(x))
|
||||
else:
|
||||
out[0] += " " + str(x)
|
||||
out[count] += " " + str(x)
|
||||
|
||||
notice("Commands I recognise: " + out[0][1:])
|
||||
if out[1]:
|
||||
notice(out[1][1:])
|
||||
if len(out) > 1:
|
||||
for x in out[1:]:
|
||||
notice(x)
|
||||
notice("For detailed help, do '%shelp <example>' where <example> "
|
||||
"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 bs4 import BeautifulSoup
|
||||
import re
|
||||
|
||||
|
||||
db_ready = False
|
||||
|
||||
|
@ -20,6 +24,32 @@ def db_init(db):
|
|||
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(autohelp=False)
|
||||
def steamcalc(inp, nick='', db=None):
|
||||
|
@ -65,7 +95,7 @@ def steamcalc(inp, nick='', db=None):
|
|||
print e
|
||||
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(
|
||||
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
|
||||
status = "Unknown"
|
||||
|
|
Reference in a new issue