Added a way to have the urlsnarfer report exceptions (hotsnotnound, ...)

(Should be possible changed to only ioExceptions)
Enable/Disable via 'supybot.plugins.Web.snarferReportIOExceptions'
This commit is contained in:
George Miller 2013-04-03 22:53:52 +00:00 committed by Valentin Lorentz
parent d5a9c3f25b
commit 0150c79924
2 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,9 @@ Web = conf.registerPlugin('Web')
conf.registerChannelValue(Web, 'titleSnarfer', conf.registerChannelValue(Web, 'titleSnarfer',
registry.Boolean(False, _("""Determines whether the bot will output the registry.Boolean(False, _("""Determines whether the bot will output the
HTML title of URLs it sees in the channel."""))) HTML title of URLs it sees in the channel.""")))
conf.registerChannelValue(Web, 'snarferReportIOExceptions',
registry.Boolean(False, _("""Determines whether the bot will notfiy the user
about network exceptions like hostnotfound, timeout ....""")))
conf.registerChannelValue(Web, 'nonSnarfingRegexp', conf.registerChannelValue(Web, 'nonSnarfingRegexp',
registry.Regexp(None, _("""Determines what URLs matching the given regexp registry.Regexp(None, _("""Determines what URLs matching the given regexp
will not be snarfed. Give the empty string if you have no URLs that you'd will not be snarfed. Give the empty string if you have no URLs that you'd

View File

@ -97,6 +97,8 @@ class Web(callbacks.PluginRegexp):
text = text.decode('utf8', 'replace') text = text.decode('utf8', 'replace')
except utils.web.Error, e: except utils.web.Error, e:
self.log.info('Couldn\'t snarf title of %u: %s.', url, e) self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
if self.registryValue('snarferReportIOExceptions', channel):
irc.reply(url+" : "+utils.web.strError(e), prefixNick=False)
return return
parser = Title() parser = Title()
try: try: