mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 00:06:30 +01:00
Fixed so nick cmdline/channelname replacement worked with the new execute_cmd paradigm. Also, Resolves Issue 427.
This commit is contained in:
parent
8f914196f4
commit
d2448c3eb6
4 changed files with 23 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue