<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="OOB.html"><spanclass="doc">inputcommand</span></a>) from the client. The inputfunc is the last destination for the inputcommand along the <aclass="reference external"href="/Messagepath.html#the-ingoing-message-path">ingoing message path</a>. 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>
<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>
</div>
<divclass="section"id="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 <codeclass="docutils literal notranslate"><spanclass="pre">evennia/server/inputfuncs.py</span></code>.</p>
<divclass="section"id="text">
<h3>text<aclass="headerlink"href="#text"title="Permalink to this headline">¶</a></h3>
<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">Command</span></a>, this inputfunc will do things like nick-replacement and then pass on the input to the central Commandhandler.</p>
</div>
<divclass="section"id="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>
</div>
<divclass="section"id="get-client-options">
<h3>get_client_options<aclass="headerlink"href="#get-client-options"title="Permalink to this headline">¶</a></h3>
<p>This is a convenience wrapper that retrieves the current options by sending “get” to <codeclass="docutils literal notranslate"><spanclass="pre">client_options</span></code> above.</p>
</div>
<divclass="section"id="get-inputfuncs">
<h3>get_inputfuncs<aclass="headerlink"href="#get-inputfuncs"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>
</div>
<divclass="section"id="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>
<p>Retrieves a value from the Character or Account currently controlled by this Session. Takes one argument, This will only accept particular white-listed names, you’ll need to overload the function to expand. By default the following values can be retrieved:</p>
<ulclass="simple">
<li><p>“name” or “key”: The key of the Account or puppeted Character.</p></li>
<li><p>“location”: Name of the current location, or “None”.</p></li>
<li><p>“servername”: Name of the Evennia server connected to.</p></li>
</ul>
</div>
<divclass="section"id="repeat">
<h3>repeat<aclass="headerlink"href="#repeat"title="Permalink to this headline">¶</a></h3>
<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">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>
</div>
<divclass="section"id="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>
</div>
<divclass="section"id="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">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>
</div>
</div>
<divclass="section"id="unmonitor">
<h2>unmonitor<aclass="headerlink"href="#unmonitor"title="Permalink to this headline">¶</a></h2>