diff --git a/src/objects/models.py b/src/objects/models.py index 6164ee58ee..fd0d92a9a0 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -360,12 +360,14 @@ class ObjectDB(TypedObject): def execute_cmd(self, raw_string, sessid=None): """ - Do something as this object. This command transparently - lets its typeclass execute the command. Evennia also calls - this method whenever the player sends a command on the command line. + 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. Argument: raw_string (string) - raw command input + sessid (int) - optional session id to return results to Returns Deferred - this is an asynchronous Twisted object that will not fire until the command has actually finished executing. To overload @@ -386,8 +388,8 @@ class ObjectDB(TypedObject): # fetch the nick data efficiently nicks = self.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel")) if self.has_player: - pnicks = self.player.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel")) - nicks = list(nicks) + list(pnicks) + # attach player nicks as well, but after the object-level nicks + nicks = list(nicks) + list(pself.player.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel"))) for nick in nicks: if nick.db_key in raw_list: raw_string = raw_string.replace(nick.db_key, nick.db_strvalue, 1) diff --git a/src/players/models.py b/src/players/models.py index 06f48ba4a5..52ef0d84ae 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -400,8 +400,9 @@ class PlayerDB(TypedObject, AbstractUser): def execute_cmd(self, raw_string, sessid=None): """ - Do something as this player. This command transparently - lets its typeclass execute the command. + Do something as this player. This method is never called normally, + but only when the player object itself is supposed to execute the command. It + does not take nicks on eventual puppets into account. raw_string - raw command input coming from the command line. """ # nick replacement - we require full-word matching. diff --git a/src/server/portal/portalsessionhandler.py b/src/server/portal/portalsessionhandler.py index 2418f2fc55..369f85e96b 100644 --- a/src/server/portal/portalsessionhandler.py +++ b/src/server/portal/portalsessionhandler.py @@ -49,7 +49,6 @@ class PortalSessionHandler(SessionHandler): self.sessions[sessid] = session # sync with server-side if self.portal.amp_protocol: # this is a timing issue - print "syncing", sessdata self.portal.amp_protocol.call_remote_ServerAdmin(sessid, operation=PCONN, data=sessdata) diff --git a/src/server/serversession.py b/src/server/serversession.py index a497124e5c..be11328d08 100644 --- a/src/server/serversession.py +++ b/src/server/serversession.py @@ -184,6 +184,19 @@ class ServerSession(Session): if text.strip() == IDLE_COMMAND: self.update_session_counters(idle=True) return + if self.player: + # nick replacement + nicks = self.player.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel")) + puppet = self.player.get_puppet(self.sessid) + if puppet: + # merge, give prio to the lowest level (puppet) + nicks = list(puppet.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel"))) + list(nicks) + raw_list = text.split(None) + raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]] + for nick in nicks: + if nick.db_key in raw_list: + text = text.replace(nick.db_key, nick.db_strvalue, 1) + break cmdhandler.cmdhandler(self, text, callertype="session", sessid=self.sessid) self.update_session_counters() if "oob" in kwargs: