def do_next_queued_command(target): target.ndb.active_command = None if target.ndb.command_queue and not target.is_frozen: # commands are in queue, so do the next one (FIFO) next_command = target.ndb.command_queue.pop() cmdhandler.cmdhandler(target.sessions.get()[0], next_command.raw_string)
def data_in(self, text=None, **kwargs): """ Send User->Evennia. This will in effect execute a command string on the server. Note that oob data is already sent to the oobhandler at this point. """ #explicitly check for None since text can be an empty string, which is #also valid if text is not None: # this is treated as a command input #text = to_unicode(escape_control_sequences(text), encoding=self.encoding) # handle the 'idle' command if text.strip() == _IDLE_COMMAND: self.update_session_counters(idle=True) return if self.player: # nick replacement puppet = self.player.get_puppet(self.sessid) if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = self.player.nicks.nickreplace(text, categories=("inputline", "channels"), include_player=False) cmdhandler(self, text, callertype="session", sessid=self.sessid) self.update_session_counters()
def text(session, *args, **kwargs): """ Main text input from the client. This will execute a command string on the server. Args: text (str): First arg is used as text-command input. Other arguments are ignored. """ # from evennia.server.profiling.timetrace import timetrace # text = timetrace(text, "ServerSession.data_in") text = args[0] if args else None # explicitly check for None since text can be an empty string, which is # also valid if text is None: return # this is treated as a command input # handle the 'idle' command if text.strip() == _IDLE_COMMAND: session.update_session_counters(idle=True) return if session.player: # nick replacement puppet = session.puppet if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = session.player.nicks.nickreplace(text, categories=("inputline", "channels"), include_player=False) kwargs.pop("options", None) cmdhandler(session, text, callertype="session", session=session, **kwargs) session.update_session_counters()
def func(self): # reroute to another command from evennia.commands import cmdhandler cmdhandler.cmdhandler(self.session, self.raw_string, cmdobj=CmdFocusInteraction(), cmdobj_key=self.cmdname)
def data_in(self, text=None, **kwargs): """ Send User->Evennia. This will in effect execute a command string on the server. Note that oob data is already sent to the oobhandler at this point. """ #explicitly check for None since text can be an empty string, which is #also valid if text is not None: # this is treated as a command input #text = to_unicode(escape_control_sequences(text), encoding=self.encoding) # handle the 'idle' command if text.strip() == _IDLE_COMMAND: self.update_session_counters(idle=True) return if self.player: # nick replacement puppet = self.player.get_puppet(self.sessid) if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = self.player.nicks.nickreplace( text, categories=("inputline", "channels"), include_player=False) cmdhandler(self, text, callertype="session", sessid=self.sessid) self.update_session_counters()
def execute_cmd(self, raw_string, session=None, **kwargs): """ 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 takes player nicks into account, but not nicks of eventual puppets. Args: raw_string (str): Raw command input coming from the command line. session (Session, optional): The session to be responsible for the command-send Kwargs: kwargs (any): Other keyword arguments will be added to the found command object instance 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. """ raw_string = to_unicode(raw_string) raw_string = self.nicks.nickreplace(raw_string, categories=("inputline", "channel"), include_player=False) if not session and _MULTISESSION_MODE in (0, 1): # for these modes we use the first/only session sessions = self.sessions.get() session = sessions[0] if sessions else None return cmdhandler.cmdhandler(self, raw_string, callertype="player", session=session, **kwargs)
def execute_cmd(self, raw_string, session=None, **kwargs): """ Do something as this account. This method is never called normally, but only when the account object itself is supposed to execute the command. It takes account nicks into account, but not nicks of eventual puppets. Args: raw_string (str): Raw command input coming from the command line. session (Session, optional): The session to be responsible for the command-send Kwargs: kwargs (any): Other keyword arguments will be added to the found command object instance 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. """ raw_string = to_unicode(raw_string) raw_string = self.nicks.nickreplace(raw_string, categories=("inputline", "channel"), include_account=False) if not session and _MULTISESSION_MODE in (0, 1): # for these modes we use the first/only session sessions = self.sessions.get() session = sessions[0] if sessions else None return cmdhandler.cmdhandler(self, raw_string, callertype="account", session=session, **kwargs)
def node_quit(caller, raw_string, **kwargs): quiet = kwargs.get("quiet") text = "" if not quiet: text = "Goodbye for now!\n" # we check an Attribute on the caller to see if we should # leave the game entirely when leaving if caller.db.evscaperoom_standalone: from evennia.commands import cmdhandler from evennia import default_cmds cmdhandler.cmdhandler(caller.ndb._menutree._session, "", cmdobj=default_cmds.CmdQuit(), cmdobj_key="@quit") return text, None # empty options exit the menu
def execute_cmd(self, raw_string, sessid=None, **kwargs): """ 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 takes player nicks into account, but not nicks of eventual puppets. raw_string - raw command input coming from the command line. sessid - the optional session id to be responsible for the command-send **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. """ raw_string = to_unicode(raw_string) raw_string = self.nicks.nickreplace(raw_string, categories=("inputline", "channel"), include_player=False) if not sessid and _MULTISESSION_MODE in (0, 1): # in this case, we should either have only one sessid, or the sessid # should not matter (since the return goes to all of them we can # just use the first one as the source) try: sessid = self.get_all_sessions()[0].sessid except IndexError: # this can happen for bots sessid = None return cmdhandler.cmdhandler(self, raw_string, callertype="player", sessid=sessid, **kwargs)
def text(session, *args, **kwargs): """ Main text input from the client. This will execute a command string on the server. Args: session (Session): The active Session to receive the input. text (str): First arg is used as text-command input. Other arguments are ignored. """ #from evennia.server.profiling.timetrace import timetrace #text = timetrace(text, "ServerSession.data_in") text = args[0] if args else None #explicitly check for None since text can be an empty string, which is #also valid if text is None: return # this is treated as a command input # handle the 'idle' command if text.strip() in _IDLE_COMMAND: session.update_session_counters(idle=True) return if session.player: # nick replacement puppet = session.puppet if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = session.player.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=False) kwargs.pop("options", None) cmdhandler(session, text, callertype="session", session=session, **kwargs) session.update_session_counters()
def data_in(self, text=None, **kwargs): """ Send data User->Evennia. This will in effect execute a command string on the server. Note that oob data is already sent separately to the oobhandler at this point. Kwargs: text (str): A text to relay kwargs (any): Other parameters from the protocol. """ #from evennia.server.profiling.timetrace import timetrace #text = timetrace(text, "ServerSession.data_in") #explicitly check for None since text can be an empty string, which is #also valid if text is not None: # this is treated as a command input #text = to_unicode(escape_control_sequences(text), encoding=self.encoding) # handle the 'idle' command if text.strip() == _IDLE_COMMAND: self.update_session_counters(idle=True) return if self.player: # nick replacement puppet = self.puppet if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = self.player.nicks.nickreplace( text, categories=("inputline", "channels"), include_player=False) cmdhandler(self, text, callertype="session", session=self) self.update_session_counters()
def json(session, *args, **kwargs): """ Main cmd input from the client. This mimics the way text is handled to work with legacy string implementation. Args: cmd (str): First arg is used as text-command input. Other arguments are ignored. Kwargs: opts (dict): Holds all of the switch/arg/param in json format. """ cmd = args[0] if args else None # explicitly check for None since cmd can be an empty string, which is # also valid if cmd is None: return # this is treated as a command input # handle the 'idle' command if cmd.strip() in _IDLE_COMMAND: session.update_session_counters(idle=True) return if session.player: # nick replacement puppet = session.puppet if puppet: cmd = puppet.nicks.nickreplace(cmd, categories=("inputline", "channel"), include_player=True) else: cmd = session.player.nicks.nickreplace(cmd, categories=("inputline", "channel"), include_player=False) kwargs["json"] = True cmdhandler(session, cmd, callertype="session", session=session, **kwargs) session.update_session_counters()
def data_in(self, text=None, **kwargs): """ Send data User->Evennia. This will in effect execute a command string on the server. Note that oob data is already sent separately to the oobhandler at this point. Kwargs: text (str): A text to relay kwargs (any): Other parameters from the protocol. """ # from evennia.server.profiling.timetrace import timetrace # text = timetrace(text, "ServerSession.data_in") # explicitly check for None since text can be an empty string, which is # also valid if text is not None: # this is treated as a command input # text = to_unicode(escape_control_sequences(text), encoding=self.encoding) # handle the 'idle' command if text.strip() == _IDLE_COMMAND: self.update_session_counters(idle=True) return if self.player: # nick replacement puppet = self.puppet if puppet: text = puppet.nicks.nickreplace(text, categories=("inputline", "channel"), include_player=True) else: text = self.player.nicks.nickreplace( text, categories=("inputline", "channels"), include_player=False ) cmdhandler(self, text, callertype="session", session=self) self.update_session_counters()
def inner_func(self): last_command = self.caller.ndb.last_command if last_command: # self.caller.execute_cmd(last_command.raw_string) self.caller.msg(last_command.raw_string) cmdhandler.cmdhandler(self.session, last_command.raw_string)
def execute_cmd(self, raw_string, session=None, **kwargs): """Support execute_cmd(), like account and object.""" return cmdhandler.cmdhandler( self, raw_string, callertype="account", session=session, **kwargs )