<h1>Inputfuncs<aclass="headerlink"href="#inputfuncs"title="Permalink to this headline">¶</a></h1>
<p>An <em>inputfunc</em> is an Evennia function that handles a particular input (an <aclass="reference internal"href="../Concepts/OOB.html"><spanclass="doc std std-doc">inputcommand</span></a>) from
the client. The inputfunc is the last destination for the inputcommand along the <spanclass="xref myst">ingoing message
path</span>. The inputcommand always has the form <codeclass="docutils literal notranslate"><spanclass="pre">(commandname,</span><spanclass="pre">(args),</span><spanclass="pre">{kwargs})</span></code> and Evennia will use this to try to find and call an inputfunc on the form</p>
<spanclass="c1"># cmdname is the name of the mismatched inputcommand</span>
</pre></div>
</div>
<sectionid="adding-your-own-inputfuncs">
<h2>Adding your own inputfuncs<aclass="headerlink"href="#adding-your-own-inputfuncs"title="Permalink to this headline">¶</a></h2>
<p>This is simple. Add a function on the above form to <codeclass="docutils literal notranslate"><spanclass="pre">mygame/server/conf/inputfuncs.py</span></code>. Your
function must be in the global, outermost scope of that module and not start with an underscore
(<codeclass="docutils literal notranslate"><spanclass="pre">_</span></code>) to be recognized as an inputfunc. Reload the server. That’s it. To overload a default
inputfunc (see below), just add a function with the same name.</p>
<p>The modules Evennia looks into for inputfuncs are defined in the list <codeclass="docutils literal notranslate"><spanclass="pre">settings.INPUT_FUNC_MODULES</span></code>.
This list will be imported from left to right and later imported functions will replace earlier
ones.</p>
</section>
<sectionid="default-inputfuncs">
<h2>Default inputfuncs<aclass="headerlink"href="#default-inputfuncs"title="Permalink to this headline">¶</a></h2>
<p>Evennia defines a few default inputfuncs to handle the common cases. These are defined in
<li><p>Output: Depends on Command triggered</p></li>
</ul>
<p>This is the most common of inputcommands, and the only one supported by every traditional mud. The
argument is usually what the user sent from their command line. Since all text input from the user
like this is considered a <aclass="reference internal"href="Commands.html"><spanclass="doc std std-doc">Command</span></a>, this inputfunc will do things like nick-replacement
and then pass on the input to the central Commandhandler.</p>
</section>
<sectionid="echo">
<h3>echo<aclass="headerlink"href="#echo"title="Permalink to this headline">¶</a></h3>
<p>This is a direct command for setting protocol options. These are settable with the <codeclass="docutils literal notranslate"><spanclass="pre">@option</span></code>
command, but this offers a client-side way to set them. Not all connection protocols makes use of
all flags, but here are the possible keywords:</p>
<ulclass="simple">
<li><p>get (bool): If this is true, ignore all other kwargs and immediately return the current settings
as an outputcommand <codeclass="docutils literal notranslate"><spanclass="pre">("client_options",</span><spanclass="pre">(),</span><spanclass="pre">{key=value,</span><spanclass="pre">...})</span></code>-</p></li>
<li><p>client (str): A client identifier, like “mushclient”.</p></li>
<li><p>version (str): A client version</p></li>
<li><p>ansi (bool): Supports ansi colors</p></li>
<li><p>xterm256 (bool): Supports xterm256 colors or not</p></li>
<li><p>mxp (bool): Supports MXP or not</p></li>
<li><p>utf-8 (bool): Supports UTF-8 or not</p></li>
<li><p>nomarkup (bool): Strip all text tags</p></li>
<li><p>raw (bool): Leave text tags unparsed</p></li>
</ul>
<blockquote>
<div><p>Note that there are two GMCP aliases to this inputfunc - <codeclass="docutils literal notranslate"><spanclass="pre">hello</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">supports_set</span></code>, which means
it will be accessed via the GMCP <codeclass="docutils literal notranslate"><spanclass="pre">Hello</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">Supports.Set</span></code> instructions assumed by some clients.</p>
</div></blockquote>
</section>
<sectionid="get-client-options">
<h3>get_client_options<aclass="headerlink"href="#get-client-options"title="Permalink to this headline">¶</a></h3>
<p>Returns an outputcommand on the form <codeclass="docutils literal notranslate"><spanclass="pre">("get_inputfuncs",</span><spanclass="pre">(),</span><spanclass="pre">{funcname:docstring,</span><spanclass="pre">...})</span></code> - a list of
all the available inputfunctions along with their docstrings.</p>
</section>
<sectionid="login">
<h3>login<aclass="headerlink"href="#login"title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><p>Note: this is currently experimental and not very well tested.</p>
<li><p>Output: Depends on the repeated function. Will return <codeclass="docutils literal notranslate"><spanclass="pre">("text",</span><spanclass="pre">(repeatlist),{}</span></code> with a list of
accepted names if given an unfamiliar callback name.</p></li>
</ul>
<p>This will tell evennia to repeatedly call a named function at a given interval. Behind the scenes
this will set up a <aclass="reference internal"href="TickerHandler.html"><spanclass="doc std std-doc">Ticker</span></a>. Only previously acceptable functions are possible to
repeat-call in this way, you’ll need to overload this inputfunc to add the ones you want to offer.
By default only two example functions are allowed, “test1” and “test2”, which will just echo a text
back at the given interval. Stop the repeat by sending <codeclass="docutils literal notranslate"><spanclass="pre">"stop":</span><spanclass="pre">True</span></code> (note that you must include
both the callback name and interval for Evennia to know what to stop).</p>
</section>
<sectionid="unrepeat">
<h3>unrepeat<aclass="headerlink"href="#unrepeat"title="Permalink to this headline">¶</a></h3>
<p>This is a convenience wrapper for sending “stop” to the <codeclass="docutils literal notranslate"><spanclass="pre">repeat</span></code> inputfunc.</p>
</section>
<sectionid="monitor">
<h3>monitor<aclass="headerlink"href="#monitor"title="Permalink to this headline">¶</a></h3>
<li><p>Output (on change): <codeclass="docutils literal notranslate"><spanclass="pre">("monitor",</span><spanclass="pre">(),</span><spanclass="pre">{"name":name,</span><spanclass="pre">"value":value})</span></code></p></li>
</ul>
<p>This sets up on-object monitoring of Attributes or database fields. Whenever the field or Attribute
changes in any way, the outputcommand will be sent. This is using the
<aclass="reference internal"href="MonitorHandler.html"><spanclass="doc std std-doc">MonitorHandler</span></a> behind the scenes. Pass the “stop” key to stop monitoring. Note
that you must supply the name also when stopping to let the system know which monitor should be
cancelled.</p>
<p>Only fields/attributes in a whitelist are allowed to be used, you have to overload this function to
add more. By default the following fields/attributes can be monitored:</p>
<ulclass="simple">
<li><p>“name”: The current character name</p></li>
<li><p>“location”: The current location</p></li>
<li><p>“desc”: The description Argument</p></li>
</ul>
</section>
</section>
<sectionid="unmonitor">
<h2>unmonitor<aclass="headerlink"href="#unmonitor"title="Permalink to this headline">¶</a></h2>