If a request to git.io times out, fall back to full url

This commit is contained in:
jesopo 2018-12-14 08:49:37 +00:00
parent d2fe95e0cc
commit 1ffc7863a0

View file

@ -105,9 +105,12 @@ class Module(ModuleManager.BaseModule):
return "" return ""
def _short_url(self, url): def _short_url(self, url):
page = utils.http.request("https://git.io", method="POST", try:
post_data={"url": url}) page = utils.http.request("https://git.io", method="POST",
return page.headers["Location"] post_data={"url": url})
return page.headers["Location"]
except utils.http.HTTPTimeoutException:
return url
def _change_count(self, n, symbol, color): def _change_count(self, n, symbol, color):
return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("") return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("")