<h1>API Reference<aclass="headerlink"href="#api-reference"title="Permalink to this headline">¶</a></h1>
<p>These pages were automatically generated from docstrings in code.</p>
<p>They might be outdated, or incomplete.</p>
<divclass="section"id="module-royalnet.audio">
<spanid="audio"></span><h2>Audio<aclass="headerlink"href="#module-royalnet.audio"title="Permalink to this headline">¶</a></h2>
<p>Video and audio downloading related classes, mainly used for Discord voice bots.</p>
<dlclass="class">
<dtid="royalnet.audio.YtdlInfo">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.audio.</code><codeclass="sig-name descname">YtdlInfo</code><spanclass="sig-paren">(</span><emclass="sig-param">info: Dict[str, Any]</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlInfo"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper around youtube_dl extracted info.</p>
<dlclass="method">
<dtid="royalnet.audio.YtdlInfo.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">info: Dict[str, Any]</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlInfo.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a YtdlInfo from the dict returned by the <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">youtube_dl.YoutubeDL.extract_info()</span></code> function.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Does not download the info, for that use <aclass="reference internal"href="#royalnet.audio.YtdlInfo.retrieve_for_url"title="royalnet.audio.YtdlInfo.retrieve_for_url"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">royalnet.audio.YtdlInfo.retrieve_for_url()</span></code></a>.</p>
<codeclass="sig-name descname">_default_ytdl_args</code><emclass="property"> = {'ignoreerrors': True, 'no_warnings': True, 'noplaylist': True, 'outtmpl': '%(title)s-%(id)s.%(ext)s', 'quiet': True}</em><aclass="headerlink"href="#royalnet.audio.YtdlInfo._default_ytdl_args"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlInfo.retrieve_for_url">
<emclass="property">classmethod </em><codeclass="sig-name descname">retrieve_for_url</code><spanclass="sig-paren">(</span><emclass="sig-param">url</em>, <emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ List[royalnet.audio.ytdlinfo.YtdlInfo]<aclass="headerlink"href="#royalnet.audio.YtdlInfo.retrieve_for_url"title="Permalink to this definition">¶</a></dt>
<dd><p>Fetch the info for an url through YoutubeDL.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>A <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#list"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">list</span></code></a> containing the infos for the requested videos.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlInfo.to_discord_embed">
<codeclass="sig-name descname">to_discord_embed</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ discord.embeds.Embed<aclass="headerlink"href="#royalnet.audio.YtdlInfo.to_discord_embed"title="Permalink to this definition">¶</a></dt>
<dd><p>Return this info as a <aclass="reference external"href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed"title="(in discord.py v1.3.0a)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">discord.Embed</span></code></a>.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.audio.YtdlFile">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.audio.</code><codeclass="sig-name descname">YtdlFile</code><spanclass="sig-paren">(</span><emclass="sig-param">url: str</em>, <emclass="sig-param">info: Optional[royalnet.audio.ytdlinfo.YtdlInfo] = None</em>, <emclass="sig-param">filename: Optional[str] = None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlFile"title="Permalink to this definition">¶</a></dt>
<dd><p>Information about a youtube-dl downloaded file.</p>
<codeclass="sig-name descname">_default_ytdl_args</code><emclass="property"> = {'ignoreerrors': True, 'no_warnings': True, 'noplaylist': True, 'outtmpl': '%(epoch)s-%(title)s-%(id)s.%(ext)s', 'quiet': True}</em><aclass="headerlink"href="#royalnet.audio.YtdlFile._default_ytdl_args"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.delete">
<codeclass="sig-name descname">delete</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlFile.delete"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.download_file">
<codeclass="sig-name descname">download_file</code><spanclass="sig-paren">(</span><emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlFile.download_file"title="Permalink to this definition">¶</a></dt>
<emclass="property">classmethod </em><codeclass="sig-name descname">download_from_url</code><spanclass="sig-paren">(</span><emclass="sig-param">url: str</em>, <emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ List[royalnet.audio.ytdlfile.YtdlFile]<aclass="headerlink"href="#royalnet.audio.YtdlFile.download_from_url"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.has_info">
<codeclass="sig-name descname">has_info</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ bool<aclass="headerlink"href="#royalnet.audio.YtdlFile.has_info"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.is_downloaded">
<codeclass="sig-name descname">is_downloaded</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ bool<aclass="headerlink"href="#royalnet.audio.YtdlFile.is_downloaded"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.open">
<codeclass="sig-name descname">open</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlFile.open"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlFile.update_info">
<codeclass="sig-name descname">update_info</code><spanclass="sig-paren">(</span><emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlFile.update_info"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.audio.FileAudioSource">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.audio.</code><codeclass="sig-name descname">FileAudioSource</code><spanclass="sig-paren">(</span><emclass="sig-param">file</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.FileAudioSource"title="Permalink to this definition">¶</a></dt>
<dd><p>A <aclass="reference external"href="https://discordpy.readthedocs.io/en/latest/api.html#discord.AudioSource"title="(in discord.py v1.3.0a)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">discord.AudioSource</span></code></a> that uses a <aclass="reference external"href="https://docs.python.org/3.7/library/io.html#io.BufferedIOBase"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">io.BufferedIOBase</span></code></a> as an input instead of memory.</p>
<p>The stream should be in the usual PCM encoding.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>This AudioSource will consume (and close) the passed stream.</p>
</div>
<dlclass="method">
<dtid="royalnet.audio.FileAudioSource.is_opus">
<codeclass="sig-name descname">is_opus</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.FileAudioSource.is_opus"title="Permalink to this definition">¶</a></dt>
<dd><p>This audio file isn’t Opus-encoded, but PCM-encoded.</p>
<codeclass="sig-name descname">read</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.FileAudioSource.read"title="Permalink to this definition">¶</a></dt>
<dd><p>Reads 20ms worth of audio.</p>
<p>If the audio is complete, then returning an empty <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#bytes"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">bytes</span></code></a>-like object to signal this is the way to do so.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.audio.YtdlDiscord">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.audio.</code><codeclass="sig-name descname">YtdlDiscord</code><spanclass="sig-paren">(</span><emclass="sig-param">ytdl_file: royalnet.audio.ytdlfile.YtdlFile</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlDiscord"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">convert_to_pcm</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlDiscord.convert_to_pcm"title="Permalink to this definition">¶</a></dt>
<emclass="property">classmethod </em><codeclass="sig-name descname">create_from_url</code><spanclass="sig-paren">(</span><emclass="sig-param">url</em>, <emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ List[royalnet.audio.ytdldiscord.YtdlDiscord]<aclass="headerlink"href="#royalnet.audio.YtdlDiscord.create_from_url"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlDiscord.delete">
<codeclass="sig-name descname">delete</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlDiscord.delete"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlDiscord.info">
<emclass="property">property </em><codeclass="sig-name descname">info</code><aclass="headerlink"href="#royalnet.audio.YtdlDiscord.info"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlDiscord.pcm_available">
<codeclass="sig-name descname">pcm_available</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlDiscord.pcm_available"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlDiscord.ready_up">
<codeclass="sig-name descname">ready_up</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlDiscord.ready_up"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">spawn_audiosource</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ royalnet.audio.fileaudiosource.FileAudioSource<aclass="headerlink"href="#royalnet.audio.YtdlDiscord.spawn_audiosource"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.audio.YtdlMp3">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.audio.</code><codeclass="sig-name descname">YtdlMp3</code><spanclass="sig-paren">(</span><emclass="sig-param">ytdl_file: royalnet.audio.ytdlfile.YtdlFile</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlMp3"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="method">
<dtid="royalnet.audio.YtdlMp3.convert_to_mp3">
<codeclass="sig-name descname">convert_to_mp3</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlMp3.convert_to_mp3"title="Permalink to this definition">¶</a></dt>
<emclass="property">classmethod </em><codeclass="sig-name descname">create_and_ready_from_url</code><spanclass="sig-paren">(</span><emclass="sig-param">url</em>, <emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ List[royalnet.audio.ytdlmp3.YtdlMp3]<aclass="headerlink"href="#royalnet.audio.YtdlMp3.create_and_ready_from_url"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlMp3.create_from_url">
<emclass="property">classmethod </em><codeclass="sig-name descname">create_from_url</code><spanclass="sig-paren">(</span><emclass="sig-param">url</em>, <emclass="sig-param">**ytdl_args</em><spanclass="sig-paren">)</span>→ List[royalnet.audio.ytdlmp3.YtdlMp3]<aclass="headerlink"href="#royalnet.audio.YtdlMp3.create_from_url"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlMp3.delete">
<codeclass="sig-name descname">delete</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.audio.YtdlMp3.delete"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlMp3.info">
<emclass="property">property </em><codeclass="sig-name descname">info</code><aclass="headerlink"href="#royalnet.audio.YtdlMp3.info"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlMp3.pcm_available">
<codeclass="sig-name descname">pcm_available</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlMp3.pcm_available"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.audio.YtdlMp3.ready_up">
<codeclass="sig-name descname">ready_up</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.audio.YtdlMp3.ready_up"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<divclass="section"id="module-royalnet.bots">
<spanid="bots"></span><h2>Bots<aclass="headerlink"href="#module-royalnet.bots"title="Permalink to this headline">¶</a></h2>
<p>Various bot interfaces, and a generic class to create new ones.</p>
<dd><p>A bot that connects to <aclass="reference external"href="https://telegram.org/">Telegram</a>.</p>
<dlclass="method">
<dtid="royalnet.bots.TelegramBot._data_factory">
<codeclass="sig-name descname">_data_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commanddata.CommandData]<aclass="headerlink"href="#royalnet.bots.TelegramBot._data_factory"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">_handle_callback_query</code><spanclass="sig-paren">(</span><emclass="sig-param">update: telegram.update.Update</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot._handle_callback_query"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">_handle_message</code><spanclass="sig-paren">(</span><emclass="sig-param">update: telegram.update.Update</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot._handle_message"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">_handle_update</code><spanclass="sig-paren">(</span><emclass="sig-param">update: telegram.update.Update</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot._handle_update"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.TelegramBot._init_client">
<codeclass="sig-name descname">_init_client</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot._init_client"title="Permalink to this definition">¶</a></dt>
<dd><p>Create the <aclass="reference external"href="https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot"title="(in Python Telegram Bot v12.1)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">telegram.Bot</span></code></a>, and set the starting offset.</p>
<codeclass="sig-name descname">_initialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot._initialize"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_interface_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commandinterface.CommandInterface]<aclass="headerlink"href="#royalnet.bots.TelegramBot._interface_factory"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.bots.TelegramBot.interface_name">
<codeclass="sig-name descname">interface_name</code><emclass="property"> = 'telegram'</em><aclass="headerlink"href="#royalnet.bots.TelegramBot.interface_name"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.TelegramBot.run">
<emclass="property">async </em><codeclass="sig-name descname">run</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.TelegramBot.run"title="Permalink to this definition">¶</a></dt>
<dd><p>A blocking coroutine that should make the bot start listening to commands and requests.</p>
<emclass="property">static </em><codeclass="sig-name descname">safe_api_call</code><spanclass="sig-paren">(</span><emclass="sig-param">f: Callable</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span>→ Optional<aclass="headerlink"href="#royalnet.bots.TelegramBot.safe_api_call"title="Permalink to this definition">¶</a></dt>
<dd><p>A bot that connects to <aclass="reference external"href="https://discordapp.com/">Discord</a>.</p>
<dlclass="method">
<dtid="royalnet.bots.DiscordBot._bot_factory">
<codeclass="sig-name descname">_bot_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[discord.client.Client]<aclass="headerlink"href="#royalnet.bots.DiscordBot._bot_factory"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a custom DiscordClient class inheriting from <aclass="reference external"href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Client"title="(in discord.py v1.3.0a)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">discord.Client</span></code></a>.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.bots.DiscordBot._data_factory">
<codeclass="sig-name descname">_data_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commanddata.CommandData]<aclass="headerlink"href="#royalnet.bots.DiscordBot._data_factory"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.DiscordBot._init_client">
<codeclass="sig-name descname">_init_client</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot._init_client"title="Permalink to this definition">¶</a></dt>
<dd><p>Create an instance of the DiscordClient class created in <aclass="reference internal"href="#royalnet.bots.DiscordBot._bot_factory"title="royalnet.bots.DiscordBot._bot_factory"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">royalnet.bots.DiscordBot._bot_factory()</span></code></a>.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.bots.DiscordBot._init_voice">
<codeclass="sig-name descname">_init_voice</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot._init_voice"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the variables needed for the connection to voice chat.</p>
<codeclass="sig-name descname">_initialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot._initialize"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_interface_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commandinterface.CommandInterface]<aclass="headerlink"href="#royalnet.bots.DiscordBot._interface_factory"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">add_to_music_data</code><spanclass="sig-paren">(</span><emclass="sig-param">dfiles: List[royalnet.audio.ytdldiscord.YtdlDiscord], guild: discord.guild.Guild</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot.add_to_music_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Add a list of <aclass="reference internal"href="#royalnet.audio.YtdlDiscord"title="royalnet.audio.YtdlDiscord"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.audio.YtdlDiscord</span></code></a> to the corresponding music_data object.</p>
<emclass="property">async </em><codeclass="sig-name descname">advance_music_data</code><spanclass="sig-paren">(</span><emclass="sig-param">guild: discord.guild.Guild</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot.advance_music_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to play the next song, while it exists. Otherwise, just return.</p>
</dd></dl>
<dlclass="attribute">
<dtid="royalnet.bots.DiscordBot.interface_name">
<codeclass="sig-name descname">interface_name</code><emclass="property"> = 'discord'</em><aclass="headerlink"href="#royalnet.bots.DiscordBot.interface_name"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.DiscordBot.run">
<emclass="property">async </em><codeclass="sig-name descname">run</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot.run"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">update_activity_with_source_title</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.DiscordBot.update_activity_with_source_title"title="Permalink to this definition">¶</a></dt>
<dd><p>Change the bot’s presence (using <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">discord.Client.change_presence()</span></code>) to match the current listening status.</p>
<p>If multiple guilds are using the bot, the bot will always have an empty presence.</p>
<codeclass="sig-name descname">_data_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commanddata.CommandData]<aclass="headerlink"href="#royalnet.bots.GenericBot._data_factory"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_init_commands</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.bots.GenericBot._init_commands"title="Permalink to this definition">¶</a></dt>
<dd><p>Generate the <codeclass="docutils literal notranslate"><spanclass="pre">commands</span></code> dictionary required to handle incoming messages, and the <codeclass="docutils literal notranslate"><spanclass="pre">network_handlers</span></code>
dictionary required to handle incoming requests.</p>
<codeclass="sig-name descname">_init_database</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot._init_database"title="Permalink to this definition">¶</a></dt>
<dd><p>Create an <aclass="reference internal"href="#royalnet.database.Alchemy"title="royalnet.database.Alchemy"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.database.Alchemy</span></code></a> with the tables required by the commands. Then,
find the chain that links the <codeclass="docutils literal notranslate"><spanclass="pre">master_table</span></code> to the <codeclass="docutils literal notranslate"><spanclass="pre">identity_table</span></code>.</p>
<codeclass="sig-name descname">_init_loop</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot._init_loop"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.GenericBot._init_network">
<codeclass="sig-name descname">_init_network</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot._init_network"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a>, and run it as a <aclass="reference external"href="https://docs.python.org/3.7/library/asyncio-task.html#asyncio.Task"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">asyncio.Task</span></code></a>.</p>
<codeclass="sig-name descname">_init_sentry</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot._init_sentry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.bots.GenericBot._initialize">
<codeclass="sig-name descname">_initialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot._initialize"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_interface_factory</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ Type[royalnet.commands.commandinterface.CommandInterface]<aclass="headerlink"href="#royalnet.bots.GenericBot._interface_factory"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">_network_handler</code><spanclass="sig-paren">(</span><emclass="sig-param">request_dict: dict</em><spanclass="sig-paren">)</span>→ dict<aclass="headerlink"href="#royalnet.bots.GenericBot._network_handler"title="Permalink to this definition">¶</a></dt>
<dd><p>Handle a single <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#dict"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dict</span></code></a> received from the <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a>.</p>
<codeclass="sig-name descname">get_secret</code><spanclass="sig-paren">(</span><emclass="sig-param">username: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot.get_secret"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">interface_name</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.bots.GenericBot.interface_name"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">run</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot.run"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">run_blocking</code><spanclass="sig-paren">(</span><emclass="sig-param">verbose=False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot.run_blocking"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">set_secret</code><spanclass="sig-paren">(</span><emclass="sig-param">username: str</em>, <emclass="sig-param">password: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.bots.GenericBot.set_secret"title="Permalink to this definition">¶</a></dt>
<spanid="commands"></span><h2>Commands<aclass="headerlink"href="#module-royalnet.commands"title="Permalink to this headline">¶</a></h2>
<dlclass="class">
<dtid="royalnet.commands.CommandInterface">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">CommandInterface</code><aclass="headerlink"href="#royalnet.commands.CommandInterface"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">alchemy</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.CommandInterface.alchemy"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.commands.CommandInterface.bot">
<codeclass="sig-name descname">bot</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.CommandInterface.bot"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.commands.CommandInterface.loop">
<codeclass="sig-name descname">loop</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.CommandInterface.loop"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.commands.CommandInterface.name">
<codeclass="sig-name descname">name</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.CommandInterface.name"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">net_request</code><spanclass="sig-paren">(</span><emclass="sig-param">message</em>, <emclass="sig-param">destination: str</em><spanclass="sig-paren">)</span>→ dict<aclass="headerlink"href="#royalnet.commands.CommandInterface.net_request"title="Permalink to this definition">¶</a></dt>
<dd><p>Send data through a <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a> and wait for a
<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>
<li><p><strong>destination</strong>– The destination of the request, either in UUID format or node name.</p></li>
<codeclass="sig-name descname">prefix</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.CommandInterface.prefix"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">register_keyboard_key</code><spanclass="sig-paren">(</span><emclass="sig-param">key_name: str</em>, <emclass="sig-param">callback: Callable</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandInterface.register_keyboard_key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">register_net_handler</code><spanclass="sig-paren">(</span><emclass="sig-param">message_type: str</em>, <emclass="sig-param">network_handler: Callable</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandInterface.register_net_handler"title="Permalink to this definition">¶</a></dt>
<dd><p>Register a new handler for messages received through Royalnet.</p>
<codeclass="sig-name descname">unregister_keyboard_key</code><spanclass="sig-paren">(</span><emclass="sig-param">key_name: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandInterface.unregister_keyboard_key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">unregister_net_handler</code><spanclass="sig-paren">(</span><emclass="sig-param">message_type: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandInterface.unregister_net_handler"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove a Royalnet handler.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.commands.Command">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">Command</code><spanclass="sig-paren">(</span><emclass="sig-param">interface: royalnet.commands.commandinterface.CommandInterface</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.Command"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.Command.aliases"title="Permalink to this definition">¶</a></dt>
<dd><p>A list of possible aliases for a command.
To have <codeclass="docutils literal notranslate"><spanclass="pre">/e</span></code> as alias for <codeclass="docutils literal notranslate"><spanclass="pre">/example</span></code>, one should set aliases to <codeclass="docutils literal notranslate"><spanclass="pre">["e"]</span></code>.</p>
<codeclass="sig-name descname">description</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.Command.description"title="Permalink to this definition">¶</a></dt>
<dd><p>A small description of the command, to be displayed when the command is being autocompleted.</p>
</dd></dl>
<dlclass="attribute">
<dtid="royalnet.commands.Command.name">
<codeclass="sig-name descname">name</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.commands.Command.name"title="Permalink to this definition">¶</a></dt>
<dd><p>The main name of the command.
To have <codeclass="docutils literal notranslate"><spanclass="pre">/example</span></code> on Telegram, the name should be <codeclass="docutils literal notranslate"><spanclass="pre">example</span></code>.</p>
<codeclass="sig-name descname">require_alchemy_tables</code><emclass="property"> = {}</em><aclass="headerlink"href="#royalnet.commands.Command.require_alchemy_tables"title="Permalink to this definition">¶</a></dt>
<dd><p>A set of <aclass="reference internal"href="#module-royalnet.database"title="royalnet.database"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.database</span></code></a> tables that must exist for this command to work.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.commands.Command.run">
<emclass="property">async </em><codeclass="sig-name descname">run</code><spanclass="sig-paren">(</span><emclass="sig-param">args: royalnet.commands.commandargs.CommandArgs</em>, <emclass="sig-param">data: royalnet.commands.commanddata.CommandData</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.commands.Command.run"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="royalnet.commands.Command.syntax">
<codeclass="sig-name descname">syntax</code><emclass="property"> = ''</em><aclass="headerlink"href="#royalnet.commands.Command.syntax"title="Permalink to this definition">¶</a></dt>
<dd><p>The syntax of the command, to be displayed when a <codeclass="xref py py-exc docutils literal notranslate"><spanclass="pre">royalnet.error.InvalidInputError</span></code> is raised,
in the format <codeclass="docutils literal notranslate"><spanclass="pre">(required_arg)</span><spanclass="pre">[optional_arg]</span></code>.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.commands.CommandData">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">CommandData</code><aclass="headerlink"href="#royalnet.commands.CommandData"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">delete_invoking</code><spanclass="sig-paren">(</span><emclass="sig-param">error_if_unavailable=False</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.commands.CommandData.delete_invoking"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">get_author</code><spanclass="sig-paren">(</span><emclass="sig-param">error_if_none: bool = False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandData.get_author"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to find the identifier of the user that sent the message.
That probably means, the database row identifying the user.</p>
<emclass="property">async </em><codeclass="sig-name descname">keyboard</code><spanclass="sig-paren">(</span><emclass="sig-param">text: str, keyboard: Dict[str, Callable]</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.commands.CommandData.keyboard"title="Permalink to this definition">¶</a></dt>
<dd><p>Send a keyboard having the keys of the dict as keys and calling the correspondent values on a press.</p>
<p>The function should be passed the <aclass="reference internal"href="#royalnet.commands.CommandData"title="royalnet.commands.CommandData"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">CommandData</span></code></a> instance as a argument.</p>
<emclass="property">async </em><codeclass="sig-name descname">reply</code><spanclass="sig-paren">(</span><emclass="sig-param">text: str</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.commands.CommandData.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>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.commands.CommandArgs">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">CommandArgs</code><aclass="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>
<codeclass="sig-name descname">__getitem__</code><spanclass="sig-paren">(</span><emclass="sig-param">item</em><spanclass="sig-paren">)</span><aclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">args[0]</span></code>.</p>
<codeclass="sig-name descname">joined</code><spanclass="sig-paren">(</span><emclass="sig-param">*</em>, <emclass="sig-param">require_at_least=0</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.commands.CommandArgs.joined"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the arguments as a space-joined string.</p>
<ddclass="field-odd"><p><strong>require_at_least</strong>– the minimum amount of arguments required, will raise <codeclass="xref py py-exc docutils literal notranslate"><spanclass="pre">royalnet.error.InvalidInputError</span></code> if the requirement is not fullfilled.</p>
<ddclass="field-even"><p><strong>royalnet.error.InvalidInputError</strong>– if there are less than <codeclass="docutils literal notranslate"><spanclass="pre">require_at_least</span></code> arguments.</p>
<codeclass="sig-name descname">match</code><spanclass="sig-paren">(</span><emclass="sig-param">pattern: Union[str, Pattern], *flags</em><spanclass="sig-paren">)</span>→ Sequence[AnyStr]<aclass="headerlink"href="#royalnet.commands.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>
<ddclass="field-odd"><p>The matched groups, as returned by <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">re.Match.groups()</span></code>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.commands.CommandArgs.optional">
<codeclass="sig-name descname">optional</code><spanclass="sig-paren">(</span><emclass="sig-param">index: int</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="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 <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">exception </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">CommandError</code><spanclass="sig-paren">(</span><emclass="sig-param">message=''</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.CommandError"title="Permalink to this definition">¶</a></dt>
<dd><p>Something went wrong during the execution of this command.</p>
<p>Display an error message to the user, explaining what went wrong.</p>
</dd></dl>
<dlclass="exception">
<dtid="royalnet.commands.InvalidInputError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">InvalidInputError</code><spanclass="sig-paren">(</span><emclass="sig-param">message=''</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.InvalidInputError"title="Permalink to this definition">¶</a></dt>
<dd><p>The command has received invalid input and cannot complete.</p>
<p>Display an error message to the user, along with the correct syntax for the command.</p>
</dd></dl>
<dlclass="exception">
<dtid="royalnet.commands.UnsupportedError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">UnsupportedError</code><spanclass="sig-paren">(</span><emclass="sig-param">message=''</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.UnsupportedError"title="Permalink to this definition">¶</a></dt>
<dd><p>A requested feature is not available on this interface.</p>
<p>Display an error message to the user, telling them to use another interface.</p>
</dd></dl>
<dlclass="exception">
<dtid="royalnet.commands.KeyboardExpiredError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.commands.</code><codeclass="sig-name descname">KeyboardExpiredError</code><spanclass="sig-paren">(</span><emclass="sig-param">message=''</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.commands.KeyboardExpiredError"title="Permalink to this definition">¶</a></dt>
<dd><p>A special type of exception that can be raised in keyboard handlers to mark a specific keyboard as expired.</p>
<spanid="database"></span><h2>Database<aclass="headerlink"href="#module-royalnet.database"title="Permalink to this headline">¶</a></h2>
<p>Relational database classes and methods.</p>
<dlclass="class">
<dtid="royalnet.database.Alchemy">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.database.</code><codeclass="sig-name descname">Alchemy</code><spanclass="sig-paren">(</span><emclass="sig-param">database_uri: str</em>, <emclass="sig-param">tables: Set</em><spanclass="sig-paren">)</span><aclass="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>
<dlclass="method">
<dtid="royalnet.database.Alchemy.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">database_uri: str</em>, <emclass="sig-param">tables: Set</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.database.Alchemy.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new Alchemy object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>database_uri</strong>– The uri of the database, as described at <aclass="reference external"href="https://docs.sqlalchemy.org/en/13/core/engines.html">https://docs.sqlalchemy.org/en/13/core/engines.html</a> .</p></li>
<li><p><strong>tables</strong>– The set of tables to be created and used in the selected database. Check the tables submodule for more details.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.database.Alchemy._create_tables">
<codeclass="sig-name descname">_create_tables</code><spanclass="sig-paren">(</span><emclass="sig-param">tables: Set</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.database.Alchemy._create_tables"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.database.Alchemy.session_acm">
<codeclass="sig-name descname">session_acm</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.database.Alchemy.session_acm"title="Permalink to this definition">¶</a></dt>
<dd><p>Use Alchemy as a asyncronous context manager (to be used in async with statements).</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.database.Alchemy.session_cm">
<codeclass="sig-name descname">session_cm</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.database.Alchemy.session_cm"title="Permalink to this definition">¶</a></dt>
<dd><p>Use Alchemy as a context manager (to be used in with statements).</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="royalnet.database.relationshiplinkchain">
<codeclass="sig-prename descclassname">royalnet.database.</code><codeclass="sig-name descname">relationshiplinkchain</code><spanclass="sig-paren">(</span><emclass="sig-param">starting_class</em>, <emclass="sig-param">ending_class</em><spanclass="sig-paren">)</span>→ Optional[tuple]<aclass="headerlink"href="#royalnet.database.relationshiplinkchain"title="Permalink to this definition">¶</a></dt>
<dd><p>Find the path to follow to get from the starting table to the ending table.</p>
</dd></dl>
<dlclass="class">
<dtid="royalnet.database.DatabaseConfig">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.database.</code><codeclass="sig-name descname">DatabaseConfig</code><spanclass="sig-paren">(</span><emclass="sig-param">database_uri: str</em>, <emclass="sig-param">master_table: Type</em>, <emclass="sig-param">identity_table: Type</em>, <emclass="sig-param">identity_column_name: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.database.DatabaseConfig"title="Permalink to this definition">¶</a></dt>
<dd><p>The configuration to be used for the <aclass="reference internal"href="#royalnet.database.Alchemy"title="royalnet.database.Alchemy"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.database.Alchemy</span></code></a> component of <aclass="reference internal"href="#royalnet.bots.GenericBot"title="royalnet.bots.GenericBot"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.bots.GenericBot</span></code></a>.</p>
<emclass="property">async </em><codeclass="sig-name descname">connect</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkLink.connect"title="Permalink to this definition">¶</a></dt>
<dd><p>Connect to the <aclass="reference internal"href="#royalnet.network.NetworkServer"title="royalnet.network.NetworkServer"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkServer</span></code></a> at <codeclass="docutils literal notranslate"><spanclass="pre">self.master_uri</span></code>.</p>
<emclass="property">async </em><codeclass="sig-name descname">identify</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.network.NetworkLink.identify"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">receive</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ royalnet.network.package.Package<aclass="headerlink"href="#royalnet.network.NetworkLink.receive"title="Permalink to this definition">¶</a></dt>
<dd><p>Recieve a <aclass="reference internal"href="#royalnet.network.Package"title="royalnet.network.Package"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Package</span></code></a> from the <aclass="reference internal"href="#royalnet.network.NetworkServer"title="royalnet.network.NetworkServer"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkServer</span></code></a>.</p>
<emclass="property">async </em><codeclass="sig-name descname">request</code><spanclass="sig-paren">(</span><emclass="sig-param">message</em>, <emclass="sig-param">destination</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkLink.request"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">run</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkLink.run"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">send</code><spanclass="sig-paren">(</span><emclass="sig-param">package: royalnet.network.package.Package</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkLink.send"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">NetworkError</code><spanclass="sig-paren">(</span><emclass="sig-param">error_data: dict</em>, <emclass="sig-param">*args</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkError"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="exception">
<dtid="royalnet.network.NotConnectedError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">NotConnectedError</code><aclass="headerlink"href="#royalnet.network.NotConnectedError"title="Permalink to this definition">¶</a></dt>
<dd><p>The <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a> is not connected to a <aclass="reference internal"href="#royalnet.network.NetworkServer"title="royalnet.network.NetworkServer"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkServer</span></code></a>.</p>
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">NotIdentifiedError</code><aclass="headerlink"href="#royalnet.network.NotIdentifiedError"title="Permalink to this definition">¶</a></dt>
<dd><p>A Royalnet package, the data type with which a <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a> communicates with a <aclass="reference internal"href="#royalnet.network.NetworkServer"title="royalnet.network.NetworkServer"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkServer</span></code></a> or another link.
Contains info about the source and the destination.</p>
<dlclass="method">
<dtid="royalnet.network.Package.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">data: dict</em>, <emclass="sig-param">*</em>, <emclass="sig-param">source: str</em>, <emclass="sig-param">destination: str</em>, <emclass="sig-param">source_conv_id: Optional[str] = None</em>, <emclass="sig-param">destination_conv_id: Optional[str] = None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.Package.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Package.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>data</strong>– The data that should be sent. Usually a <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Message</span></code>.</p></li>
<li><p><strong>source</strong>– The <codeclass="docutils literal notranslate"><spanclass="pre">nid</span></code> of the node that created this Package.</p></li>
<li><p><strong>destination</strong>– The <codeclass="docutils literal notranslate"><spanclass="pre">link_type</span></code> of the destination node, or alternatively, the <codeclass="docutils literal notranslate"><spanclass="pre">nid</span></code> of the node. Can also be the <codeclass="docutils literal notranslate"><spanclass="pre">NULL</span></code> value to send the message to nobody.</p></li>
<li><p><strong>source_conv_id</strong>– The conversation id of the node that created this package. Akin to the sequence number on IP packets.</p></li>
<li><p><strong>destination_conv_id</strong>– The conversation id of the node that this Package is a reply to.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.from_dict">
<emclass="property">static </em><codeclass="sig-name descname">from_dict</code><spanclass="sig-paren">(</span><emclass="sig-param">d</em><spanclass="sig-paren">)</span>→ royalnet.network.package.Package<aclass="headerlink"href="#royalnet.network.Package.from_dict"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Package from a dictionary.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.from_json_bytes">
<emclass="property">static </em><codeclass="sig-name descname">from_json_bytes</code><spanclass="sig-paren">(</span><emclass="sig-param">b: bytes</em><spanclass="sig-paren">)</span>→ royalnet.network.package.Package<aclass="headerlink"href="#royalnet.network.Package.from_json_bytes"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Package from UTF8-encoded JSON bytes.</p>
<emclass="property">static </em><codeclass="sig-name descname">from_json_string</code><spanclass="sig-paren">(</span><emclass="sig-param">string: str</em><spanclass="sig-paren">)</span>→ royalnet.network.package.Package<aclass="headerlink"href="#royalnet.network.Package.from_json_string"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Package from a JSON string.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.reply">
<codeclass="sig-name descname">reply</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span>→ royalnet.network.package.Package<aclass="headerlink"href="#royalnet.network.Package.reply"title="Permalink to this definition">¶</a></dt>
<dd><p>Reply to this Package with another Package.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong>– The data that should be sent. Usually a <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Message</span></code>.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The reply Package.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.to_dict">
<codeclass="sig-name descname">to_dict</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ dict<aclass="headerlink"href="#royalnet.network.Package.to_dict"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the Package into a dictionary.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.to_json_bytes">
<codeclass="sig-name descname">to_json_bytes</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ bytes<aclass="headerlink"href="#royalnet.network.Package.to_json_bytes"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the Package into UTF8-encoded JSON bytes.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Package.to_json_string">
<codeclass="sig-name descname">to_json_string</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.network.Package.to_json_string"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the Package into a JSON string.</p>
<codeclass="sig-name descname">find_destination</code><spanclass="sig-paren">(</span><emclass="sig-param">package: royalnet.network.package.Package</em><spanclass="sig-paren">)</span>→ List[royalnet.network.networkserver.ConnectedClient]<aclass="headerlink"href="#royalnet.network.NetworkServer.find_destination"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">listener</code><spanclass="sig-paren">(</span><emclass="sig-param">websocket: websockets.server.WebSocketServerProtocol</em>, <emclass="sig-param">path</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkServer.listener"title="Permalink to this definition">¶</a></dt>
<emclass="property">async </em><codeclass="sig-name descname">route_package</code><spanclass="sig-paren">(</span><emclass="sig-param">package: royalnet.network.package.Package</em><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#royalnet.network.NetworkServer.route_package"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">run_blocking</code><spanclass="sig-paren">(</span><emclass="sig-param">verbose=False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkServer.run_blocking"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">serve</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkServer.serve"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">NetworkConfig</code><spanclass="sig-paren">(</span><emclass="sig-param">master_uri: str</em>, <emclass="sig-param">master_secret: str</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.NetworkConfig"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">ConnectionClosedError</code><aclass="headerlink"href="#royalnet.network.ConnectionClosedError"title="Permalink to this definition">¶</a></dt>
<dd><p>The <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a>’s connection was closed unexpectedly. The link can’t be used anymore.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">Request</code><spanclass="sig-paren">(</span><emclass="sig-param">handler: str</em>, <emclass="sig-param">data: dict</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.Request"title="Permalink to this definition">¶</a></dt>
<dd><p>A request sent from a <aclass="reference internal"href="#royalnet.network.NetworkLink"title="royalnet.network.NetworkLink"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.NetworkLink</span></code></a> to another.</p>
<p>It contains the name of the requested handler, in addition to the data.</p>
<dlclass="method">
<dtid="royalnet.network.Request.from_dict">
<emclass="property">static </em><codeclass="sig-name descname">from_dict</code><spanclass="sig-paren">(</span><emclass="sig-param">d: dict</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.Request.from_dict"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="royalnet.network.Request.to_dict">
<codeclass="sig-name descname">to_dict</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.Request.to_dict"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.network.Response">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">Response</code><aclass="headerlink"href="#royalnet.network.Response"title="Permalink to this definition">¶</a></dt>
<dd><p>A base class to be inherited by all other response types.</p>
<dlclass="method">
<dtid="royalnet.network.Response.from_dict">
<emclass="property">classmethod </em><codeclass="sig-name descname">from_dict</code><spanclass="sig-paren">(</span><emclass="sig-param">d: dict</em><spanclass="sig-paren">)</span>→ royalnet.network.response.Response<aclass="headerlink"href="#royalnet.network.Response.from_dict"title="Permalink to this definition">¶</a></dt>
<dd><p>Recreate the response from a received <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#dict"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dict</span></code></a>.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Response.raise_on_error">
<codeclass="sig-name descname">raise_on_error</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.Response.raise_on_error"title="Permalink to this definition">¶</a></dt>
<dd><p>Raise an <aclass="reference external"href="https://docs.python.org/3.7/library/exceptions.html#Exception"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Exception</span></code></a> if the Response is an error, do nothing otherwise.</p>
</dd></dl>
<dlclass="method">
<dtid="royalnet.network.Response.to_dict">
<codeclass="sig-name descname">to_dict</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ dict<aclass="headerlink"href="#royalnet.network.Response.to_dict"title="Permalink to this definition">¶</a></dt>
<dd><p>Prepare the Response to be sent by converting it to a JSONable <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#dict"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dict</span></code></a>.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.network.ResponseSuccess">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">ResponseSuccess</code><spanclass="sig-paren">(</span><emclass="sig-param">data: Optional[dict] = None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.ResponseSuccess"title="Permalink to this definition">¶</a></dt>
<dd><p>A response to a successful <aclass="reference internal"href="#royalnet.network.Request"title="royalnet.network.Request"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Request</span></code></a>.</p>
<codeclass="sig-name descname">raise_on_error</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.ResponseSuccess.raise_on_error"title="Permalink to this definition">¶</a></dt>
<dd><p>Raise an <aclass="reference external"href="https://docs.python.org/3.7/library/exceptions.html#Exception"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Exception</span></code></a> if the Response is an error, do nothing otherwise.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.network.ResponseError">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.network.</code><codeclass="sig-name descname">ResponseError</code><spanclass="sig-paren">(</span><emclass="sig-param">name: str</em>, <emclass="sig-param">description: str</em>, <emclass="sig-param">extra_info: Optional[dict] = None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.ResponseError"title="Permalink to this definition">¶</a></dt>
<dd><p>A response to a invalid <aclass="reference internal"href="#royalnet.network.Request"title="royalnet.network.Request"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Request</span></code></a>.</p>
<codeclass="sig-name descname">raise_on_error</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.network.ResponseError.raise_on_error"title="Permalink to this definition">¶</a></dt>
<dd><p>Raise an <aclass="reference external"href="https://docs.python.org/3.7/library/exceptions.html#Exception"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Exception</span></code></a> if the Response is an error, do nothing otherwise.</p>
</dd></dl>
</dd></dl>
</div>
<divclass="section"id="module-royalnet.utils">
<spanid="utils"></span><h2>Utils<aclass="headerlink"href="#module-royalnet.utils"title="Permalink to this headline">¶</a></h2>
<p>Miscellaneous useful functions and classes.</p>
<dlclass="function">
<dtid="royalnet.utils.asyncify">
<emclass="property">async </em><codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">asyncify</code><spanclass="sig-paren">(</span><emclass="sig-param">function: Callable</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.asyncify"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a function into a coroutine.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>The coroutine cannot be cancelled, and any attempts to do so will result in unexpected outputs.</p>
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">safeformat</code><spanclass="sig-paren">(</span><emclass="sig-param">string: str</em>, <emclass="sig-param">**words: str</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.safeformat"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">cdj</code><spanclass="sig-paren">(</span><emclass="sig-param">class_: Any</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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>class_</strong>– The object that you want to dict-ify.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The class dict.</p>
</dd>
</dl>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>You can’t dict-ify classes with <codeclass="docutils literal notranslate"><spanclass="pre">__slots__</span></code>!</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.sleep_until">
<emclass="property">async </em><codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">sleep_until</code><spanclass="sig-paren">(</span><emclass="sig-param">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>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Accurate only to seconds.</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.plusformat">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">plusformat</code><spanclass="sig-paren">(</span><emclass="sig-param">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 <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#str"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code></a>, prepending a <codeclass="docutils literal notranslate"><spanclass="pre">+</span></code> if it’s greater than 0.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>i</strong>– the <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 convert.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name 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="sig-name descname">message_type</code><emclass="property"> = NotImplemented</em><aclass="headerlink"href="#royalnet.utils.NetworkHandler.message_type"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.andformat">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">andformat</code><spanclass="sig-paren">(</span><emclass="sig-param">l: List[str], middle=', ', final=' and '</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.andformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#list"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">list</span></code></a> to a <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#str"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code></a> by adding <codeclass="docutils literal notranslate"><spanclass="pre">final</span></code> between the last two elements and <codeclass="docutils literal notranslate"><spanclass="pre">middle</span></code> between the others.</p>
<li><p><strong>middle</strong>– the <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#str"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code></a> to be added between the middle elements.</p></li>
<li><p><strong>final</strong>– the <aclass="reference external"href="https://docs.python.org/3.7/library/stdtypes.html#str"title="(in Python v3.7)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">str</span></code></a> to be added between the last two elements.</p></li>
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">fileformat</code><spanclass="sig-paren">(</span><emclass="sig-param">string: str</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.fileformat"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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>string</strong>– the input string.</p>
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">ytdldateformat</code><spanclass="sig-paren">(</span><emclass="sig-param">string: Optional[str], separator: str = '-'</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.ytdldateformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the weird date string returned by <codeclass="docutils literal notranslate"><spanclass="pre">youtube-dl</span></code> into the <codeclass="docutils literal notranslate"><spanclass="pre">YYYY-MM-DD</span></code> format.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong>– the input string, in the <codeclass="docutils literal notranslate"><spanclass="pre">YYYYMMDD</span></code> format.</p></li>
<li><p><strong>separator</strong>– the string to add between the years, the months and the days. Defaults to <codeclass="docutils literal notranslate"><spanclass="pre">-</span></code>.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The resulting string, in the format <codeclass="docutils literal notranslate"><spanclass="pre">YYYY-MM-DD</span></code> format.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.numberemojiformat">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">numberemojiformat</code><spanclass="sig-paren">(</span><emclass="sig-param">l: List[str]</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.numberemojiformat"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="royalnet.utils.telegram_escape">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">telegram_escape</code><spanclass="sig-paren">(</span><emclass="sig-param">string: str</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.telegram_escape"title="Permalink to this definition">¶</a></dt>
<dd><p>Escape a string to be sent through Telegram, and format it using RoyalCode.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Currently escapes everything, even items in code blocks.</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.discord_escape">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">discord_escape</code><spanclass="sig-paren">(</span><emclass="sig-param">string: str</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.discord_escape"title="Permalink to this definition">¶</a></dt>
<dd><p>Escape a string to be sent through Discord, and format it using RoyalCode.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Currently escapes everything, even items in code blocks.</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="royalnet.utils.splitstring">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">splitstring</code><spanclass="sig-paren">(</span><emclass="sig-param">s: str</em>, <emclass="sig-param">max: int</em><spanclass="sig-paren">)</span>→ List[str]<aclass="headerlink"href="#royalnet.utils.splitstring"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="royalnet.utils.parse_5etools_entry">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">parse_5etools_entry</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#royalnet.utils.parse_5etools_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="royalnet.utils.ordinalformat">
<codeclass="sig-prename descclassname">royalnet.utils.</code><codeclass="sig-name descname">ordinalformat</code><spanclass="sig-paren">(</span><emclass="sig-param">number: int</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.utils.ordinalformat"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</div>
<divclass="section"id="module-royalnet.web">
<spanid="web"></span><h2>Web<aclass="headerlink"href="#module-royalnet.web"title="Permalink to this headline">¶</a></h2>
<dlclass="function">
<dtid="royalnet.web.create_app">
<codeclass="sig-prename descclassname">royalnet.web.</code><codeclass="sig-name descname">create_app</code><spanclass="sig-paren">(</span><emclass="sig-param">config_obj: Type, blueprints: List[royalnet.web.royalprint.Royalprint]</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.web.create_app"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">flask.Flask</span></code> application object.</p>
<p>Gets the <codeclass="docutils literal notranslate"><spanclass="pre">app.secret_key</span></code> from the <codeclass="docutils literal notranslate"><spanclass="pre">SECRET_KEY</span></code> envvar.</p>
<p>Also requires a <codeclass="docutils literal notranslate"><spanclass="pre">DB_PATH</span></code> key in <codeclass="docutils literal notranslate"><spanclass="pre">config_obj</span></code> to initialize the database connection.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>The code for this class was written at 1 AM, and I have no clue of how and why it works or even if it really does work.
Use with caution?</p>
</div>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>config_obj</strong>– The object to be passed to <codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">flask.Flask.config.from_object()</span></code>.</p></li>
<li><p><strong>blueprints</strong>– A list of blueprints to be registered to the application.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The created <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">flask.Flask</span></code>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="class">
<dtid="royalnet.web.Royalprint">
<emclass="property">class </em><codeclass="sig-prename descclassname">royalnet.web.</code><codeclass="sig-name descname">Royalprint</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">import_name</em>, <emclass="sig-param">static_folder=None</em>, <emclass="sig-param">static_url_path=None</em>, <emclass="sig-param">template_folder=None</em>, <emclass="sig-param">url_prefix=None</em>, <emclass="sig-param">subdomain=None</em>, <emclass="sig-param">url_defaults=None</em>, <emclass="sig-param">root_path=None</em>, <emclass="sig-param">required_tables: Optional[set] = None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.web.Royalprint"title="Permalink to this definition">¶</a></dt>
<spanid="error"></span><h2>Error<aclass="headerlink"href="#module-royalnet.error"title="Permalink to this headline">¶</a></h2>
<dlclass="exception">
<dtid="royalnet.error.RoyalnetRequestError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.error.</code><codeclass="sig-name descname">RoyalnetRequestError</code><spanclass="sig-paren">(</span><emclass="sig-param">error: ResponseError</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#royalnet.error.RoyalnetRequestError"title="Permalink to this definition">¶</a></dt>
<dd><p>An error was raised while handling the Royalnet request.</p>
<p>This exception contains the <aclass="reference internal"href="#royalnet.network.ResponseError"title="royalnet.network.ResponseError"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.ResponseError</span></code></a> that was returned by the other Link.</p>
<emclass="property">property </em><codeclass="sig-name descname">args</code><aclass="headerlink"href="#royalnet.error.RoyalnetRequestError.args"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">royalnet.error.</code><codeclass="sig-name descname">RoyalnetResponseError</code><aclass="headerlink"href="#royalnet.error.RoyalnetResponseError"title="Permalink to this definition">¶</a></dt>
<dd><p>The <aclass="reference internal"href="#royalnet.network.Response"title="royalnet.network.Response"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">royalnet.network.Response</span></code></a> that was received is invalid.</p>
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>.