mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Catch a webutils.WebError, fix whitespace, and remove a urlquote
This commit is contained in:
parent
6a1b9ccaeb
commit
b4580384ee
@ -139,11 +139,14 @@ class ShrinkUrl(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
url = m.group(1)
|
url = m.group(1)
|
||||||
if len(url) > self.registryValue('minimumLength', channel):
|
if len(url) > self.registryValue('minimumLength', channel):
|
||||||
cmd = self.registryValue('default', channel)
|
cmd = self.registryValue('default', channel)
|
||||||
|
try:
|
||||||
if cmd == 'ln':
|
if cmd == 'ln':
|
||||||
(shortUrl, _) = self._getLnUrl(url)
|
(shortUrl, _) = self._getLnUrl(url)
|
||||||
elif cmd == 'tiny':
|
elif cmd == 'tiny':
|
||||||
shortUrl = self._getTinyUrl(url)
|
shortUrl = self._getTinyUrl(url)
|
||||||
text = text.replace(url, shortUrl)
|
text = text.replace(url, shortUrl)
|
||||||
|
except webutils.WebError:
|
||||||
|
pass
|
||||||
newMsg = ircmsgs.privmsg(channel, text, msg=msg)
|
newMsg = ircmsgs.privmsg(channel, text, msg=msg)
|
||||||
newMsg.tag('shrunken')
|
newMsg.tag('shrunken')
|
||||||
irc.queueMsg(newMsg)
|
irc.queueMsg(newMsg)
|
||||||
@ -192,7 +195,6 @@ class ShrinkUrl(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
try:
|
try:
|
||||||
return self.db.getLn(url)
|
return self.db.getLn(url)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
url = webutils.urlquote(url)
|
|
||||||
text = webutils.getUrl('http://ln-s.net/home/api.jsp?url=%s' % url)
|
text = webutils.getUrl('http://ln-s.net/home/api.jsp?url=%s' % url)
|
||||||
(code, lnurl) = text.split(None, 1)
|
(code, lnurl) = text.split(None, 1)
|
||||||
lnurl = lnurl.strip()
|
lnurl = lnurl.strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user