From a8dcfff24815a0ed865bd526e0fac5f97c4b8756 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 29 Sep 2012 10:52:31 +0200 Subject: [PATCH] Fixing the strange edge-case of trying to define a command with the same alias being defined multiple times or aliases being the same as the command key. This is now excluded at the Command metaclass level. --- src/commands/command.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/command.py b/src/commands/command.py index 2a5a29376b..112ca5c5a0 100644 --- a/src/commands/command.py +++ b/src/commands/command.py @@ -23,10 +23,11 @@ class CommandMeta(type): mcs.key = mcs.key.lower() if mcs.aliases and not is_iter(mcs.aliases): try: - mcs.aliases = mcs.aliases.split(',') + mcs.aliases = [str(alias).strip().lower() for alias in mcs.aliases.split(',')] except Exception: mcs.aliases = [] - mcs.aliases = [str(alias).strip().lower() for alias in mcs.aliases] + mcs.aliases = list(set(alias for alias in mcs.aliases if alias != mcs.key)) + # optimization - a set is much faster to match against than a list mcs._matchset = set([mcs.key] + mcs.aliases) # optimization for looping over keys+aliases