AttackProtector: Add configuration variable plugin.AttackProtector.enable.

master
Valentin Lorentz 2012-05-05 19:19:19 +00:00
parent 40f021d3b3
commit 64a2c8c962
3 changed files with 15 additions and 1 deletions

View File

@ -76,6 +76,9 @@ AttackProtector = conf.registerPlugin('AttackProtector')
# conf.registerGlobalValue(AttackProtector, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName."""))
conf.registerChannelValue(AttackProtector, 'enable',
registry.Boolean(True, _("""Determines whether or not AttackProtector
is enabled on this channel.""")))
conf.registerGlobalValue(AttackProtector, 'exempt',
registry.String('nopunish', _("""If a user has this capability, he won't be
punished by AttackProtector""")))

View File

@ -164,6 +164,8 @@ class AttackProtector(callbacks.Plugin):
if not ircutils.isChannel(channel):
return
if not self.registryValue('enable', channel):
return
try:
ircdb.users.getUser(msg.prefix) # May raise KeyError

View File

@ -33,7 +33,7 @@ from supybot.test import *
import supybot.ircdb as ircdb
class AttackProtectorTestCase(ChannelPluginTestCase):
plugins = ('AttackProtector', 'Utilities', 'User')
plugins = ('AttackProtector', 'Config', 'Utilities', 'User')
config = {'supybot.plugins.AttackProtector.join.detection': '5p2',
'supybot.plugins.AttackProtector.part.punishment':
'command echo hi !'}
@ -219,6 +219,15 @@ class AttackProtectorTestCase(ChannelPluginTestCase):
self.failIf(self._getIfAnswerIsThisBan(),
'Doesn\'t clean the join collection after having banned.')
def testDisable(self):
for i in range(1, 11):
msg = ircmsgs.privmsg(self.channel, 'Hi, this is a flood',
prefix=self.prefix)
self.irc.feedMsg(msg)
self.assertNotError('config plugin.AttackProtector.enable False')
self.failIf(self._getIfAnswerIsThisKick('message'),
'Punishment even if disabled')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: