diff --git a/src/callbacks.py b/src/callbacks.py index c2c75461f..ad60ba7ba 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -98,7 +98,13 @@ def canonicalName(command): Currently, this makes everything lowercase and removes all dashes and underscores. """ - return command.translate(string.ascii, '\t -_').lower() + assert not isinstance(command, unicode) + special = '\t -_' + reAppend = '' + while command and command[-1] in special: + reAppend = command[-1] + reAppend + command = command[:-1] + return command.translate(string.ascii, special).lower() + reAppend def reply(msg, s, prefixName=True, private=False, notice=False): """Makes a reply to msg with the payload s""" diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 85c0ad8e2..dbe2b19b7 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -124,7 +124,8 @@ class FunctionsTestCase(unittest.TestCase): self.assertEqual('foobar', callbacks.canonicalName('FOO-bar')) self.assertEqual('foobar', callbacks.canonicalName('FOOBAR')) self.assertEqual('foobar', callbacks.canonicalName('foo___bar')) - self.assertEqual('foobar', callbacks.canonicalName('_f_o_o-b_a_r_')) + self.assertEqual('foobar', callbacks.canonicalName('_f_o_o-b_a_r')) + self.assertEqual('foobar--', callbacks.canonicalName('foobar--')) def testAddressed(self): oldprefixchars = conf.prefixChars