From 5bc91113fe47a9c7defdee94a6fa62fcc3e47db2 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 10 Oct 2004 15:11:19 +0000 Subject: [PATCH] Fixed so disabled commands in other plugins won't break our outfilter. --- plugins/Filter.py | 4 ++-- src/callbacks.py | 7 +++++-- test/test_Filter.py | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugins/Filter.py b/plugins/Filter.py index 6a81fc811..043300624 100644 --- a/plugins/Filter.py +++ b/plugins/Filter.py @@ -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() diff --git a/src/callbacks.py b/src/callbacks.py index 2f5113ca9..40410cbb0 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -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) diff --git a/test/test_Filter.py b/test/test_Filter.py index f29a96955..e60f12179 100644 --- a/test/test_Filter.py +++ b/test/test_Filter.py @@ -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.',