mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
Fixed a non-functioning Command.set_aliases method.
This commit is contained in:
parent
a3e198e857
commit
a575942ea6
1 changed files with 9 additions and 12 deletions
|
|
@ -8,7 +8,7 @@ from builtins import range
|
|||
|
||||
import re
|
||||
from evennia.locks.lockhandler import LockHandler
|
||||
from evennia.utils.utils import is_iter, fill, lazy_property
|
||||
from evennia.utils.utils import is_iter, fill, lazy_property, make_iter
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
|
|
@ -246,27 +246,24 @@ class Command(with_metaclass(CommandMeta, object)):
|
|||
|
||||
def set_aliases(self, new_aliases):
|
||||
"""
|
||||
Update aliases.
|
||||
Replace aliases with new ones.
|
||||
|
||||
Args:
|
||||
new_aliases (list):
|
||||
new_aliases (str or list): Either a ;-separated string
|
||||
or a list of aliases. These aliases will replace the
|
||||
existing ones, if any.
|
||||
|
||||
Notes:
|
||||
This is necessary to use to make sure the optimization
|
||||
caches are properly updated as well.
|
||||
|
||||
"""
|
||||
if not is_iter(new_aliases):
|
||||
try:
|
||||
self.aliases = [str(alias).strip().lower()
|
||||
for alias in self.aliases.split(',')]
|
||||
except Exception:
|
||||
self.aliases = []
|
||||
self.aliases = list(set(alias for alias in self.aliases
|
||||
if alias and alias != self.key))
|
||||
if isinstance(new_aliases, basestring):
|
||||
new_aliases = new_aliases.split(';')
|
||||
aliases = (str(alias).strip().lower() for alias in make_iter(new_aliases))
|
||||
self.aliases = list(set(alias for alias in aliases if alias != self.key))
|
||||
self._optimize()
|
||||
|
||||
|
||||
def match(self, cmdname):
|
||||
"""
|
||||
This is called by the system when searching the available commands,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue