pep8
This commit is contained in:
parent
3a2bd24352
commit
148733567e
|
@ -1,30 +1,26 @@
|
||||||
'''
|
# tf.py: written by ipsum
|
||||||
tf.py
|
#
|
||||||
|
# This skybot plugin retreives the number of items
|
||||||
A skybot plugin for Team Fortress 2
|
# a given user has waiting from idling in Team Fortress 2.
|
||||||
By Ipsum
|
|
||||||
'''
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from util import hook
|
from util import hook
|
||||||
|
|
||||||
|
|
||||||
@hook.command('hats')
|
@hook.command('hats')
|
||||||
@hook.command
|
@hook.command
|
||||||
def tf(inp):
|
def tf(inp):
|
||||||
'''.tf/.hats <SteamID> -- Displays the number of hats
|
""".tf/.hats <SteamID> -- Shows items waiting to be received in TF2."""
|
||||||
and items waiting to be received by <SteamID>'''
|
|
||||||
|
|
||||||
if not inp:
|
if not inp:
|
||||||
return tf.__doc__
|
return tf.__doc__
|
||||||
|
|
||||||
if inp.isdigit() : link = 'profiles'
|
if inp.isdigit(): link = 'profiles'
|
||||||
else : link = 'id'
|
else: link = 'id'
|
||||||
|
|
||||||
url = 'http://steamcommunity.com/%s/%s/tfitems?json=1' % \
|
url = 'http://steamcommunity.com/%s/%s/tfitems?json=1' % \
|
||||||
(link,urllib.quote(inp, safe=''))
|
(link,urllib.quote(inp, safe=''))
|
||||||
|
|
||||||
raw_data = urllib.urlopen(url).read().decode('utf-8')
|
raw_data = urllib.urlopen(url).read().decode('utf-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -36,12 +32,13 @@ def tf(inp):
|
||||||
for item, data in inv.iteritems():
|
for item, data in inv.iteritems():
|
||||||
ind = int(data['defindex'])
|
ind = int(data['defindex'])
|
||||||
if data['inventory'] == 0:
|
if data['inventory'] == 0:
|
||||||
if 47<=ind<=55 or 94<=ind<=126 or 134<=ind<=152:
|
if 47 <= ind <= 55 or 94 <= ind <= 126 or 134 <= ind <= 152:
|
||||||
dhats+=1
|
dhats += 1
|
||||||
else:
|
else:
|
||||||
dropped+=1
|
dropped += 1
|
||||||
else:
|
else:
|
||||||
if 47<=ind<=55 or 94<=ind<=126 or 134<=ind<=152:
|
if 47 <= ind <= 55 or 94 <= ind <= 126 or 134 <= ind <= 152:
|
||||||
hats+=1
|
hats += 1
|
||||||
|
|
||||||
return '%s has had %s items and %s hats drop (%s total hats)' % (inp,dropped,dhats,dhats+hats)
|
return '%s has had %s items and %s hats drop (%s total hats)' % \
|
||||||
|
(inp,dropped,dhats,dhats+hats)
|
Loading…
Reference in New Issue