mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Fixed so disabled commands in other plugins won't break our outfilter.
This commit is contained in:
parent
c2759270ee
commit
5bc91113fe
@ -106,8 +106,8 @@ class Filter(callbacks.Privmsg):
|
|||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
if command:
|
if command:
|
||||||
if command in self._filterCommands and \
|
if not self.isDisabled(command) and \
|
||||||
command not in conf.supybot.commands.disabled():
|
command in self._filterCommands:
|
||||||
method = getattr(self, command)
|
method = getattr(self, command)
|
||||||
self.outFilters.setdefault(channel, []).append(method)
|
self.outFilters.setdefault(channel, []).append(method)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
@ -993,9 +993,12 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
noIgnore = False
|
noIgnore = False
|
||||||
Proxy = IrcObjectProxy
|
Proxy = IrcObjectProxy
|
||||||
commandArgs = ['self', 'irc', 'msg', 'args']
|
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()
|
_mores = ircutils.IrcDict()
|
||||||
_disabled = DisabledCommands()
|
_disabled = DisabledCommands()
|
||||||
|
def isDisabled(self, command):
|
||||||
|
return self._disabled.disabled(command, self.name())
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__parent = super(Privmsg, self)
|
self.__parent = super(Privmsg, self)
|
||||||
myName = self.name()
|
myName = self.name()
|
||||||
@ -1066,7 +1069,7 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
|
|
||||||
# Don't canonicalize this name: consider outFilter(self, irc, msg).
|
# Don't canonicalize this name: consider outFilter(self, irc, msg).
|
||||||
# name = canonicalName(name)
|
# name = canonicalName(name)
|
||||||
if self._disabled.disabled(name, plugin=self.name()):
|
if self.isDisabled(name):
|
||||||
return False
|
return False
|
||||||
if hasattr(self, name):
|
if hasattr(self, name):
|
||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
|
@ -32,15 +32,29 @@ from testsupport import *
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class FilterTest(ChannelPluginTestCase, PluginDocumentation):
|
class FilterTest(ChannelPluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Filter',)
|
plugins = ('Filter', 'Utilities')
|
||||||
def testNoErrors(self):
|
def testNoErrors(self):
|
||||||
self.assertNotError('leet foobar')
|
self.assertNotError('leet foobar')
|
||||||
self.assertNotError('supa1337 foobar')
|
self.assertNotError('supa1337 foobar')
|
||||||
self.assertNotError('lithp meghan sweeney')
|
self.assertNotError('lithp meghan sweeney')
|
||||||
self.assertNotError('aol I\'m too legit to quit.')
|
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):
|
def testHebrew(self):
|
||||||
self.assertResponse('hebrew The quick brown fox '
|
self.assertResponse('hebrew The quick brown fox '
|
||||||
'jumps over the lazy dog.',
|
'jumps over the lazy dog.',
|
||||||
|
Loading…
Reference in New Issue
Block a user