mirror of
https://github.com/evennia/evennia.git
synced 2026-03-29 12:07:17 +02:00
Added arg_regex, an optional Command class-method for customizing how commands are identified by using a regex to enforce a specific look/grammar to the command argument. Discussed and suggested in issue 213.
This commit is contained in:
parent
42254fa3c4
commit
690bfadd9d
4 changed files with 13 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ All commands in Evennia inherit from the 'Command' class in this module.
|
|||
|
||||
"""
|
||||
|
||||
import re
|
||||
from src.locks.lockhandler import LockHandler
|
||||
from src.utils.utils import is_iter
|
||||
|
||||
|
|
@ -42,6 +43,11 @@ class CommandMeta(type):
|
|||
temp.append(lockstring)
|
||||
mcs.lock_storage = ";".join(temp)
|
||||
|
||||
if hasattr(mcs, 'arg_regex') and isinstance(mcs.arg_regex, basestring):
|
||||
mcs.arg_regex = re.compile(r"%s" % mcs.arg_regex, re.I)
|
||||
else:
|
||||
mcs.arg_regex = None
|
||||
|
||||
if not hasattr(mcs, 'is_exit'):
|
||||
mcs.is_exit = False
|
||||
if not hasattr(mcs, "help_category"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue