Switched to using is.gd for URL shortening

This commit is contained in:
Luke Rogers 2012-08-28 16:38:40 +12:00
parent 3fa8d5d312
commit 2871bd3211
4 changed files with 23 additions and 25 deletions

View file

@ -2,18 +2,14 @@
from util import hook
from urllib2 import HTTPError
from util.web import bitly, ShortenError
from util.web import isgd
@hook.command
def shorten(inp, bot=None):
"shorten <url> - Makes an j.mp/bit.ly shortlink to the url provided."
api_user = bot.config.get("api_keys", {}).get("bitly_user", None)
api_key = bot.config.get("api_keys", {}).get("bitly_api", None)
if api_key is None:
return "error: no api key set"
def shorten(inp):
"shorten <url> - Makes an is.gd shortlink to the url provided."
try:
return bitly(inp, api_user, api_key)
except (HTTPError, ShortenError):
return isgd(inp)
except (HTTPError):
return "Could not shorten '%s'!" % inp