From 04543aa5ed4a146eaa0827dbac3871d6c9606225 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Wed, 4 Jan 2017 16:52:08 +0200 Subject: Improve broken git.io handling --- local/utility.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/local/utility.py b/local/utility.py index 9896106..1a7954a 100644 --- a/local/utility.py +++ b/local/utility.py @@ -118,9 +118,14 @@ def getShortURL(longurl): data = 'url=%s' % (longurl) # Temporarily disabled url = longurl - #req = urllib2.Request("https://git.io/", data) - #response = urllib2.urlopen(req) - #url = response.info().getheader('Location') + try: + req = urllib2.Request("https://git.io/", data) + response = urllib2.urlopen(req) + url = response.info().getheader('Location') + except IOError as e: + # Bad luck + log.warning("URL shortening failed with: %s" % (e.message,)) + url = longurl return ircutils.mircColor(url, "purple") getShortURL.github = re.compile('^([a-z]*\:\/\/)?([^\/]+.)?github.com') -- cgit v1.2.3