Skip to content

Instantly share code, notes, and snippets.

@dmptrluke
Created August 29, 2012 02:02
Show Gist options
  • Save dmptrluke/3506062 to your computer and use it in GitHub Desktop.
Save dmptrluke/3506062 to your computer and use it in GitHub Desktop.
# Code by Luke from CloudBot! (https://www.github.com/CloudBot/)
import urllib2
from django.utils import simplejson as json
from urllib import quote_plus
api_url = "http://www.fishbans.com/api/stats/%s/force/"
if len(args) == 1 and args[0] == "":
print "This factoid requires input."
user = args[0]
request = urllib2.urlopen(api_url % quote_plus(user)).read()
j = json.loads(request)
if j["success"] == False:
print "Could not fetch ban data for %s." % user
user_url = "http://fishbans.com/u/%s" % user
ban_count = j["stats"]["totalbans"]
print "The user \x02%s\x02 has \x02%s\x02 bans. See detailed info " \
"at %s" % (user, ban_count, user_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment