<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">asyncify</code><spanclass="sig-paren">(</span><em>function: Callable</em>, <em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.asyncify"title="Permalink to this definition">¶</a></dt>
<dd><p>A command call. An abstract class, sub-bots should create a new call class from this.</p>
<dlclass="method">
<dtid="royalnet.utils.Call.__init__">
<codeclass="descname">__init__</code><spanclass="sig-paren">(</span><em>channel, command: Type[royalnet.utils.command.Command], command_args: List[str] = None, **kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Call.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Create the call.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>channel</strong>– The channel object this call was sent in.</p></li>
<li><p><strong>command</strong>– The command to be called.</p></li>
<li><p><strong>command_args</strong>– The arguments to be passed to the command</p></li>
<li><p><strong>kwargs</strong>– Additional optional keyword arguments that may be passed to the command, possibly specific to the bot.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.utils.Call._session_init">
<codeclass="descname">_session_init</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Call._session_init"title="Permalink to this definition">¶</a></dt>
<dd><p>If the command requires database access, create a <aclass="reference internal"href="database.html#royalnet.database.Alchemy"title="royalnet.database.Alchemy"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.database.Alchemy</span></code></a> session for this call, otherwise, do nothing.</p>
<codeclass="descname">alchemy</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Call.alchemy"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.utils.Call.get_author">
<codeclass="descname">get_author</code><spanclass="sig-paren">(</span><em>error_if_none=False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Call.get_author"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to find the universal identifier of the user that sent the message.
That probably means, the database row identifying the user.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>error_if_none</strong>– Raise a <aclass="reference internal"href="error.html#royalnet.error.UnregisteredError"title="royalnet.error.UnregisteredError"><codeclass="xref py py-exc docutils literal notranslate"><spanclass="pre">royalnet.error.UnregisteredError</span></code></a> if this is True and the call has no author.</p>
<codeclass="descname">interface_name</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Call.interface_name"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.utils.Call.interface_obj">
<codeclass="descname">interface_obj</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Call.interface_obj"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.utils.Call.interface_prefix">
<codeclass="descname">interface_prefix</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Call.interface_prefix"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">net_request</code><spanclass="sig-paren">(</span><em>message</em>, <em>destination: str</em><spanclass="sig-paren">)</span>→ royalnet.network.messages.Reply<aclass="headerlink"href="#royalnet.utils.Call.net_request"title="Permalink to this definition">¶</a></dt>
<dd><p>Send data through a <aclass="reference internal"href="network.html#royalnet.network.RoyalnetLink"title="royalnet.network.RoyalnetLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.RoyalnetLink</span></code></a> and wait for a <aclass="reference internal"href="network.html#royalnet.network.Reply"title="royalnet.network.Reply"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Reply</span></code></a>.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>message</strong>– The data to be sent. Must be <aclass="reference external"href="https://docs.python.org/3.7/library/pickle.html#module-pickle"title="(in Python v3.7)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">pickle</span></code></a>-able.</p></li>
<codeclass="descname">reply</code><spanclass="sig-paren">(</span><em>text: str</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.utils.Call.reply"title="Permalink to this definition">¶</a></dt>
<dd><p>Send a text message to the channel where the call was made.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong>– The text to be sent, possibly formatted in the weird undescribed markup that I’m using.</p>
<codeclass="descname">run</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Call.run"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">session_end</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Call.session_end"title="Permalink to this definition">¶</a></dt>
<dd><p>Close the previously created <aclass="reference internal"href="database.html#royalnet.database.Alchemy"title="royalnet.database.Alchemy"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.database.Alchemy</span></code></a> session for this call (if it was created).</p>
<emclass="property">class </em><codeclass="descclassname">royalnet.utils.</code><codeclass="descname">Command</code><aclass="headerlink"href="#royalnet.utils.Command"title="Permalink to this definition">¶</a></dt>
<dd><p>A generic command, called from any source.</p>
<codeclass="descname">command_description</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Command.command_description"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.utils.Command.command_name">
<codeclass="descname">command_name</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Command.command_name"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.utils.Command.command_syntax">
<codeclass="descname">command_syntax</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.Command.command_syntax"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="classmethod">
<dtid="royalnet.utils.Command.common">
<emclass="property">classmethod </em><codeclass="descname">common</code><spanclass="sig-paren">(</span><em>call: Call</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Command.common"title="Permalink to this definition">¶</a></dt>
<emclass="property">classmethod </em><codeclass="descname">network_handler_dict</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.Command.network_handler_dict"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.utils.Command.network_handlers">
<codeclass="descname">network_handlers</code><emclass="property"> = {}</em><aclass="headerlink"href="#royalnet.utils.Command.network_handlers"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">require_alchemy_tables</code><emclass="property"> = {}</em><aclass="headerlink"href="#royalnet.utils.Command.require_alchemy_tables"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">safeformat</code><spanclass="sig-paren">(</span><em>string: str</em>, <em>**words</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.safeformat"title="Permalink to this definition">¶</a></dt>
<dd><p><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">str.format()</span></code> something, but ignore missing keys instead of raising an error.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong>– The base string to be formatted.</p></li>
<li><p><strong>words</strong>– The words to format the string with.</p></li>
<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">cdj</code><spanclass="sig-paren">(</span><em>class_</em><spanclass="sig-paren">)</span>→ dict<aclass="headerlink"href="#royalnet.utils.cdj"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dict of the class attributes without the <codeclass="docutils literal notranslate"><spanclass="pre">__module__</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">__dict__</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">__weakref__</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">__doc__</span></code> keys, to be used while generating dynamically SQLAlchemy declarative table classes.</p>
<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">sleep_until</code><spanclass="sig-paren">(</span><em>dt: datetime.datetime</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.utils.sleep_until"title="Permalink to this definition">¶</a></dt>
<dd><p>Block the call until the specified datetime.</p>
<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">plusformat</code><spanclass="sig-paren">(</span><em>i: int</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.plusformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert an <aclass="reference external"href="https://docs.python.org/3.7/library/functions.html#int"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">int</span></code></a> to a string, adding a plus if they are greater than 0.</p>
<emclass="property">class </em><codeclass="descclassname">royalnet.utils.</code><codeclass="descname">CommandArgs</code><aclass="headerlink"href="#royalnet.utils.CommandArgs"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">__getitem__</code><spanclass="sig-paren">(</span><em>item</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.CommandArgs.__getitem__"title="Permalink to this definition">¶</a></dt>
<dd><p>Arguments can be accessed with an array notation, such as <codeclass="docutils literal notranslate"><spanclass="pre">args[0]</span></code>.</p>
<codeclass="descname">joined</code><spanclass="sig-paren">(</span><em>*</em>, <em>require_at_least=0</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.CommandArgs.joined"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the arguments as a space-joined string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>require_at_least</strong>– the minimum amount of arguments required, will raise <aclass="reference internal"href="error.html#royalnet.error.InvalidInputError"title="royalnet.error.InvalidInputError"><codeclass="xref py py-exc docutils literal notranslate"><spanclass="pre">royalnet.error.InvalidInputError</span></code></a> if the requirement is not fullfilled.</p>
<codeclass="descname">match</code><spanclass="sig-paren">(</span><em>pattern: Pattern[AnyStr]</em><spanclass="sig-paren">)</span>→ Sequence[AnyStr]<aclass="headerlink"href="#royalnet.utils.CommandArgs.match"title="Permalink to this definition">¶</a></dt>
<dd><p>Match the <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">royalnet.utils.commandargs.joined()</span></code> to a regex pattern.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>pattern</strong>– The regex pattern to be passed to <aclass="reference external"href="https://docs.python.org/3.7/library/re.html#re.match"title="(in Python v3.7)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">re.match()</span></code></a>.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The matched groups, as returned by <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">re.Match.groups()</span></code>.</p>
<codeclass="descname">optional</code><spanclass="sig-paren">(</span><em>index: int</em>, <em>default=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.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 <codeclass="docutils literal notranslate"><spanclass="pre">default</span></code> value.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="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>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Either the argument or the <codeclass="docutils literal notranslate"><spanclass="pre">default</span></code> value, defaulting to <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>.</p>
<emclass="property">class </em><codeclass="descclassname">royalnet.utils.</code><codeclass="descname">NetworkHandler</code><aclass="headerlink"href="#royalnet.utils.NetworkHandler"title="Permalink to this definition">¶</a></dt>
<dd><p>The NetworkHandler functions are called when a specific Message type is received.</p>
<codeclass="descname">message_type</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.NetworkHandler.message_type"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">royalnet.utils.</code><codeclass="descname">safefilename</code><spanclass="sig-paren">(</span><em>string: str</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.safefilename"title="Permalink to this definition">¶</a></dt>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.