mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 23:54:07 +01:00
Web: Fix NameError with snarferShowTargetDomain. Closes GH-1177.
This commit is contained in:
parent
57b77a6725
commit
1f57c31665
@ -130,7 +130,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
|
|
||||||
def getTitle(self, url, raiseErrors):
|
def getTitle(self, url, raiseErrors):
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
text = utils.web.getUrl(url, size=size)
|
(target, text) = utils.web.getUrlTargetAndContent(url, size=size)
|
||||||
try:
|
try:
|
||||||
text = text.decode(utils.web.getEncoding(text) or 'utf8',
|
text = text.decode(utils.web.getEncoding(text) or 'utf8',
|
||||||
'replace')
|
'replace')
|
||||||
@ -147,7 +147,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
parser.close()
|
parser.close()
|
||||||
title = ''.join(parser.data).strip()
|
title = ''.join(parser.data).strip()
|
||||||
if title:
|
if title:
|
||||||
return title
|
return (target, title)
|
||||||
elif raiseErrors:
|
elif raiseErrors:
|
||||||
if len(text) < size:
|
if len(text) < size:
|
||||||
irc.reply(_('That URL appears to have no HTML title.'))
|
irc.reply(_('That URL appears to have no HTML title.'))
|
||||||
@ -170,9 +170,9 @@ class Web(callbacks.PluginRegexp):
|
|||||||
if r and r.search(url):
|
if r and r.search(url):
|
||||||
self.log.debug('Not titleSnarfing %q.', url)
|
self.log.debug('Not titleSnarfing %q.', url)
|
||||||
return
|
return
|
||||||
title = self.getTitle(url, False)
|
(target, title) = self.getTitle(url, False)
|
||||||
if title:
|
if title:
|
||||||
domain = utils.web.getDomain(fd.geturl()
|
domain = utils.web.getDomain(target
|
||||||
if self.registryValue('snarferShowTargetDomain', channel)
|
if self.registryValue('snarferShowTargetDomain', channel)
|
||||||
else url)
|
else url)
|
||||||
s = format(_('Title: %s (at %s)'), title, domain)
|
s = format(_('Title: %s (at %s)'), title, domain)
|
||||||
@ -281,7 +281,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
if not self._checkURLWhitelist(url):
|
if not self._checkURLWhitelist(url):
|
||||||
irc.error("This url is not on the whitelist.")
|
irc.error("This url is not on the whitelist.")
|
||||||
return
|
return
|
||||||
title = self.getTitle(url, True)
|
(target, title) = self.getTitle(url, True)
|
||||||
if title:
|
if title:
|
||||||
if not [y for x,y in optlist if x == 'no-filter']:
|
if not [y for x,y in optlist if x == 'no-filter']:
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
|
Loading…
Reference in New Issue
Block a user