Allow ambiguous aliases.

This commit is contained in:
Jeremy Fincher 2003-12-10 07:43:45 +00:00
parent 94cdec8a26
commit 7f7562ef42
2 changed files with 11 additions and 3 deletions

View File

@ -217,9 +217,10 @@ class Alias(callbacks.Privmsg):
raise AliasError, s raise AliasError, s
name = realName name = realName
cbs = callbacks.findCallbackForCommand(irc, name) cbs = callbacks.findCallbackForCommand(irc, name)
if [cb for cb in cbs if cb != self]: if self in cbs:
s = 'A command with the name %r already exists.' % name if hasattr(self, realName) and realName not in self.aliases:
raise AliasError, s s = 'You can\'t overwrite commands in this plugin.'
raise AliasError, s
if name in self.aliases: if name in self.aliases:
(currentAlias, locked) = self.aliases[name] (currentAlias, locked) = self.aliases[name]
if locked and currentAlias != alias: if locked and currentAlias != alias:

View File

@ -67,6 +67,13 @@ class FunctionsTest(unittest.TestCase):
class AliasTestCase(ChannelPluginTestCase, PluginDocumentation): class AliasTestCase(ChannelPluginTestCase, PluginDocumentation):
plugins = ('Alias', 'Fun', 'Utilities') plugins = ('Alias', 'Fun', 'Utilities')
def testDoesNotOverwriteCommands(self):
self.assertError('alias add alias "echo foo bar baz"')
self.assertError('alias add add "echo foo bar baz"')
self.assertError('alias add remove "echo foo bar baz"')
self.assertError('alias add lock "echo foo bar baz"')
self.assertError('alias add unlock "echo foo bar baz"')
def testAliasHelp(self): def testAliasHelp(self):
self.assertNotError('alias add slashdot foo') self.assertNotError('alias add slashdot foo')
self.assertRegexp('help slashdot', "Alias for 'foo'") self.assertRegexp('help slashdot', "Alias for 'foo'")