This commit is contained in:
ipsum 2010-04-18 13:24:17 -04:00
parent 3a2bd24352
commit 148733567e
1 changed files with 16 additions and 19 deletions

View File

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