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: 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:
@ -44,4 +40,5 @@ def tf(inp):
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)