mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Web: add option for having titlesnarfer immune to defaultignore. Closes GH-1101
This commit is contained in:
parent
86d9f49aa5
commit
a81d3ddae6
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user