<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>royalnet.commands — Royalnet documentation</title> <script type="text/javascript" src="_static/js/modernizr.min.js"></script> <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/language_data.js"></script> <script type="text/javascript" src="_static/js/theme.js"></script> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/rygdocs.css" type="text/css" /> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="royalnet.database" href="database.html" /> <link rel="prev" title="royalnet.bots" href="bots.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="index.html" class="icon icon-home"> Royalnet </a> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="audio.html">royalnet.audio</a></li> <li class="toctree-l1"><a class="reference internal" href="bots.html">royalnet.bots</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">royalnet.commands</a><ul class="simple"> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="database.html">royalnet.database</a></li> <li class="toctree-l1"><a class="reference internal" href="network.html">royalnet.network</a></li> <li class="toctree-l1"><a class="reference internal" href="utils.html">royalnet.utils</a></li> <li class="toctree-l1"><a class="reference internal" href="error.html">royalnet.error</a></li> <li class="toctree-l1"><a class="reference internal" href="web.html">royalnet.web</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">Royalnet</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html">Docs</a> »</li> <li>royalnet.commands</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/commands.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="royalnet-commands"> <h1>royalnet.commands<a class="headerlink" href="#royalnet-commands" title="Permalink to this headline">¶</a></h1> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-royalnet.commands"></span><dl class="class"> <dt id="royalnet.commands.CommandArgs"> <em class="property">class </em><code class="sig-prename descclassname">royalnet.commands.</code><code class="sig-name descname">CommandArgs</code><a class="headerlink" href="#royalnet.commands.CommandArgs" title="Permalink to this definition">¶</a></dt> <dd><p>An interface to access the arguments of a command with ease.</p> <dl class="method"> <dt id="royalnet.commands.CommandArgs.__getitem__"> <code class="sig-name descname">__getitem__</code><span class="sig-paren">(</span><em class="sig-param">item</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.commands.CommandArgs.__getitem__" title="Permalink to this definition">¶</a></dt> <dd><p>Arguments can be accessed with an array notation, such as <code class="docutils literal notranslate"><span class="pre">args[0]</span></code>.</p> <dl class="field-list simple"> <dt class="field-odd">Raises</dt> <dd class="field-odd"><p><a class="reference internal" href="error.html#royalnet.error.InvalidInputError" title="royalnet.error.InvalidInputError"><strong>royalnet.error.InvalidInputError</strong></a> – if the requested argument does not exist.</p> </dd> </dl> </dd></dl> <dl class="attribute"> <dt id="royalnet.commands.CommandArgs.__weakref__"> <code class="sig-name descname">__weakref__</code><a class="headerlink" href="#royalnet.commands.CommandArgs.__weakref__" title="Permalink to this definition">¶</a></dt> <dd><p>list of weak references to the object (if defined)</p> </dd></dl> <dl class="method"> <dt id="royalnet.commands.CommandArgs.joined"> <code class="sig-name descname">joined</code><span class="sig-paren">(</span><em class="sig-param">*</em>, <em class="sig-param">require_at_least=0</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.commands.CommandArgs.joined" title="Permalink to this definition">¶</a></dt> <dd><p>Get the arguments as a space-joined string.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>require_at_least</strong> – the minimum amount of arguments required, will raise <a class="reference internal" href="error.html#royalnet.error.InvalidInputError" title="royalnet.error.InvalidInputError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">royalnet.error.InvalidInputError</span></code></a> if the requirement is not fullfilled.</p> </dd> <dt class="field-even">Raises</dt> <dd class="field-even"><p><a class="reference internal" href="error.html#royalnet.error.InvalidInputError" title="royalnet.error.InvalidInputError"><strong>royalnet.error.InvalidInputError</strong></a> – if there are less than <code class="docutils literal notranslate"><span class="pre">require_at_least</span></code> arguments.</p> </dd> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>The space-joined string.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.commands.CommandArgs.match"> <code class="sig-name descname">match</code><span class="sig-paren">(</span><em class="sig-param">pattern: Union[str, Pattern]</em><span class="sig-paren">)</span> → Sequence[AnyStr]<a class="headerlink" href="#royalnet.commands.CommandArgs.match" title="Permalink to this definition">¶</a></dt> <dd><p>Match the <code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.utils.commandargs.joined()</span></code> to a regex pattern.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>pattern</strong> – The regex pattern to be passed to <a class="reference external" href="https://docs.python.org/3.7/library/re.html#re.match" title="(in Python v3.7)"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.match()</span></code></a>.</p> </dd> <dt class="field-even">Raises</dt> <dd class="field-even"><p><a class="reference internal" href="error.html#royalnet.error.InvalidInputError" title="royalnet.error.InvalidInputError"><strong>royalnet.error.InvalidInputError</strong></a> – if the pattern doesn’t match.</p> </dd> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>The matched groups, as returned by <code class="xref py py-func docutils literal notranslate"><span class="pre">re.Match.groups()</span></code>.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.commands.CommandArgs.optional"> <code class="sig-name descname">optional</code><span class="sig-paren">(</span><em class="sig-param">index: int</em>, <em class="sig-param">default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.commands.CommandArgs.optional" title="Permalink to this definition">¶</a></dt> <dd><p>Get the argument at a specific index, but don’t raise an error if nothing is found, instead returning the <code class="docutils literal notranslate"><span class="pre">default</span></code> value.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>index</strong> – The index of the argument you want to retrieve.</p></li> <li><p><strong>default</strong> – The value returned if the argument is missing.</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>Either the argument or the <code class="docutils literal notranslate"><span class="pre">default</span></code> value, defaulting to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd> </dl> </dd></dl> </dd></dl> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="database.html" class="btn btn-neutral float-right" title="royalnet.database" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="bots.html" class="btn btn-neutral float-left" title="royalnet.bots" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2019, Stefano Pigozzi </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>