mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 04:57:16 +02:00
Added cmd.funcpart as a way of adding multiple-part commands, each with a possibility to yield with a deferred. This allows for flexible implementation of delayed commands and other asynchronous goodies.
This commit is contained in:
parent
47356ca632
commit
0121f36ac0
2 changed files with 9 additions and 4 deletions
|
|
@ -43,7 +43,7 @@ from src.comms.channelhandler import CHANNELHANDLER
|
|||
from src.utils import logger, utils
|
||||
from src.commands.cmdset import CmdSet
|
||||
from src.commands.cmdparser import at_multimatch_cmd
|
||||
from src.utils.utils import string_suggestions
|
||||
from src.utils.utils import string_suggestions, make_iter
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
cmd.raw_string = unformatted_raw_string
|
||||
|
||||
if hasattr(cmd, 'obj') and hasattr(cmd.obj, 'scripts'):
|
||||
# cmd.obj are automatically made available.
|
||||
# cmd.obj is automatically made available.
|
||||
# we make sure to validate its scripts.
|
||||
yield cmd.obj.scripts.validate()
|
||||
|
||||
|
|
@ -270,6 +270,11 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
# (return value is normally None)
|
||||
ret = yield cmd.func()
|
||||
|
||||
if hasattr(cmd, "funcparts"):
|
||||
# yield on command parts (for multi-part delayed commands)
|
||||
for funcpart in make_iter(cmd.funcparts):
|
||||
yield funcpart()
|
||||
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue