Added a missing execute_cmd on the Session. It got lost after the inputfunc changes.

This commit is contained in:
Griatch 2016-04-24 15:23:55 +02:00
parent 8bf63885e2
commit 68e5c4d283
3 changed files with 26 additions and 6 deletions

View file

@ -424,11 +424,10 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
def execute_cmd(self, raw_string, session=None, **kwargs):
"""
Do something as this object. This method is a copy of the
`execute_cmd` method on the session. This is never called
normally, it's only used when wanting specifically to let an
object be the caller of a command. It makes use of nicks of
eventual connected players as well.
Do something as this object. This is never called normally,
it's only used when wanting specifically to let an object be
the caller of a command. It makes use of nicks of eventual
connected players as well.
Args:
raw_string (string): Raw command input

View file

@ -68,7 +68,8 @@ def text(session, *args, **kwargs):
else:
text = session.player.nicks.nickreplace(text,
categories=("inputline", "channels"), include_player=False)
cmdhandler(session, text, callertype="session", session=session)
kwargs.pop("options", None)
cmdhandler(session, text, callertype="session", session=session, **kwargs)
session.update_session_counters()

View file

@ -381,6 +381,26 @@ class ServerSession(Session):
else:
self.data_out(**kwargs)
def execute_cmd(self, raw_string, **kwargs):
"""
Do something as this object. This method is normally never
called directly, instead incoming command instructions are
sent to the appropriate inputfunc already at the sessionhandler
level. This method allows Python code to inject commands into
this stream, and will lead to the text inputfunc be called.
Args:
raw_string (string): Raw command input
Kwargs:
Other keyword arguments will be added to the found command
object instace as variables before it executes. This is
unused by default Evennia but may be used to set flags and
change operating paramaters for commands at run-time.
"""
# inject instruction into input stream
kwargs["text"] = ((raw_string,), {})
self.sessionhandler.data_in(self, **kwargs)
def __eq__(self, other):
"Handle session comparisons"