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.

This commit is contained in:
Griatch 2012-09-29 10:52:31 +02:00
parent f95198fbdb
commit a8dcfff248

View file

@ -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