Fixed so disabled commands in other plugins won't break our outfilter.

This commit is contained in:
Jeremy Fincher 2004-10-10 15:11:19 +00:00
parent c2759270ee
commit 5bc91113fe
3 changed files with 22 additions and 5 deletions

View File

@ -106,8 +106,8 @@ class Filter(callbacks.Privmsg):
message isn't sent in the channel itself.
"""
if command:
if command in self._filterCommands and \
command not in conf.supybot.commands.disabled():
if not self.isDisabled(command) and \
command in self._filterCommands:
method = getattr(self, command)
self.outFilters.setdefault(channel, []).append(method)
irc.replySuccess()

View File

@ -993,9 +993,12 @@ class Privmsg(irclib.IrcCallback):
noIgnore = False
Proxy = IrcObjectProxy
commandArgs = ['self', 'irc', 'msg', 'args']
# This must be class-scope, so all plugins use the same one.
# These must be class-scope, so all plugins use the same one.
_mores = ircutils.IrcDict()
_disabled = DisabledCommands()
def isDisabled(self, command):
return self._disabled.disabled(command, self.name())
def __init__(self):
self.__parent = super(Privmsg, self)
myName = self.name()
@ -1066,7 +1069,7 @@ class Privmsg(irclib.IrcCallback):
# Don't canonicalize this name: consider outFilter(self, irc, msg).
# name = canonicalName(name)
if self._disabled.disabled(name, plugin=self.name()):
if self.isDisabled(name):
return False
if hasattr(self, name):
method = getattr(self, name)

View File

@ -32,15 +32,29 @@ from testsupport import *
import re
import supybot.utils as utils
import supybot.callbacks as callbacks
class FilterTest(ChannelPluginTestCase, PluginDocumentation):
plugins = ('Filter',)
plugins = ('Filter', 'Utilities')
def testNoErrors(self):
self.assertNotError('leet foobar')
self.assertNotError('supa1337 foobar')
self.assertNotError('lithp meghan sweeney')
self.assertNotError('aol I\'m too legit to quit.')
def testDisabledCommandsCannotFilter(self):
self.assertNotError('outfilter rot13')
self.assertResponse('echo foo', 'sbb')
self.assertNotError('outfilter')
try:
self.assertNotError('disable rot13')
self.assertError('outfilter rot13')
self.assertNotError('enable rot13')
self.assertNotError('disable notAPlugin rot13')
self.assertNotError('outfilter rot13')
finally:
callbacks.Privmsg._disabled.remove('rot13')
def testHebrew(self):
self.assertResponse('hebrew The quick brown fox '
'jumps over the lazy dog.',