diff --git a/plugins/Web/config.py b/plugins/Web/config.py index 4c0554e55..6b565eec8 100644 --- a/plugins/Web/config.py +++ b/plugins/Web/config.py @@ -60,6 +60,9 @@ conf.registerChannelValue(Web, 'nonSnarfingRegexp', 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 like to exclude from being snarfed."""))) +conf.registerChannelValue(Web, 'checkIgnored', + registry.Boolean(True, _("""Determines whether the title snarfer checks + if the author of a message is ignored."""))) conf.registerGlobalValue(Web, 'urlWhitelist', registry.SpaceSeparatedListOfStrings([], """If set, bot will only fetch data diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index 9525a142a..c777c016a 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -121,6 +121,9 @@ class Web(callbacks.PluginRegexp): """Add the help for "@help Web" here.""" regexps = ['titleSnarfer'] + def noIgnore(self, irc, msg): + return not self.registryValue('checkIgnored', msg.args[0]) + @fetch_sandbox def titleSnarfer(self, irc, msg, match): channel = msg.args[0] diff --git a/plugins/Web/test.py b/plugins/Web/test.py index 074f38c8e..c78bc7c35 100644 --- a/plugins/Web/test.py +++ b/plugins/Web/test.py @@ -30,7 +30,7 @@ from supybot.test import * class WebTestCase(ChannelPluginTestCase): - plugins = ('Web',) + plugins = ('Web', 'Admin',) timeout = 10 if network: def testHeaders(self): @@ -92,6 +92,34 @@ class WebTestCase(ChannelPluginTestCase): finally: conf.supybot.plugins.Web.nonSnarfingRegexp.setValue(snarf) + def testSnarferIgnore(self): + conf.supybot.plugins.Web.titleSnarfer.setValue(True) + (oldprefix, self.prefix) = (self.prefix, 'foo!bar@baz') + try: + self.assertSnarfRegexp('http://google.com/', 'Google') + self.assertNotError('admin ignore add %s' % self.prefix) + self.assertSnarfNoResponse('http://google.com/') + self.assertNoResponse('title http://www.google.com/') + finally: + conf.supybot.plugins.Web.titleSnarfer.setValue(False) + (self.prefix, oldprefix) = (oldprefix, self.prefix) + self.assertNotError('admin ignore remove %s' % oldprefix) + + def testSnarferNotIgnore(self): + conf.supybot.plugins.Web.titleSnarfer.setValue(True) + conf.supybot.plugins.Web.checkIgnored.setValue(False) + (oldprefix, self.prefix) = (self.prefix, 'foo!bar@baz') + try: + self.assertSnarfRegexp('https://google.com/', 'Google') + self.assertNotError('admin ignore add %s' % self.prefix) + self.assertSnarfRegexp('https://www.google.com/', 'Google') + self.assertNoResponse('title http://www.google.com/') + finally: + conf.supybot.plugins.Web.titleSnarfer.setValue(False) + conf.supybot.plugins.Web.checkIgnored.setValue(True) + (self.prefix, oldprefix) = (oldprefix, self.prefix) + self.assertNotError('admin ignore remove %s' % oldprefix) + def testWhitelist(self): fm = conf.supybot.plugins.Web.fetch.maximum() uw = conf.supybot.plugins.Web.urlWhitelist()