diff options
author | kongr45gpen <electrovesta@gmail.com> | 2017-01-04 16:52:08 +0200 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2017-01-04 16:52:08 +0200 |
commit | 04543aa5ed4a146eaa0827dbac3871d6c9606225 (patch) | |
tree | 3f16299b825f757d5a51955909a17dfa6cf2105b | |
parent | aa94ba150fdb0bd7cec63dae937e0bb52dc1b575 (diff) | |
download | supybot_github-04543aa5ed4a146eaa0827dbac3871d6c9606225.tar.gz supybot_github-04543aa5ed4a146eaa0827dbac3871d6c9606225.tar.bz2 supybot_github-04543aa5ed4a146eaa0827dbac3871d6c9606225.zip |
Improve broken git.io handling
-rw-r--r-- | local/utility.py | 11 |
1 files 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') |