mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Added ability to abort the command chain by returning a true value from cmd.at_pre_cmd().
This commit is contained in:
parent
58f6c05964
commit
545804dffe
2 changed files with 7 additions and 2 deletions
|
|
@ -401,7 +401,10 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
|||
setattr(cmd, key, val)
|
||||
|
||||
# pre-command hook
|
||||
yield cmd.at_pre_cmd()
|
||||
abort = yield cmd.at_pre_cmd()
|
||||
if abort:
|
||||
# abort sequence
|
||||
returnValue(abort)
|
||||
|
||||
# Parse and execute
|
||||
yield cmd.parse()
|
||||
|
|
|
|||
|
|
@ -255,7 +255,9 @@ class Command(object):
|
|||
|
||||
def at_pre_cmd(self):
|
||||
"""
|
||||
This hook is called before self.parse() on all commands
|
||||
This hook is called before self.parse() on all commands.
|
||||
If this hook returns anything but False/None, the command
|
||||
sequence is aborted.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue