Made enable case-insensitive.

This commit is contained in:
Jeremy Fincher 2004-02-08 23:54:01 +00:00
parent 72adc73330
commit da209e5a36
2 changed files with 14 additions and 7 deletions

View File

@ -226,13 +226,16 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
Re-enables the command <command> for all non-owner users. Re-enables the command <command> for all non-owner users.
""" """
command = privmsgs.getArgs(args) command = privmsgs.getArgs(args)
try: command = command.lower()
anticapability = ircdb.makeAntiCapability(command) L = []
except ValueError: for capability in conf.supybot.defaultCapabilities():
irc.error('%r is not a valid command.' % command) if ircdb.isAntiCapability(capability):
return nonAntiCapability = ircdb.unAntiCapability(capability)
if anticapability in conf.supybot.defaultCapabilities(): if nonAntiCapability.lower() == command:
conf.supybot.defaultCapabilities().remove(anticapability) L.append(capability)
if L:
for capability in L:
conf.supybot.defaultCapabilities().remove(capability)
irc.replySuccess() irc.replySuccess()
else: else:
irc.error('That command wasn\'t disabled.') irc.error('That command wasn\'t disabled.')

View File

@ -75,6 +75,10 @@ class AdminTestCase(PluginTestCase, PluginDocumentation):
def testEnable(self): def testEnable(self):
self.assertError('enable enable') self.assertError('enable enable')
def testEnableIsCaseInsensitive(self):
self.assertNotError('disable Foo')
self.assertNotError('enable foo')
def testJoin(self): def testJoin(self):
m = self.getMsg('join #foo') m = self.getMsg('join #foo')
self.assertEqual(m.command, 'JOIN') self.assertEqual(m.command, 'JOIN')