mirror of
https://github.com/RYGhub/royalnet.git
synced 2025-03-21 16:03:25 +00:00
Update docs
This commit is contained in:
parent
0f85279561
commit
61b3ed80b0
43 changed files with 596 additions and 92 deletions
docs
doctrees
audio.doctreebots.doctreecommands.doctreedatabase.doctreeenvironment.pickleerror.doctreeindex.doctreenetwork.doctreeutils.doctree
html
docs_source
royalnet
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
docs/doctrees/error.doctree
Normal file
BIN
docs/doctrees/error.doctree
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11
docs/html/_sources/error.rst.txt
Normal file
11
docs/html/_sources/error.rst.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
royalnet.error
|
||||
====================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
.. automodule:: royalnet.error
|
||||
:members:
|
||||
:private-members:
|
||||
:undoc-members:
|
|
@ -10,6 +10,7 @@ royalnet
|
|||
database
|
||||
network
|
||||
utils
|
||||
error
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -157,7 +158,8 @@
|
|||
<h1>royalnet.audio<a class="headerlink" href="#royalnet-audio" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.audio"></span><dl class="class">
|
||||
<span class="target" id="module-royalnet.audio"></span><p>Video and audio downloading related classes, mainly used for Discord voice bots.</p>
|
||||
<dl class="class">
|
||||
<dt id="royalnet.audio.PlayMode">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">PlayMode</code><a class="headerlink" href="#royalnet.audio.PlayMode" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The base class for a PlayMode, such as <a class="reference internal" href="#royalnet.audio.Playlist" title="royalnet.audio.Playlist"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.Playlist</span></code></a>. Inherit from this class if you want to create a custom PlayMode.</p>
|
||||
|
@ -449,7 +451,7 @@ The name of the downloaded and PCM-converted audio file.</p>
|
|||
</dl>
|
||||
<div class="admonition warning">
|
||||
<p class="admonition-title">Warning</p>
|
||||
<p>It’s going to be deleted as soon as the <code class="xref py py-func docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMFile.__init__()</span></code> function has completed, so it’s probably not going to be very useful…</p>
|
||||
<p>It’s going to be deleted as soon as the <code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMFile.__init__()</span></code> function has completed, so it’s probably not going to be very useful…</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -157,7 +158,8 @@
|
|||
<h1>royalnet.bots<a class="headerlink" href="#royalnet-bots" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.bots"></span><dl class="class">
|
||||
<span class="target" id="module-royalnet.bots"></span><p>Various bot interfaces, and a generic class to create new ones.</p>
|
||||
<dl class="class">
|
||||
<dt id="royalnet.bots.TelegramBot">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">TelegramBot</code><span class="sig-paren">(</span><em>*</em>, <em>telegram_config: royalnet.bots.telegram.TelegramConfig</em>, <em>royalnet_config: Optional[royalnet.network.royalnetconfig.RoyalnetConfig] = None</em>, <em>database_config: Optional[royalnet.database.databaseconfig.DatabaseConfig] = None</em>, <em>command_prefix: str = '/'</em>, <em>commands: List[Type[royalnet.utils.command.Command]] = None</em>, <em>missing_command: Type[royalnet.utils.command.Command] = <class 'royalnet.commands.null.NullCommand'></em>, <em>error_command: Type[royalnet.utils.command.Command] = <class 'royalnet.commands.null.NullCommand'></em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>A bot that connects to <a class="reference external" href="https://telegram.org/">Telegram</a>.</p>
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -157,7 +158,8 @@
|
|||
<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">
|
||||
<span class="target" id="module-royalnet.commands"></span><p>Commands that can be used in bots. These probably won’t suit your needs, as they are tailored for the bots of the <a class="reference external" href="https://ryg.steffo.eu">Royal Games</a> gaming community, but you can check them for reference.</p>
|
||||
<dl class="class">
|
||||
<dt id="royalnet.commands.NullCommand">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.commands.</code><code class="descname">NullCommand</code><a class="headerlink" href="#royalnet.commands.NullCommand" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
</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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -158,7 +159,8 @@
|
|||
<h1>royalnet.database<a class="headerlink" href="#royalnet-database" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.database"></span><dl class="class">
|
||||
<span class="target" id="module-royalnet.database"></span><p>Relational database classes and methods.</p>
|
||||
<dl class="class">
|
||||
<dt id="royalnet.database.Alchemy">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.database.</code><code class="descname">Alchemy</code><span class="sig-paren">(</span><em>database_uri: str, tables: Set[T]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.database.Alchemy" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>A wrapper around SQLAlchemy declarative that allows to use multiple databases at once while maintaining a single table-class for both of them.</p>
|
||||
|
@ -259,7 +261,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Telegram.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b84b0; no key></em><a class="headerlink" href="#royalnet.database.tables.Telegram.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x717a078; no key></em><a class="headerlink" href="#royalnet.database.tables.Telegram.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -289,7 +291,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Diario.creator">
|
||||
<code class="descname">creator</code><em class="property"> = <RelationshipProperty at 0x73b84f8; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.creator" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">creator</code><em class="property"> = <RelationshipProperty at 0x71841e0; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.creator" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -314,7 +316,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Diario.quoted_account">
|
||||
<code class="descname">quoted_account</code><em class="property"> = <RelationshipProperty at 0x73b8b28; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.quoted_account" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">quoted_account</code><em class="property"> = <RelationshipProperty at 0x7184618; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.quoted_account" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -349,7 +351,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Alias.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8198; no key></em><a class="headerlink" href="#royalnet.database.tables.Alias.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7184810; no key></em><a class="headerlink" href="#royalnet.database.tables.Alias.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -364,7 +366,7 @@
|
|||
<em class="property">class </em><code class="descclassname">royalnet.database.tables.</code><code class="descname">ActiveKvGroup</code><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><dl class="attribute">
|
||||
<dt id="royalnet.database.tables.ActiveKvGroup.group">
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x73b80c0; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.group" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x7174ae0; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.group" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -374,7 +376,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.ActiveKvGroup.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8df8; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x70b5a98; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -389,7 +391,7 @@
|
|||
<em class="property">class </em><code class="descclassname">royalnet.database.tables.</code><code class="descname">Keyvalue</code><a class="headerlink" href="#royalnet.database.tables.Keyvalue" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Keyvalue.group">
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x73b8930; no key></em><a class="headerlink" href="#royalnet.database.tables.Keyvalue.group" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x71848a0; no key></em><a class="headerlink" href="#royalnet.database.tables.Keyvalue.group" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -444,7 +446,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Discord.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8b28; no key></em><a class="headerlink" href="#royalnet.database.tables.Discord.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7184810; no key></em><a class="headerlink" href="#royalnet.database.tables.Discord.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
|
258
docs/html/error.html
Normal file
258
docs/html/error.html
Normal file
|
@ -0,0 +1,258 @@
|
|||
|
||||
|
||||
<!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.error — 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="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="prev" title="royalnet.utils" href="utils.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"><a class="reference internal" href="commands.html">royalnet.commands</a></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 current"><a class="current reference internal" href="#">royalnet.error</a><ul class="simple">
|
||||
</ul>
|
||||
</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.error</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="_sources/error.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-error">
|
||||
<h1>royalnet.error<a class="headerlink" href="#royalnet-error" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.error"></span><dl class="exception">
|
||||
<dt id="royalnet.error.ExternalError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">ExternalError</code><a class="headerlink" href="#royalnet.error.ExternalError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Something went wrong in a non-Royalnet component and the command execution cannot be completed.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.InvalidConfigError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">InvalidConfigError</code><a class="headerlink" href="#royalnet.error.InvalidConfigError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The bot has not been configured correctly, therefore the command can not function.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.InvalidInputError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">InvalidInputError</code><a class="headerlink" href="#royalnet.error.InvalidInputError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The command has received invalid input and cannot complete.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.NoneFoundError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">NoneFoundError</code><a class="headerlink" href="#royalnet.error.NoneFoundError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The element that was being looked for was not found.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.RoyalnetError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">RoyalnetError</code><span class="sig-paren">(</span><em>exc: Exception</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.error.RoyalnetError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>An error was raised while handling the Royalnet request.
|
||||
This exception contains the exception that was raised during the handling.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.TooManyFoundError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">TooManyFoundError</code><a class="headerlink" href="#royalnet.error.TooManyFoundError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Multiple elements matching the request were found, and only one was expected.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.UnregisteredError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">UnregisteredError</code><a class="headerlink" href="#royalnet.error.UnregisteredError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The command required a registered user, and the user was not registered.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="exception">
|
||||
<dt id="royalnet.error.UnsupportedError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.error.</code><code class="descname">UnsupportedError</code><a class="headerlink" href="#royalnet.error.UnsupportedError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The command is not supported for the specified interface.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
|
||||
<a href="utils.html" class="btn btn-neutral float-left" title="royalnet.utils" 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>
|
|
@ -86,6 +86,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -157,6 +158,7 @@
|
|||
| <a href="#B"><strong>B</strong></a>
|
||||
| <a href="#C"><strong>C</strong></a>
|
||||
| <a href="#D"><strong>D</strong></a>
|
||||
| <a href="#E"><strong>E</strong></a>
|
||||
| <a href="#F"><strong>F</strong></a>
|
||||
| <a href="#G"><strong>G</strong></a>
|
||||
| <a href="#I"><strong>I</strong></a>
|
||||
|
@ -179,6 +181,8 @@
|
|||
<h2 id="_">_</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="utils.html#royalnet.utils.CommandArgs.__getitem__">__getitem__() (royalnet.utils.CommandArgs method)</a>
|
||||
</li>
|
||||
<li><a href="audio.html#royalnet.audio.Playlist.__init__">__init__() (royalnet.audio.Playlist method)</a>
|
||||
|
||||
<ul>
|
||||
|
@ -195,6 +199,8 @@
|
|||
<li><a href="network.html#royalnet.network.Package.__init__">(royalnet.network.Package method)</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.RequestError.__init__">(royalnet.network.RequestError method)</a>
|
||||
</li>
|
||||
<li><a href="utils.html#royalnet.utils.Call.__init__">(royalnet.utils.Call method)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="bots.html#royalnet.bots.DiscordBot._bot_factory">_bot_factory() (royalnet.bots.DiscordBot method)</a>
|
||||
|
@ -236,6 +242,8 @@
|
|||
<li><a href="bots.html#royalnet.bots.DiscordBot._init_voice">_init_voice() (royalnet.bots.DiscordBot method)</a>
|
||||
</li>
|
||||
<li><a href="bots.html#royalnet.bots.GenericBot._network_handler">_network_handler() (royalnet.bots.GenericBot method)</a>
|
||||
</li>
|
||||
<li><a href="utils.html#royalnet.utils.Call._session_init">_session_init() (royalnet.utils.Call method)</a>
|
||||
</li>
|
||||
<li><a href="audio.html#royalnet.audio.YtdlFile._stop_download">_stop_download() (royalnet.audio.YtdlFile method)</a>
|
||||
</li>
|
||||
|
@ -388,6 +396,14 @@
|
|||
</ul></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="E">E</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="error.html#royalnet.error.ExternalError">ExternalError</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="F">F</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
|
@ -445,13 +461,17 @@
|
|||
<li><a href="utils.html#royalnet.utils.Call.interface_name">(royalnet.utils.Call attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="utils.html#royalnet.utils.Call.interface_obj">interface_obj (royalnet.utils.Call attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="utils.html#royalnet.utils.Call.interface_prefix">interface_prefix (royalnet.utils.Call attribute)</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.InvalidConfigError">InvalidConfigError</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.InvalidDestinationEM">InvalidDestinationEM (class in royalnet.network)</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.InvalidInputError">InvalidInputError</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.InvalidPackageEM">InvalidPackageEM (class in royalnet.network)</a>
|
||||
</li>
|
||||
|
@ -531,11 +551,13 @@
|
|||
</li>
|
||||
<li><a href="network.html#royalnet.network.NetworkError">NetworkError</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="utils.html#royalnet.utils.NetworkHandler">NetworkHandler (class in royalnet.utils)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="audio.html#royalnet.audio.PlayMode.next">next() (royalnet.audio.PlayMode method)</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.NoneFoundError">NoneFoundError</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.NotConnectedError">NotConnectedError</a>
|
||||
</li>
|
||||
|
@ -670,12 +692,16 @@
|
|||
<li><a href="database.html#module-royalnet.database">royalnet.database (module)</a>
|
||||
</li>
|
||||
<li><a href="database.html#module-royalnet.database.tables">royalnet.database.tables (module)</a>
|
||||
</li>
|
||||
<li><a href="error.html#module-royalnet.error">royalnet.error (module)</a>
|
||||
</li>
|
||||
<li><a href="network.html#module-royalnet.network">royalnet.network (module)</a>
|
||||
</li>
|
||||
<li><a href="utils.html#module-royalnet.utils">royalnet.utils (module)</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.RoyalnetConfig">RoyalnetConfig (class in royalnet.network)</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.RoyalnetError">RoyalnetError</a>
|
||||
</li>
|
||||
<li><a href="network.html#royalnet.network.RoyalnetLink">RoyalnetLink (class in royalnet.network)</a>
|
||||
</li>
|
||||
|
@ -721,8 +747,6 @@
|
|||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="utils.html#royalnet.utils.Call.session_init">session_init() (royalnet.utils.Call method)</a>
|
||||
</li>
|
||||
<li><a href="commands.html#royalnet.commands.ShipCommand">ShipCommand (class in royalnet.commands)</a>
|
||||
</li>
|
||||
<li><a href="commands.html#royalnet.commands.SkipCommand">SkipCommand (class in royalnet.commands)</a>
|
||||
|
@ -758,6 +782,8 @@
|
|||
<li><a href="database.html#royalnet.database.tables.Telegram.tg_id">tg_id (royalnet.database.tables.Telegram attribute)</a>
|
||||
</li>
|
||||
<li><a href="database.html#royalnet.database.tables.Diario.timestamp">timestamp (royalnet.database.tables.Diario attribute)</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.TooManyFoundError">TooManyFoundError</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
|
@ -767,10 +793,14 @@
|
|||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="database.html#royalnet.database.tables.Royal.uid">uid (royalnet.database.tables.Royal attribute)</a>
|
||||
</li>
|
||||
<li><a href="bots.html#royalnet.bots.DiscordBot.update_activity_with_source_title">update_activity_with_source_title() (royalnet.bots.DiscordBot method)</a>
|
||||
<li><a href="error.html#royalnet.error.UnregisteredError">UnregisteredError</a>
|
||||
</li>
|
||||
<li><a href="error.html#royalnet.error.UnsupportedError">UnsupportedError</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="bots.html#royalnet.bots.DiscordBot.update_activity_with_source_title">update_activity_with_source_title() (royalnet.bots.DiscordBot method)</a>
|
||||
</li>
|
||||
<li><a href="database.html#royalnet.database.tables.Discord.username">username (royalnet.database.tables.Discord attribute)</a>
|
||||
|
||||
<ul>
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -173,6 +174,9 @@
|
|||
<li class="toctree-l1"><a class="reference internal" href="utils.html">royalnet.utils</a><ul class="simple">
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="error.html">royalnet.error</a><ul class="simple">
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
</ul>
|
||||
</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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -157,7 +158,8 @@
|
|||
<h1>royalnet.network<a class="headerlink" href="#royalnet-network" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.network"></span><dl class="class">
|
||||
<span class="target" id="module-royalnet.network"></span><p>Royalnet realated classes.</p>
|
||||
<dl class="class">
|
||||
<dt id="royalnet.network.Message">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">Message</code><a class="headerlink" href="#royalnet.network.Message" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>A message sent through the Royalnet.</p>
|
||||
|
@ -365,7 +367,7 @@
|
|||
<dt id="royalnet.network.RequestError.raise_on_error">
|
||||
<code class="descname">raise_on_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.network.RequestError.raise_on_error" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>If the reply is an error, raise an error, otherwise, do nothing.</p>
|
||||
<p>:raises Always raises a <code class="xref py py-exc docutils literal notranslate"><span class="pre">royalnet.error.RoyalnetError</span></code>, containing the exception that caused the error.:</p>
|
||||
<p>:raises Always raises a <a class="reference internal" href="error.html#royalnet.error.RoyalnetError" title="royalnet.error.RoyalnetError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">royalnet.error.RoyalnetError</span></code></a>, containing the exception that caused the error.:</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
|
Binary file not shown.
|
@ -88,6 +88,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -190,6 +191,11 @@
|
|||
<td>   
|
||||
<a href="database.html#module-royalnet.database.tables"><code class="xref">royalnet.database.tables</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>   
|
||||
<a href="error.html#module-royalnet.error"><code class="xref">royalnet.error</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>   
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -35,6 +35,7 @@
|
|||
<link rel="stylesheet" href="_static/pygments.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.error" href="error.html" />
|
||||
<link rel="prev" title="royalnet.network" href="network.html" />
|
||||
</head>
|
||||
|
||||
|
@ -88,6 +89,7 @@
|
|||
<li class="toctree-l1 current"><a class="current reference internal" href="#">royalnet.utils</a><ul class="simple">
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="error.html">royalnet.error</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -156,15 +158,43 @@
|
|||
<h1>royalnet.utils<a class="headerlink" href="#royalnet-utils" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
</div>
|
||||
<span class="target" id="module-royalnet.utils"></span><dl class="function">
|
||||
<span class="target" id="module-royalnet.utils"></span><p>Miscellaneous useful functions and classes.</p>
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.asyncify">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">asyncify</code><span class="sig-paren">(</span><em>function: Callable</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.asyncify" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Convert a function into a coroutine.</p>
|
||||
<div class="admonition warning">
|
||||
<p class="admonition-title">Warning</p>
|
||||
<p>The coroutine cannot be cancelled, and any attempts to do so will result in unexpected outputs.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="royalnet.utils.Call">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.utils.</code><code class="descname">Call</code><span class="sig-paren">(</span><em>channel, command: Type[royalnet.utils.command.Command], command_args: List[str] = None, **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>A command call. Still an abstract class, subbots should create a new call from this.</p>
|
||||
<dd><p>A command call. An abstract class, sub-bots should create a new call class from this.</p>
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.__init__">
|
||||
<code class="descname">__init__</code><span class="sig-paren">(</span><em>channel, command: Type[royalnet.utils.command.Command], command_args: List[str] = None, **kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.__init__" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create the call.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="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>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call._session_init">
|
||||
<code class="descname">_session_init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call._session_init" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>If the command requires database access, create a <a class="reference internal" href="database.html#royalnet.database.Alchemy" title="royalnet.database.Alchemy"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.Alchemy</span></code></a> session for this call, otherwise, do nothing.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.utils.Call.alchemy">
|
||||
<code class="descname">alchemy</code><em class="property"> = NotImplemented</em><a class="headerlink" href="#royalnet.utils.Call.alchemy" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -174,8 +204,15 @@
|
|||
<dt id="royalnet.utils.Call.get_author">
|
||||
<code class="descname">get_author</code><span class="sig-paren">(</span><em>error_if_none=False</em><span class="sig-paren">)</span><a class="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.
|
||||
Raise a UnregisteredError if error_if_none is set to True and no author is found.</p>
|
||||
That probably means, the database row identifying the user.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>error_if_none</strong> – Raise a <a class="reference internal" href="error.html#royalnet.error.UnregisteredError" title="royalnet.error.UnregisteredError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">royalnet.error.UnregisteredError</span></code></a> if this is True and the call has no author.</p>
|
||||
</dd>
|
||||
<dt class="field-even">Raises</dt>
|
||||
<dd class="field-even"><p><a class="reference internal" href="error.html#royalnet.error.UnregisteredError" title="royalnet.error.UnregisteredError"><strong>royalnet.error.UnregisteredError</strong></a> – </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -195,31 +232,40 @@ Raise a UnregisteredError if error_if_none is set to True and no author is found
|
|||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.net_request">
|
||||
<code class="descname">net_request</code><span class="sig-paren">(</span><em>message: royalnet.network.messages.Message</em>, <em>destination: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.net_request" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Send data to the rest of the Royalnet, and optionally wait for an answer.
|
||||
The data must be pickleable.</p>
|
||||
<code class="descname">net_request</code><span class="sig-paren">(</span><em>message</em>, <em>destination: str</em><span class="sig-paren">)</span> → royalnet.network.messages.Reply<a class="headerlink" href="#royalnet.utils.Call.net_request" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Send data through a <a class="reference internal" href="network.html#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a> and wait for a <a class="reference internal" href="network.html#royalnet.network.Reply" title="royalnet.network.Reply"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Reply</span></code></a>.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>message</strong> – The data to be sent. Must be <a class="reference external" href="https://docs.python.org/3.7/library/pickle.html#module-pickle" title="(in Python v3.7)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a>-able.</p></li>
|
||||
<li><p><strong>destination</strong> – </p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.reply">
|
||||
<code class="descname">reply</code><span class="sig-paren">(</span><em>text: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.reply" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Send a text message to the channel the call was made.</p>
|
||||
<code class="descname">reply</code><span class="sig-paren">(</span><em>text: str</em><span class="sig-paren">)</span> → None<a class="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>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>text</strong> – The text to be sent, possibly formatted in the weird undescribed markup that I’m using.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.run">
|
||||
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Execute the called command, and return the command result.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.session_end">
|
||||
<code class="descname">session_end</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.session_end" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.Call.session_init">
|
||||
<code class="descname">session_init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.Call.session_init" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Close the previously created <a class="reference internal" href="database.html#royalnet.database.Alchemy" title="royalnet.database.Alchemy"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.Alchemy</span></code></a> session for this call (if it was created).</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
|
@ -266,13 +312,25 @@ The data must be pickleable.</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.safeformat">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">safeformat</code><span class="sig-paren">(</span><em>string: str</em>, <em>ignore_escaping: bool = False</em>, <em>**words</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.utils.safeformat" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">safeformat</code><span class="sig-paren">(</span><em>string: str</em>, <em>**words</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.utils.safeformat" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p><code class="xref py py-func docutils literal notranslate"><span class="pre">str.format()</span></code> something, but ignore missing keys instead of raising an error.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><ul class="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>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>The formatted string.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.cdj">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">cdj</code><span class="sig-paren">(</span><em>class_</em><span class="sig-paren">)</span> → dict<a class="headerlink" href="#royalnet.utils.cdj" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Return the cleaned class attributes in a dict.</p>
|
||||
<dd><p>Return a dict of the class attributes without the <code class="docutils literal notranslate"><span class="pre">__module__</span></code>, <code class="docutils literal notranslate"><span class="pre">__dict__</span></code>, <code class="docutils literal notranslate"><span class="pre">__weakref__</span></code> and <code class="docutils literal notranslate"><span class="pre">__doc__</span></code> keys, to be used while generating dynamically SQLAlchemy declarative table classes.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
|
@ -291,10 +349,10 @@ The data must be pickleable.</p>
|
|||
<dd><p>Convert an <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> to a string, adding a plus if they are greater than 0.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>i</strong> – the <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> to convert</p>
|
||||
<dd class="field-odd"><p><strong>i</strong> – the <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> to convert.</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>The resulting <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#str" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a></p>
|
||||
<dd class="field-even"><p>The resulting <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#str" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
@ -302,21 +360,65 @@ The data must be pickleable.</p>
|
|||
<dl class="class">
|
||||
<dt id="royalnet.utils.CommandArgs">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.utils.</code><code class="descname">CommandArgs</code><a class="headerlink" href="#royalnet.utils.CommandArgs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The arguments of a command. Raises <code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidInputError</span></code> if the requested argument does not exist.</p>
|
||||
<dd><p>The arguments of a command.</p>
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.CommandArgs.__getitem__">
|
||||
<code class="descname">__getitem__</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span><a class="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 <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>InvalidInputError</strong></a> – </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.CommandArgs.joined">
|
||||
<code class="descname">joined</code><span class="sig-paren">(</span><em>*</em>, <em>require_at_least=0</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.CommandArgs.joined" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<code class="descname">joined</code><span class="sig-paren">(</span><em>*</em>, <em>require_at_least=0</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.utils.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> – </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.utils.CommandArgs.match">
|
||||
<code class="descname">match</code><span class="sig-paren">(</span><em>pattern: Pattern[AnyStr]</em><span class="sig-paren">)</span> → Sequence[AnyStr]<a class="headerlink" href="#royalnet.utils.CommandArgs.match" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<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">Returns</dt>
|
||||
<dd class="field-even"><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.utils.CommandArgs.optional">
|
||||
<code class="descname">optional</code><span class="sig-paren">(</span><em>index: int</em>, <em>default=None</em><span class="sig-paren">)</span> → Optional<a class="headerlink" href="#royalnet.utils.CommandArgs.optional" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<code class="descname">optional</code><span class="sig-paren">(</span><em>index: int</em>, <em>default=None</em><span class="sig-paren">)</span><a class="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 <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>
|
||||
|
||||
|
@ -333,7 +435,7 @@ The data must be pickleable.</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.safefilename">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">safefilename</code><span class="sig-paren">(</span><em>string: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.safefilename" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">safefilename</code><span class="sig-paren">(</span><em>string: str</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.utils.safefilename" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Ensure a string can be used as a filename by replacing all non-word characters with underscores.</p>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -347,6 +449,8 @@ The data must be pickleable.</p>
|
|||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="error.html" class="btn btn-neutral float-right" title="royalnet.error" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="network.html" class="btn btn-neutral float-left" title="royalnet.network" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
|
|
|
@ -29,13 +29,14 @@ author = 'Stefano Pigozzi'
|
|||
# ones.
|
||||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.intersphinx"]
|
||||
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.7', None),
|
||||
'discord': ('https://discordpy.readthedocs.io/en/latest/', None),
|
||||
"telegram": ("https://python-telegram-bot.readthedocs.io/en/stable/", None)}
|
||||
intersphinx_mapping = {"python": ("https://docs.python.org/3.7", None),
|
||||
"discord": ("https://discordpy.readthedocs.io/en/latest/", None),
|
||||
"telegram": ("https://python-telegram-bot.readthedocs.io/en/stable/", None),
|
||||
"sqlalchemy": ("https://docs.sqlalchemy.org/en/13/", None)}
|
||||
|
||||
|
||||
def skip(app, what, name, obj, would_skip, options):
|
||||
if name == "__init__":
|
||||
def skip(app, what, name: str, obj, would_skip, options):
|
||||
if name == "__init__" or name == "__getitem__" or name == "__getattr__":
|
||||
return not bool(obj.__doc__)
|
||||
return would_skip
|
||||
|
||||
|
|
11
docs_source/error.rst
Normal file
11
docs_source/error.rst
Normal file
|
@ -0,0 +1,11 @@
|
|||
royalnet.error
|
||||
====================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
.. automodule:: royalnet.error
|
||||
:members:
|
||||
:private-members:
|
||||
:undoc-members:
|
|
@ -10,6 +10,7 @@ royalnet
|
|||
database
|
||||
network
|
||||
utils
|
||||
error
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"""Video and audio downloading related classes, mainly used for Discord voice bots."""
|
||||
|
||||
from .playmodes import PlayMode, Playlist, Pool
|
||||
from .youtubedl import YtdlFile, YtdlInfo
|
||||
from .royalpcmfile import RoyalPCMFile
|
||||
|
|
|
@ -80,7 +80,7 @@ class RoyalPCMFile(YtdlFile):
|
|||
The name of the downloaded video file, as a :py:class:`str`.
|
||||
|
||||
Warning:
|
||||
It's going to be deleted as soon as the :py:func:`discord.audio.RoyalPCMFile.__init__` function has completed, so it's probably not going to be very useful...
|
||||
It's going to be deleted as soon as the :py:func:`royalnet.audio.RoyalPCMFile.__init__` function has completed, so it's probably not going to be very useful...
|
||||
"""
|
||||
return f"./downloads/{safefilename(self.info.title)}-{safefilename(str(int(self._time)))}.ytdl"
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Various bot interfaces, and a generic class to create new ones."""
|
||||
|
||||
from .generic import GenericBot
|
||||
from .telegram import TelegramBot, TelegramConfig
|
||||
from .discord import DiscordBot, DiscordConfig
|
||||
from .generic import GenericBot
|
||||
|
||||
__all__ = ["TelegramBot", "TelegramConfig", "DiscordBot", "DiscordConfig", "GenericBot"]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"""Commands that can be used in bots. These probably won't suit your needs, as they are tailored for the bots of the `Royal Games <https://ryg.steffo.eu>`_ gaming community, but you can check them for reference."""
|
||||
|
||||
from .null import NullCommand
|
||||
from .ping import PingCommand
|
||||
from .ship import ShipCommand
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"""Relational database classes and methods."""
|
||||
|
||||
from .alchemy import Alchemy
|
||||
from .relationshiplinkchain import relationshiplinkchain
|
||||
from .databaseconfig import DatabaseConfig
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"""Royalnet realated classes."""
|
||||
|
||||
from .messages import Message, ServerErrorMessage, InvalidSecretEM, InvalidDestinationEM, InvalidPackageEM, RequestSuccessful, RequestError, Reply
|
||||
from .packages import Package
|
||||
from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError
|
||||
|
|
|
@ -14,6 +14,7 @@ log = _logging.getLogger(__name__)
|
|||
|
||||
|
||||
class ConnectedClient:
|
||||
"""The :py:class:`royalnet.network.RoyalnetServer`-side representation of a connected :py:class:`royalnet.network.RoyalnetLink`."""
|
||||
def __init__(self, socket: websockets.WebSocketServerProtocol):
|
||||
self.socket: websockets.WebSocketServerProtocol = socket
|
||||
self.nid: typing.Optional[str] = None
|
||||
|
@ -22,9 +23,11 @@ class ConnectedClient:
|
|||
|
||||
@property
|
||||
def is_identified(self) -> bool:
|
||||
"""Has the client sent a valid identification package?"""
|
||||
return bool(self.nid)
|
||||
|
||||
async def send(self, package: Package):
|
||||
"""Send a :py:class:`royalnet.network.Package` to the :py:class:`royalnet.network.RoyalnetLink`."""
|
||||
await self.socket.send(package.pickle())
|
||||
|
||||
|
||||
|
|
|
@ -15,12 +15,7 @@ log = logging.root
|
|||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{")
|
||||
log.addHandler(stream_handler)
|
||||
logging.getLogger("royalnet.audio.royalpcmfile").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.audio.royalpcmaudio").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.audio.youtubedl").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.bots.generic").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.bots.discord").setLevel(logging.DEBUG)
|
||||
logging.getLogger("royalnet.bots.telegram").setLevel(logging.DEBUG)
|
||||
log.setLevel(logging.WARNING)
|
||||
|
||||
commands = [PingCommand, ShipCommand, SmecdsCommand, ColorCommand, CiaoruoziCommand, DebugCreateCommand, SyncCommand,
|
||||
AuthorCommand, DiarioCommand, RageCommand, DateparserCommand, ReminderCommand, KvactiveCommand, KvCommand,
|
|
@ -1,3 +1,5 @@
|
|||
"""Miscellaneous useful functions and classes."""
|
||||
|
||||
from .asyncify import asyncify
|
||||
from .call import Call
|
||||
from .command import Command
|
||||
|
|
|
@ -4,6 +4,9 @@ import typing
|
|||
|
||||
|
||||
async def asyncify(function: typing.Callable, *args, **kwargs):
|
||||
# TODO: make cancellable somehow
|
||||
loop = asyncio.get_running_loop()
|
||||
"""Convert a function into a coroutine.
|
||||
|
||||
Warning:
|
||||
The coroutine cannot be cancelled, and any attempts to do so will result in unexpected outputs."""
|
||||
loop = asyncio.get_event_loop()
|
||||
return await loop.run_in_executor(None, functools.partial(function, *args, **kwargs))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import typing
|
||||
import asyncio
|
||||
from ..network.messages import Message
|
||||
from ..network import Message, Reply
|
||||
from .command import Command
|
||||
from .commandargs import CommandArgs
|
||||
if typing.TYPE_CHECKING:
|
||||
|
@ -11,7 +11,7 @@ loop = asyncio.get_event_loop()
|
|||
|
||||
|
||||
class Call:
|
||||
"""A command call. Still an abstract class, subbots should create a new call from this."""
|
||||
"""A command call. An abstract class, sub-bots should create a new call class from this."""
|
||||
|
||||
# These parameters / methods should be overridden
|
||||
interface_name = NotImplemented
|
||||
|
@ -19,19 +19,30 @@ class Call:
|
|||
interface_prefix = NotImplemented
|
||||
alchemy: "Alchemy" = NotImplemented
|
||||
|
||||
async def reply(self, text: str):
|
||||
"""Send a text message to the channel the call was made."""
|
||||
async def reply(self, text: str) -> None:
|
||||
"""Send a text message to the channel where the call was made.
|
||||
|
||||
Parameters:
|
||||
text: The text to be sent, possibly formatted in the weird undescribed markup that I'm using."""
|
||||
raise NotImplementedError()
|
||||
|
||||
async def net_request(self, message: Message, destination: str):
|
||||
"""Send data to the rest of the Royalnet, and optionally wait for an answer.
|
||||
The data must be pickleable."""
|
||||
async def net_request(self, message, destination: str) -> Reply:
|
||||
"""Send data through a :py:class:`royalnet.network.RoyalnetLink` and wait for a :py:class:`royalnet.network.Reply`.
|
||||
|
||||
Parameters:
|
||||
message: The data to be sent. Must be :py:mod:`pickle`-able.
|
||||
destination: """
|
||||
raise NotImplementedError()
|
||||
|
||||
async def get_author(self, error_if_none=False):
|
||||
"""Try to find the universal identifier of the user that sent the message.
|
||||
That probably means, the database row identifying the user.
|
||||
Raise a UnregisteredError if error_if_none is set to True and no author is found."""
|
||||
|
||||
Parameters:
|
||||
error_if_none: Raise a :py:exc:`royalnet.error.UnregisteredError` if this is True and the call has no author.
|
||||
|
||||
Raises:
|
||||
:py:exc:`royalnet.error.UnregisteredError` if ``error_if_none`` is set to True and no author is found."""
|
||||
raise NotImplementedError()
|
||||
|
||||
# These parameters / methods should be left alone
|
||||
|
@ -40,6 +51,14 @@ class Call:
|
|||
command: typing.Type[Command],
|
||||
command_args: typing.List[str] = None,
|
||||
**kwargs):
|
||||
"""Create the call.
|
||||
|
||||
Parameters:
|
||||
channel: The channel object this call was sent in.
|
||||
command: The command to be called.
|
||||
command_args: The arguments to be passed to the command
|
||||
kwargs: Additional optional keyword arguments that may be passed to the command, possibly specific to the bot.
|
||||
"""
|
||||
if command_args is None:
|
||||
command_args = []
|
||||
self.channel = channel
|
||||
|
@ -48,18 +67,21 @@ class Call:
|
|||
self.kwargs = kwargs
|
||||
self.session = None
|
||||
|
||||
async def session_init(self):
|
||||
async def _session_init(self):
|
||||
"""If the command requires database access, create a :py:class:`royalnet.database.Alchemy` session for this call, otherwise, do nothing."""
|
||||
if not self.command.require_alchemy_tables:
|
||||
return
|
||||
self.session = await loop.run_in_executor(None, self.alchemy.Session)
|
||||
|
||||
async def session_end(self):
|
||||
"""Close the previously created :py:class:`royalnet.database.Alchemy` session for this call (if it was created)."""
|
||||
if not self.session:
|
||||
return
|
||||
self.session.close()
|
||||
|
||||
async def run(self):
|
||||
await self.session_init()
|
||||
"""Execute the called command, and return the command result."""
|
||||
await self._session_init()
|
||||
try:
|
||||
coroutine = getattr(self.command, self.interface_name)
|
||||
except AttributeError:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
def cdj(class_) -> dict:
|
||||
"""Return the cleaned class attributes in a dict."""
|
||||
"""Return a dict of the class attributes without the ``__module__``, ``__dict__``, ``__weakref__`` and ``__doc__`` keys, to be used while generating dynamically SQLAlchemy declarative table classes."""
|
||||
d = dict(class_.__dict__)
|
||||
del d["__module__"]
|
||||
del d["__dict__"]
|
||||
|
|
|
@ -4,9 +4,13 @@ from royalnet.error import InvalidInputError
|
|||
|
||||
|
||||
class CommandArgs(list):
|
||||
"""The arguments of a command. Raises :py:exc:`InvalidInputError` if the requested argument does not exist."""
|
||||
"""The arguments of a command."""
|
||||
|
||||
def __getitem__(self, item):
|
||||
"""Arguments can be accessed with an array notation, such as ``args[0]``.
|
||||
|
||||
Raises:
|
||||
:py:exc:`InvalidInputError` if the requested argument does not exist."""
|
||||
if isinstance(item, int):
|
||||
try:
|
||||
return super().__getitem__(item)
|
||||
|
@ -19,19 +23,44 @@ class CommandArgs(list):
|
|||
raise InvalidInputError(f'Tried to get invalid [{item}] slice from CommandArgs')
|
||||
raise ValueError(f"Invalid type passed to CommandArgs.__getattr__: {type(item)}")
|
||||
|
||||
def joined(self, *, require_at_least=0):
|
||||
def joined(self, *, require_at_least=0) -> str:
|
||||
"""Get the arguments as a space-joined string.
|
||||
|
||||
Parameters:
|
||||
require_at_least: the minimum amount of arguments required, will raise :py:exc:`royalnet.error.InvalidInputError` if the requirement is not fullfilled.
|
||||
|
||||
Raises:
|
||||
:py:exc:`royalnet.error.InvalidInputError` if the ``require_at_least`` requirement is not fullfilled.
|
||||
|
||||
Returns:
|
||||
The space-joined string."""
|
||||
if len(self) < require_at_least:
|
||||
raise InvalidInputError("Not enough arguments")
|
||||
return " ".join(self)
|
||||
|
||||
def match(self, pattern: typing.Pattern) -> typing.Sequence[typing.AnyStr]:
|
||||
"""Match the :py:func:`royalnet.utils.commandargs.joined` to a regex pattern.
|
||||
|
||||
Parameters:
|
||||
pattern: The regex pattern to be passed to :py:func:`re.match`.
|
||||
|
||||
Returns:
|
||||
The matched groups, as returned by :py:func:`re.Match.groups`."""
|
||||
text = self.joined()
|
||||
match = re.match(pattern, text)
|
||||
if match is None:
|
||||
raise InvalidInputError("Pattern didn't match")
|
||||
return match.groups()
|
||||
|
||||
def optional(self, index: int, default=None) -> typing.Optional:
|
||||
def optional(self, index: int, default=None):
|
||||
"""Get the argument at a specific index, but don't raise an error if nothing is found, instead returning the ``default`` value.
|
||||
|
||||
Parameters:
|
||||
index: The index of the argument you want to retrieve.
|
||||
default: The value returned if the argument is missing.
|
||||
|
||||
Returns:
|
||||
Either the argument or the ``default`` value, defaulting to ``None``."""
|
||||
try:
|
||||
return self[index]
|
||||
except InvalidInputError:
|
||||
|
|
|
@ -2,10 +2,10 @@ def plusformat(i: int) -> str:
|
|||
"""Convert an :py:class:`int` to a string, adding a plus if they are greater than 0.
|
||||
|
||||
Parameters:
|
||||
i: the :py:class:`int` to convert
|
||||
i: the :py:class:`int` to convert.
|
||||
|
||||
Returns:
|
||||
The resulting :py:class:`str`"""
|
||||
The resulting :py:class:`str`."""
|
||||
if i >= 0:
|
||||
return f"+{i}"
|
||||
return str(i)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
|
||||
|
||||
def safefilename(string: str):
|
||||
def safefilename(string: str) -> str:
|
||||
"""Ensure a string can be used as a filename by replacing all non-word characters with underscores."""
|
||||
return re.sub(r"\W", "_", string)
|
||||
|
|
|
@ -3,11 +3,13 @@ class SafeDict(dict):
|
|||
return "{" + key + "}"
|
||||
|
||||
|
||||
def safeformat(string: str, ignore_escaping: bool = False, **words: str) -> str:
|
||||
if ignore_escaping:
|
||||
escaped = words
|
||||
else:
|
||||
escaped = {}
|
||||
for key in words:
|
||||
escaped[key] = str(words[key]).replace("<", "<").replace(">", ">")
|
||||
return string.format_map(SafeDict(**escaped))
|
||||
def safeformat(string: str, **words: str) -> str:
|
||||
""":py:func:`str.format` something, but ignore missing keys instead of raising an error.
|
||||
|
||||
Parameters:
|
||||
string: The base string to be formatted.
|
||||
words: The words to format the string with.
|
||||
|
||||
Returns:
|
||||
The formatted string."""
|
||||
return string.format_map(SafeDict(**words))
|
||||
|
|
Loading…
Add table
Reference in a new issue