mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 18:44:04 +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
|
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
|
||||||
like to exclude from being snarfed.""")))
|
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',
|
conf.registerGlobalValue(Web, 'urlWhitelist',
|
||||||
registry.SpaceSeparatedListOfStrings([], """If set, bot will only fetch data
|
registry.SpaceSeparatedListOfStrings([], """If set, bot will only fetch data
|
||||||
|
@ -121,6 +121,9 @@ class Web(callbacks.PluginRegexp):
|
|||||||
"""Add the help for "@help Web" here."""
|
"""Add the help for "@help Web" here."""
|
||||||
regexps = ['titleSnarfer']
|
regexps = ['titleSnarfer']
|
||||||
|
|
||||||
|
def noIgnore(self, irc, msg):
|
||||||
|
return not self.registryValue('checkIgnored', msg.args[0])
|
||||||
|
|
||||||
@fetch_sandbox
|
@fetch_sandbox
|
||||||
def titleSnarfer(self, irc, msg, match):
|
def titleSnarfer(self, irc, msg, match):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
from supybot.test import *
|
from supybot.test import *
|
||||||
|
|
||||||
class WebTestCase(ChannelPluginTestCase):
|
class WebTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('Web',)
|
plugins = ('Web', 'Admin',)
|
||||||
timeout = 10
|
timeout = 10
|
||||||
if network:
|
if network:
|
||||||
def testHeaders(self):
|
def testHeaders(self):
|
||||||
@ -92,6 +92,34 @@ class WebTestCase(ChannelPluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.Web.nonSnarfingRegexp.setValue(snarf)
|
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):
|
def testWhitelist(self):
|
||||||
fm = conf.supybot.plugins.Web.fetch.maximum()
|
fm = conf.supybot.plugins.Web.fetch.maximum()
|
||||||
uw = conf.supybot.plugins.Web.urlWhitelist()
|
uw = conf.supybot.plugins.Web.urlWhitelist()
|
||||||
|
Loading…
Reference in New Issue
Block a user