<spanid="evennia-commands-default-muxcommand"></span><h1>evennia.commands.default.muxcommand<aclass="headerlink"href="#module-evennia.commands.default.muxcommand"title="Permalink to this headline">¶</a></h1>
<p>The command template for the default MUX-style command set. There
is also an Account/OOC version that makes sure caller is an Account object.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.commands.default.muxcommand.</code><codeclass="sig-name descname">MuxCommand</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">has_perm</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">srcobj</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.has_perm"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.has_perm"title="Permalink to this definition">¶</a></dt>
<dd><p>This is called by the cmdhandler to determine
if srcobj is allowed to execute this command.
We just show it here for completeness - we
are satisfied using the default check in Command.</p>
<codeclass="sig-name descname">at_pre_cmd</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.at_pre_cmd"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.at_pre_cmd"title="Permalink to this definition">¶</a></dt>
<dd><p>This hook is called before self.parse() on all commands</p>
<codeclass="sig-name descname">at_post_cmd</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.at_post_cmd"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.at_post_cmd"title="Permalink to this definition">¶</a></dt>
<dd><p>This hook is called after the command has finished executing
<codeclass="sig-name descname">parse</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.parse"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.parse"title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called by the cmdhandler once the command name
has been identified. It creates a new set of member variables
that can be later accessed from self.func() (see below)</p>
<p>The following variables are available for our use when entering this
method (from the command definition, and assigned on the fly by the
cmdhandler):</p>
<blockquote>
<div><p>self.key - the name of this command (‘look’)
self.aliases - the aliases of this cmd (‘l’)
self.permissions - permission string for this command
self.help_category - overall category of command</p>
<p>self.caller - the object calling this command
self.cmdstring - the actual command name used to call this</p>
<blockquote>
<div><dlclass="simple">
<dt>(this allows you to know which alias was used,</dt><dd><p>for example)</p>
</dd>
</dl>
</div></blockquote>
<p>self.args - the raw input; everything following self.cmdstring.
self.cmdset - the cmdset from which this command was picked. Not</p>
<blockquote>
<div><p>often used (useful for commands like ‘help’ or to
list all available commands etc)</p>
</div></blockquote>
<dlclass="simple">
<dt>self.obj - the object on which this command was defined. It is often</dt><dd><p>the same as self.caller.</p>
</dd>
</dl>
</div></blockquote>
<p>A MUX command has the following possible syntax:</p>
<blockquote>
<div><p>name[ with several words][/switch[/switch..]] arg1[,arg2,…] [[=|,] arg[,..]]</p>
</div></blockquote>
<p>The ‘name[ with several words]’ part is already dealt with by the
cmdhandler at this point, and stored in self.cmdname (we don’t use
it here). The rest of the command is stored in self.args, which can
start with the switch indicator /.</p>
<dlclass="simple">
<dt>Optional variables to aid in parsing, if set:</dt><dd><dlclass="simple">
<dt>self.switch_options - (tuple of valid /switches expected by this</dt><dd><p>command (without the /))</p>
</dd>
<dt>self.rhs_split - Alternate string delimiter or tuple of strings</dt><dd><p>to separate left/right hand sides. tuple form
gives priority split to first string delimiter.</p>
</dd>
</dl>
</dd>
</dl>
<p>This parser breaks self.args into its constituents and stores them in the
following variables:</p>
<blockquote>
<div><p>self.switches = [list of /switches (without the /)]
self.raw = This is the raw argument input, including switches
self.args = This is re-defined to be everything <em>except</em> the switches
self.lhs = Everything to the left of = (lhs:’left-hand side’). If</p>
<blockquote>
<div><p>no = is found, this is identical to self.args.</p>
</div></blockquote>
<dlclass="simple">
<dt>self.rhs: Everything to the right of = (rhs:’right-hand side’).</dt><dd><p>If no ‘=’ is found, this is None.</p>
</dd>
</dl>
<p>self.lhslist - [self.lhs split into a list by comma]
self.rhslist - [list of self.rhs split into a list by comma]
self.arglist = [list of space-separated args (stripped, including ‘=’ if it exists)]</p>
<p>All args and list members are stripped of excess whitespace around the
<codeclass="sig-name descname">get_command_info</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.get_command_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.get_command_info"title="Permalink to this definition">¶</a></dt>
<dd><p>Update of parent class’s get_command_info() for MuxCommand.</p>
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxCommand.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.func"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="simple">
<dt>This is the hook function that actually does all the work. It is called</dt><dd><p>by the cmdhandler right after self.parser() finishes, and so has access
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'command'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'no_prefix': ' ', 'tags': '', 'text': "\n This sets up the basis for a MUX command. The idea\n is that most other Mux-related commands should just\n inherit from this and don't have to implement much\n parsing of their own unless they do something particularly\n advanced.\n\n Note that the class's __doc__ string (this text) is\n used by Evennia to create the automatic help entry for\n the command, so make sure to document consistently here.\n "}</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxCommand.search_index_entry"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.commands.default.muxcommand.</code><codeclass="sig-name descname">MuxAccountCommand</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/commands/default/muxcommand.html#MuxAccountCommand"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">account_caller</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.account_caller"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'command'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'no_prefix': ' ', 'tags': '', 'text': '\n This is an on-Account version of the MuxCommand. Since these commands sit\n on Accounts rather than on Characters/Objects, we need to check\n this in the parser.\n\n Account commands are available also when puppeting a Character, it\'s\n just that they are applied with a lower priority and are always\n available, also when disconnected from a character (i.e. "ooc").\n\n This class makes sure that caller is always an Account object, while\n creating a new property "character" that is set only if a\n character is actually attached to this Account and Session.\n '}</em><aclass="headerlink"href="#evennia.commands.default.muxcommand.MuxAccountCommand.search_index_entry"title="Permalink to this definition">¶</a></dt>