diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index d846158a28..a9c7389c0c 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -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 diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py index 8d89cdcae6..b631b7cd1a 100644 --- a/evennia/server/inputfuncs.py +++ b/evennia/server/inputfuncs.py @@ -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() diff --git a/evennia/server/serversession.py b/evennia/server/serversession.py index 0ac3b37795..be7a0d0602 100644 --- a/evennia/server/serversession.py +++ b/evennia/server/serversession.py @@ -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"