Catch a webutils.WebError, fix whitespace, and remove a urlquote

This commit is contained in:
James Vega 2004-10-04 18:15:06 +00:00
parent 6a1b9ccaeb
commit b4580384ee

View File

@ -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()