mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Web: Fix title fetching.
This commit is contained in:
parent
7884ed5133
commit
a070b658a0
@ -128,7 +128,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
def noIgnore(self, irc, msg):
|
def noIgnore(self, irc, msg):
|
||||||
return not self.registryValue('checkIgnored', msg.args[0])
|
return not self.registryValue('checkIgnored', msg.args[0])
|
||||||
|
|
||||||
def getTitle(self, url, raiseErrors):
|
def getTitle(self, irc, url, raiseErrors):
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
(target, text) = utils.web.getUrlTargetAndContent(url, size=size)
|
(target, text) = utils.web.getUrlTargetAndContent(url, size=size)
|
||||||
try:
|
try:
|
||||||
@ -150,10 +150,11 @@ class Web(callbacks.PluginRegexp):
|
|||||||
return (target, 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.error(_('That URL appears to have no HTML title.'),
|
||||||
|
Raise=True)
|
||||||
else:
|
else:
|
||||||
irc.reply(format(_('That URL appears to have no HTML title '
|
irc.error(format(_('That URL appears to have no HTML title '
|
||||||
'within the first %S.'), size))
|
'within the first %S.'), size), Raise=True)
|
||||||
|
|
||||||
@fetch_sandbox
|
@fetch_sandbox
|
||||||
def titleSnarfer(self, irc, msg, match):
|
def titleSnarfer(self, irc, msg, match):
|
||||||
@ -170,7 +171,10 @@ 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
|
||||||
(target, title) = self.getTitle(url, False)
|
r = self.getTitle(irc, url, False)
|
||||||
|
if not r:
|
||||||
|
return
|
||||||
|
(target, title) = r
|
||||||
if title:
|
if title:
|
||||||
domain = utils.web.getDomain(target
|
domain = utils.web.getDomain(target
|
||||||
if self.registryValue('snarferShowTargetDomain', channel)
|
if self.registryValue('snarferShowTargetDomain', channel)
|
||||||
@ -281,7 +285,10 @@ 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
|
||||||
(target, title) = self.getTitle(url, True)
|
r = self.getTitle(irc, url, True)
|
||||||
|
if not r:
|
||||||
|
return
|
||||||
|
(target, title) = r
|
||||||
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