From 7dfb881e428a17f395f44f4dd01b986468427f9c Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 21 Nov 2011 21:41:53 +1300 Subject: [PATCH] Removed SimpleJSON dependency --- plugins/shorten.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/shorten.py b/plugins/shorten.py index 6428141..e6f3166 100644 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -1,11 +1,11 @@ # # Lukeroge -from util import hook +from util import hook, http try: from re import match from urllib2 import urlopen, Request, HTTPError from urllib import urlencode - from simplejson import loads + except ImportError, e: raise Exception('Required module missing: %s' % e.args[0]) @@ -14,12 +14,12 @@ def tiny(url, user, apikey): params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, 'format': 'json'}) req = Request("http://api.bit.ly/v3/shorten?%s" % params) response = urlopen(req) - j = loads(response.read()) + j = http.get_json(response.read()) if j['status_code'] == 200: return j['data']['url'] raise Exception('%s'%j['status_txt']) except HTTPError, e: - raise('HTTP error%s'%e.read()) + return "Invalid URL!" @hook.command def shorten(inp, bot = None):