mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Allow ambiguous aliases.
This commit is contained in:
parent
94cdec8a26
commit
7f7562ef42
@ -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:
|
||||||
|
@ -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'")
|
||||||
|
Loading…
Reference in New Issue
Block a user