1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Update docs

This commit is contained in:
Steffo 2019-04-24 14:09:11 +02:00
parent 6983d40b19
commit 576f628ab0
21 changed files with 118 additions and 177 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -335,12 +335,6 @@
<dt id="royalnet.audio.YtdlFile"> <dt id="royalnet.audio.YtdlFile">
<em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">YtdlFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">YtdlFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile" title="Permalink to this definition"></a></dt>
<dd><p>A wrapper around a youtube_dl downloaded file.</p> <dd><p>A wrapper around a youtube_dl downloaded file.</p>
<dl class="method">
<dt id="royalnet.audio.YtdlFile.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.audio.YtdlFile._stop_download"> <dt id="royalnet.audio.YtdlFile._stop_download">
<code class="descname">_stop_download</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile._stop_download" title="Permalink to this definition"></a></dt> <code class="descname">_stop_download</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile._stop_download" title="Permalink to this definition"></a></dt>
@ -392,13 +386,7 @@
<dl class="class"> <dl class="class">
<dt id="royalnet.audio.RoyalPCMFile"> <dt id="royalnet.audio.RoyalPCMFile">
<em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">RoyalPCMFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMFile" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">RoyalPCMFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMFile" title="Permalink to this definition"></a></dt>
<dd><dl class="method"> <dd><dl class="attribute">
<dt id="royalnet.audio.RoyalPCMFile.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="attribute">
<dt id="royalnet.audio.RoyalPCMFile.audio_filename"> <dt id="royalnet.audio.RoyalPCMFile.audio_filename">
<code class="descname">audio_filename</code><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.audio_filename" title="Permalink to this definition"></a></dt> <code class="descname">audio_filename</code><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.audio_filename" title="Permalink to this definition"></a></dt>
<dd><p>Returns: <dd><p>Returns:

View file

@ -161,16 +161,10 @@
<dt id="royalnet.bots.TelegramBot"> <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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot" title="Permalink to this definition"></a></dt> <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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</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> <dd><p>A bot that connects to <a class="reference external" href="https://telegram.org/">Telegram</a>.</p>
<dl class="method">
<dt id="royalnet.bots.TelegramBot.__init__">
<code class="descname">__init__</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.TelegramBot._call_factory"> <dt id="royalnet.bots.TelegramBot._call_factory">
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.TelegramBot._call_factory" title="Permalink to this definition"></a></dt> <code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.TelegramBot._call_factory" title="Permalink to this definition"></a></dt>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p> <dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
@ -181,7 +175,8 @@
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.TelegramBot._init_client"> <dt id="royalnet.bots.TelegramBot._init_client">
<code class="descname">_init_client</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot._init_client" title="Permalink to this definition"></a></dt> <code class="descname">_init_client</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot._init_client" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd><p>Create the <a class="reference external" href="https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot" title="(in Python Telegram Bot v11.1)"><code class="xref py py-class docutils literal notranslate"><span class="pre">telegram.Bot</span></code></a>, and set the starting offset.</p>
</dd></dl>
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.bots.TelegramBot.botfather_command_string"> <dt id="royalnet.bots.TelegramBot.botfather_command_string">
@ -204,51 +199,40 @@
<dl class="class"> <dl class="class">
<dt id="royalnet.bots.TelegramConfig"> <dt id="royalnet.bots.TelegramConfig">
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">TelegramConfig</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramConfig" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">TelegramConfig</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramConfig" title="Permalink to this definition"></a></dt>
<dd><p>The specific configuration to be used for <span class="xref std std-ref">royalnet.database.TelegramBot</span>.</p> <dd><p>The specific configuration to be used for <code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.TelegramBot</span></code>.</p>
<dl class="method">
<dt id="royalnet.bots.TelegramConfig.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramConfig.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl> </dd></dl>
<dl class="class"> <dl class="class">
<dt id="royalnet.bots.DiscordBot"> <dt id="royalnet.bots.DiscordBot">
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">DiscordBot</code><span class="sig-paren">(</span><em>*</em>, <em>discord_config: royalnet.bots.discord.DiscordConfig</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">DiscordBot</code><span class="sig-paren">(</span><em>*</em>, <em>discord_config: royalnet.bots.discord.DiscordConfig</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot" title="Permalink to this definition"></a></dt>
<dd><p>A bot that connects to <a class="reference external" href="https://discordapp.com/">Discord</a>.</p> <dd><p>A bot that connects to <a class="reference external" href="https://discordapp.com/">Discord</a>.</p>
<dl class="method">
<dt id="royalnet.bots.DiscordBot.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>*</em>, <em>discord_config: royalnet.bots.discord.DiscordConfig</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot._bot_factory"> <dt id="royalnet.bots.DiscordBot._bot_factory">
<code class="descname">_bot_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[discord.client.Client]<a class="headerlink" href="#royalnet.bots.DiscordBot._bot_factory" title="Permalink to this definition"></a></dt> <code class="descname">_bot_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[discord.client.Client]<a class="headerlink" href="#royalnet.bots.DiscordBot._bot_factory" title="Permalink to this definition"></a></dt>
<dd><p>Create a new DiscordClient class based on this DiscordBot.</p> <dd><p>Create a custom DiscordClient class inheriting from <a class="reference external" href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Client" title="(in discord.py v1.1.0a)"><code class="xref py py-class docutils literal notranslate"><span class="pre">discord.Client</span></code></a>.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot._call_factory"> <dt id="royalnet.bots.DiscordBot._call_factory">
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.DiscordBot._call_factory" title="Permalink to this definition"></a></dt> <code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.DiscordBot._call_factory" title="Permalink to this definition"></a></dt>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p> <dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot._init_client"> <dt id="royalnet.bots.DiscordBot._init_client">
<code class="descname">_init_client</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot._init_client" title="Permalink to this definition"></a></dt> <code class="descname">_init_client</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot._init_client" title="Permalink to this definition"></a></dt>
<dd><p>Create a bot instance.</p> <dd><p>Create an instance of the DiscordClient class created in <code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.bots.discord._bot_factory()</span></code>.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot._init_voice"> <dt id="royalnet.bots.DiscordBot._init_voice">
<code class="descname">_init_voice</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot._init_voice" title="Permalink to this definition"></a></dt> <code class="descname">_init_voice</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot._init_voice" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd><p>Initialize the variables needed for the connection to voice chat.</p>
</dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot.add_to_music_data"> <dt id="royalnet.bots.DiscordBot.add_to_music_data">
<code class="descname">add_to_music_data</code><span class="sig-paren">(</span><em>audio_sources: List[discord.player.AudioSource], guild: discord.guild.Guild</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.add_to_music_data" title="Permalink to this definition"></a></dt> <code class="descname">add_to_music_data</code><span class="sig-paren">(</span><em>audio_sources: List[royalnet.audio.royalpcmaudio.RoyalPCMAudio], guild: discord.guild.Guild</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.add_to_music_data" title="Permalink to this definition"></a></dt>
<dd><p>Add a file to the corresponding music_data object.</p> <dd><p>Add a file to the corresponding music_data object.</p>
</dd></dl> </dd></dl>
@ -266,72 +250,64 @@
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot.run"> <dt id="royalnet.bots.DiscordBot.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.run" title="Permalink to this definition"></a></dt> <code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.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> <dd><p>Login to Discord, then run the bot.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.DiscordBot.update_activity_with_source_title"> <dt id="royalnet.bots.DiscordBot.update_activity_with_source_title">
<code class="descname">update_activity_with_source_title</code><span class="sig-paren">(</span><em>rpa: Optional[royalnet.audio.royalpcmaudio.RoyalPCMAudio] = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.update_activity_with_source_title" title="Permalink to this definition"></a></dt> <code class="descname">update_activity_with_source_title</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot.update_activity_with_source_title" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd><p>Change the bots presence (using <code class="xref py py-func docutils literal notranslate"><span class="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>
</dd></dl>
</dd></dl> </dd></dl>
<dl class="class"> <dl class="class">
<dt id="royalnet.bots.DiscordConfig"> <dt id="royalnet.bots.DiscordConfig">
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">DiscordConfig</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordConfig" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">DiscordConfig</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordConfig" title="Permalink to this definition"></a></dt>
<dd><p>The specific configuration to be used for <span class="xref std std-ref">royalnet.database.DiscordBot</span>.</p> <dd><p>The specific configuration to be used for <code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.DiscordBot</span></code>.</p>
<dl class="method">
<dt id="royalnet.bots.DiscordConfig.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordConfig.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl> </dd></dl>
<dl class="class"> <dl class="class">
<dt id="royalnet.bots.GenericBot"> <dt id="royalnet.bots.GenericBot">
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">GenericBot</code><span class="sig-paren">(</span><em>*</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">GenericBot</code><span class="sig-paren">(</span><em>*</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot" title="Permalink to this definition"></a></dt>
<dd><p>A generic bot class, to be used as base for the other more specific classes, such as <span class="xref std std-ref">royalnet.bots.TelegramBot</span> and <span class="xref std std-ref">royalnet.bots.DiscordBot</span>.</p> <dd><p>A generic bot class, to be used as base for the other more specific classes, such as <span class="xref std std-ref">royalnet.bots.TelegramBot</span> and <span class="xref std std-ref">royalnet.bots.DiscordBot</span>.</p>
<dl class="method">
<dt id="royalnet.bots.GenericBot.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>*</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] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em>, <em>error_command: Type[royalnet.utils.command.Command] = &lt;class 'royalnet.commands.null.NullCommand'&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot._call_factory"> <dt id="royalnet.bots.GenericBot._call_factory">
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.GenericBot._call_factory" title="Permalink to this definition"></a></dt> <code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.GenericBot._call_factory" title="Permalink to this definition"></a></dt>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p> <dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot._init_commands"> <dt id="royalnet.bots.GenericBot._init_commands">
<code class="descname">_init_commands</code><span class="sig-paren">(</span><em>command_prefix: str, commands: List[Type[royalnet.utils.command.Command]], missing_command: Type[royalnet.utils.command.Command], error_command: Type[royalnet.utils.command.Command]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_commands" title="Permalink to this definition"></a></dt> <code class="descname">_init_commands</code><span class="sig-paren">(</span><em>command_prefix: str, commands: List[Type[royalnet.utils.command.Command]], missing_command: Type[royalnet.utils.command.Command], error_command: Type[royalnet.utils.command.Command]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_commands" title="Permalink to this definition"></a></dt>
<dd><p>Generate the commands dictionary required to handle incoming messages, and the network_handlers dictionary required to handle incoming requests.</p> <dd><p>Generate the <code class="docutils literal notranslate"><span class="pre">commands</span></code> dictionary required to handle incoming messages, and the <code class="docutils literal notranslate"><span class="pre">network_handlers</span></code> dictionary required to handle incoming requests.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot._init_database"> <dt id="royalnet.bots.GenericBot._init_database">
<code class="descname">_init_database</code><span class="sig-paren">(</span><em>commands: List[Type[royalnet.utils.command.Command]], database_config: royalnet.database.databaseconfig.DatabaseConfig</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_database" title="Permalink to this definition"></a></dt> <code class="descname">_init_database</code><span class="sig-paren">(</span><em>commands: List[Type[royalnet.utils.command.Command]], database_config: royalnet.database.databaseconfig.DatabaseConfig</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_database" title="Permalink to this definition"></a></dt>
<dd><p>Connect to the database, and create the missing tables required by the selected commands.</p> <dd><p>Create an <code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Alchemy</span></code> with the tables required by the commands. Then, find the chain that links the <code class="docutils literal notranslate"><span class="pre">master_table</span></code> to the <code class="docutils literal notranslate"><span class="pre">identity_table</span></code>.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot._init_royalnet"> <dt id="royalnet.bots.GenericBot._init_royalnet">
<code class="descname">_init_royalnet</code><span class="sig-paren">(</span><em>royalnet_config: royalnet.network.royalnetconfig.RoyalnetConfig</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_royalnet" title="Permalink to this definition"></a></dt> <code class="descname">_init_royalnet</code><span class="sig-paren">(</span><em>royalnet_config: royalnet.network.royalnetconfig.RoyalnetConfig</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_royalnet" title="Permalink to this definition"></a></dt>
<dd><p>Create a RoyalnetLink, and run it as a task.</p> <dd><p>Create 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 run it as a <a class="reference external" href="https://docs.python.org/3.7/library/asyncio-task.html#asyncio.Task" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Task</span></code></a>.</p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot._network_handler"> <dt id="royalnet.bots.GenericBot._network_handler">
<code class="descname">_network_handler</code><span class="sig-paren">(</span><em>message: royalnet.network.messages.Message</em><span class="sig-paren">)</span> &#x2192; royalnet.network.messages.Message<a class="headerlink" href="#royalnet.bots.GenericBot._network_handler" title="Permalink to this definition"></a></dt> <code class="descname">_network_handler</code><span class="sig-paren">(</span><em>message: royalnet.network.messages.Message</em><span class="sig-paren">)</span> &#x2192; royalnet.network.messages.Message<a class="headerlink" href="#royalnet.bots.GenericBot._network_handler" title="Permalink to this definition"></a></dt>
<dd><p>Handle a single Message received from the RoyalnetLink</p> <dd><p>Handle a single <a class="reference internal" href="network.html#royalnet.network.Message" title="royalnet.network.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Message</span></code></a> received from the <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></p>
</dd></dl> </dd></dl>
<dl class="method"> <dl class="method">
<dt id="royalnet.bots.GenericBot.call"> <dt id="royalnet.bots.GenericBot.call">
<code class="descname">call</code><span class="sig-paren">(</span><em>command_name: str</em>, <em>channel</em>, <em>parameters: List[str] = None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot.call" title="Permalink to this definition"></a></dt> <code class="descname">call</code><span class="sig-paren">(</span><em>command_name: str</em>, <em>channel</em>, <em>parameters: List[str] = None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot.call" title="Permalink to this definition"></a></dt>
<dd><p>Call a command by its string, or missing_command if it doesnt exists, or error_command if an exception is raised during the execution.</p> <dd><p>Call the command with the specified name.</p>
<p>If it doesnt exist, call <code class="docutils literal notranslate"><span class="pre">self.missing_command</span></code>.</p>
<p>If an exception is raised during the execution of the command, call <code class="docutils literal notranslate"><span class="pre">self.error_command</span></code>.</p>
</dd></dl> </dd></dl>
<dl class="attribute"> <dl class="attribute">

View file

@ -205,12 +205,6 @@
<dt id="royalnet.database.DatabaseConfig"> <dt id="royalnet.database.DatabaseConfig">
<em class="property">class </em><code class="descclassname">royalnet.database.</code><code class="descname">DatabaseConfig</code><span class="sig-paren">(</span><em>database_uri: str, master_table: Type[CT_co], identity_table: Type[CT_co], identity_column_name: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.database.DatabaseConfig" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.database.</code><code class="descname">DatabaseConfig</code><span class="sig-paren">(</span><em>database_uri: str, master_table: Type[CT_co], identity_table: Type[CT_co], identity_column_name: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.database.DatabaseConfig" title="Permalink to this definition"></a></dt>
<dd><p>The configuration to be used for the <span class="xref std std-ref">royalnet.database.Alchemy</span> component of <span class="xref std std-ref">royalnet.bots.GenericBot</span>.</p> <dd><p>The configuration to be used for the <span class="xref std std-ref">royalnet.database.Alchemy</span> component of <span class="xref std std-ref">royalnet.bots.GenericBot</span>.</p>
<dl class="method">
<dt id="royalnet.database.DatabaseConfig.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>database_uri: str, master_table: Type[CT_co], identity_table: Type[CT_co], identity_column_name: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.database.DatabaseConfig.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl> </dd></dl>
<div class="section" id="module-royalnet.database.tables"> <div class="section" id="module-royalnet.database.tables">
@ -265,7 +259,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.Telegram.royal"> <dt id="royalnet.database.tables.Telegram.royal">
<code class="descname">royal</code><em class="property"> = &lt;RelationshipProperty at 0x6fa26f0; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70300; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Telegram.royal" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -295,7 +289,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.Diario.creator"> <dt id="royalnet.database.tables.Diario.creator">
<code class="descname">creator</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2270; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70348; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Diario.creator" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -320,7 +314,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.Diario.quoted_account"> <dt id="royalnet.database.tables.Diario.quoted_account">
<code class="descname">quoted_account</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2c90; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70978; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Diario.quoted_account" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -355,7 +349,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.Alias.royal"> <dt id="royalnet.database.tables.Alias.royal">
<code class="descname">royal</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2588; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70198; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Alias.royal" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -370,7 +364,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> <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"> <dd><dl class="attribute">
<dt id="royalnet.database.tables.ActiveKvGroup.group"> <dt id="royalnet.database.tables.ActiveKvGroup.group">
<code class="descname">group</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2fa8; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a701e0; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.group" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -380,7 +374,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.ActiveKvGroup.royal"> <dt id="royalnet.database.tables.ActiveKvGroup.royal">
<code class="descname">royal</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2d20; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70b70; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.royal" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -395,7 +389,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> <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"> <dd><dl class="attribute">
<dt id="royalnet.database.tables.Keyvalue.group"> <dt id="royalnet.database.tables.Keyvalue.group">
<code class="descname">group</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2270; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a709c0; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Keyvalue.group" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
@ -450,7 +444,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.database.tables.Discord.royal"> <dt id="royalnet.database.tables.Discord.royal">
<code class="descname">royal</code><em class="property"> = &lt;RelationshipProperty at 0x6fa2f18; no key&gt;</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"> = &lt;RelationshipProperty at 0x7a70a08; no key&gt;</em><a class="headerlink" href="#royalnet.database.tables.Discord.royal" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
<dl class="attribute"> <dl class="attribute">

View file

@ -187,46 +187,16 @@
<li><a href="audio.html#royalnet.audio.Pool.__init__">(royalnet.audio.Pool method)</a> <li><a href="audio.html#royalnet.audio.Pool.__init__">(royalnet.audio.Pool method)</a>
</li> </li>
<li><a href="audio.html#royalnet.audio.RoyalPCMAudio.__init__">(royalnet.audio.RoyalPCMAudio method)</a> <li><a href="audio.html#royalnet.audio.RoyalPCMAudio.__init__">(royalnet.audio.RoyalPCMAudio method)</a>
</li>
<li><a href="audio.html#royalnet.audio.RoyalPCMFile.__init__">(royalnet.audio.RoyalPCMFile method)</a>
</li>
<li><a href="audio.html#royalnet.audio.YtdlFile.__init__">(royalnet.audio.YtdlFile method)</a>
</li> </li>
<li><a href="audio.html#royalnet.audio.YtdlInfo.__init__">(royalnet.audio.YtdlInfo method)</a> <li><a href="audio.html#royalnet.audio.YtdlInfo.__init__">(royalnet.audio.YtdlInfo method)</a>
</li>
<li><a href="bots.html#royalnet.bots.DiscordBot.__init__">(royalnet.bots.DiscordBot method)</a>
</li>
<li><a href="bots.html#royalnet.bots.DiscordConfig.__init__">(royalnet.bots.DiscordConfig method)</a>
</li>
<li><a href="bots.html#royalnet.bots.GenericBot.__init__">(royalnet.bots.GenericBot method)</a>
</li>
<li><a href="bots.html#royalnet.bots.TelegramBot.__init__">(royalnet.bots.TelegramBot method)</a>
</li>
<li><a href="bots.html#royalnet.bots.TelegramConfig.__init__">(royalnet.bots.TelegramConfig method)</a>
</li> </li>
<li><a href="database.html#royalnet.database.Alchemy.__init__">(royalnet.database.Alchemy method)</a> <li><a href="database.html#royalnet.database.Alchemy.__init__">(royalnet.database.Alchemy method)</a>
</li>
<li><a href="database.html#royalnet.database.DatabaseConfig.__init__">(royalnet.database.DatabaseConfig method)</a>
</li>
<li><a href="network.html#royalnet.network.NetworkError.__init__">(royalnet.network.NetworkError method)</a>
</li> </li>
<li><a href="network.html#royalnet.network.Package.__init__">(royalnet.network.Package method)</a> <li><a href="network.html#royalnet.network.Package.__init__">(royalnet.network.Package method)</a>
</li> </li>
<li><a href="network.html#royalnet.network.RequestError.__init__">(royalnet.network.RequestError method)</a> <li><a href="network.html#royalnet.network.RequestError.__init__">(royalnet.network.RequestError method)</a>
</li>
<li><a href="network.html#royalnet.network.RoyalnetConfig.__init__">(royalnet.network.RoyalnetConfig method)</a>
</li>
<li><a href="network.html#royalnet.network.RoyalnetLink.__init__">(royalnet.network.RoyalnetLink method)</a>
</li>
<li><a href="network.html#royalnet.network.RoyalnetServer.__init__">(royalnet.network.RoyalnetServer method)</a>
</li>
<li><a href="network.html#royalnet.network.ServerErrorMessage.__init__">(royalnet.network.ServerErrorMessage method)</a>
</li>
<li><a href="utils.html#royalnet.utils.Call.__init__">(royalnet.utils.Call method)</a>
</li> </li>
</ul></li> </ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="bots.html#royalnet.bots.DiscordBot._bot_factory">_bot_factory() (royalnet.bots.DiscordBot method)</a> <li><a href="bots.html#royalnet.bots.DiscordBot._bot_factory">_bot_factory() (royalnet.bots.DiscordBot method)</a>
</li> </li>
<li><a href="bots.html#royalnet.bots.DiscordBot._call_factory">_call_factory() (royalnet.bots.DiscordBot method)</a> <li><a href="bots.html#royalnet.bots.DiscordBot._call_factory">_call_factory() (royalnet.bots.DiscordBot method)</a>
@ -237,6 +207,8 @@
<li><a href="bots.html#royalnet.bots.TelegramBot._call_factory">(royalnet.bots.TelegramBot method)</a> <li><a href="bots.html#royalnet.bots.TelegramBot._call_factory">(royalnet.bots.TelegramBot method)</a>
</li> </li>
</ul></li> </ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="database.html#royalnet.database.Alchemy._create_tables">_create_tables() (royalnet.database.Alchemy method)</a> <li><a href="database.html#royalnet.database.Alchemy._create_tables">_create_tables() (royalnet.database.Alchemy method)</a>
</li> </li>
<li><a href="audio.html#royalnet.audio.Playlist._generate_generator">_generate_generator() (royalnet.audio.Playlist method)</a> <li><a href="audio.html#royalnet.audio.Playlist._generate_generator">_generate_generator() (royalnet.audio.Playlist method)</a>
@ -629,9 +601,11 @@
<td style="width: 33%; vertical-align: top;"><ul> <td style="width: 33%; vertical-align: top;"><ul>
<li><a href="commands.html#royalnet.commands.RageCommand">RageCommand (class in royalnet.commands)</a> <li><a href="commands.html#royalnet.commands.RageCommand">RageCommand (class in royalnet.commands)</a>
</li> </li>
<li><a href="network.html#royalnet.network.RequestError.raise_on_error">raise_on_error() (royalnet.network.RequestError method)</a> <li><a href="network.html#royalnet.network.Reply.raise_on_error">raise_on_error() (royalnet.network.Reply method)</a>
<ul> <ul>
<li><a href="network.html#royalnet.network.RequestError.raise_on_error">(royalnet.network.RequestError method)</a>
</li>
<li><a href="network.html#royalnet.network.RequestSuccessful.raise_on_error">(royalnet.network.RequestSuccessful method)</a> <li><a href="network.html#royalnet.network.RequestSuccessful.raise_on_error">(royalnet.network.RequestSuccessful method)</a>
</li> </li>
</ul></li> </ul></li>
@ -642,6 +616,8 @@
<li><a href="database.html#royalnet.database.relationshiplinkchain">relationshiplinkchain() (in module royalnet.database)</a> <li><a href="database.html#royalnet.database.relationshiplinkchain">relationshiplinkchain() (in module royalnet.database)</a>
</li> </li>
<li><a href="commands.html#royalnet.commands.ReminderCommand">ReminderCommand (class in royalnet.commands)</a> <li><a href="commands.html#royalnet.commands.ReminderCommand">ReminderCommand (class in royalnet.commands)</a>
</li>
<li><a href="network.html#royalnet.network.Reply">Reply (class in royalnet.network)</a>
</li> </li>
<li><a href="network.html#royalnet.network.Package.reply">reply() (royalnet.network.Package method)</a> <li><a href="network.html#royalnet.network.Package.reply">reply() (royalnet.network.Package method)</a>

View file

@ -167,12 +167,6 @@
<dt id="royalnet.network.ServerErrorMessage"> <dt id="royalnet.network.ServerErrorMessage">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">ServerErrorMessage</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.ServerErrorMessage" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">ServerErrorMessage</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.ServerErrorMessage" title="Permalink to this definition"></a></dt>
<dd><p>Something went wrong in the connection to the <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p> <dd><p>Something went wrong in the connection to the <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
<dl class="method">
<dt id="royalnet.network.ServerErrorMessage.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.ServerErrorMessage.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl> </dd></dl>
<dl class="class"> <dl class="class">
@ -198,12 +192,6 @@
<dt id="royalnet.network.RoyalnetLink"> <dt id="royalnet.network.RoyalnetLink">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetLink</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>secret: str</em>, <em>link_type: str</em>, <em>request_handler</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetLink</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>secret: str</em>, <em>link_type: str</em>, <em>request_handler</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink" title="Permalink to this definition"></a></dt>
<dd><dl class="method"> <dd><dl class="method">
<dt id="royalnet.network.RoyalnetLink.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>secret: str</em>, <em>link_type: str</em>, <em>request_handler</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.connect"> <dt id="royalnet.network.RoyalnetLink.connect">
<code class="descname">connect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.connect" title="Permalink to this definition"></a></dt> <code class="descname">connect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.connect" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
@ -238,18 +226,13 @@
<dl class="exception"> <dl class="exception">
<dt id="royalnet.network.NetworkError"> <dt id="royalnet.network.NetworkError">
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NetworkError</code><span class="sig-paren">(</span><em>error_msg: royalnet.network.messages.ServerErrorMessage</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.NetworkError" title="Permalink to this definition"></a></dt> <em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NetworkError</code><span class="sig-paren">(</span><em>error_msg: royalnet.network.messages.ServerErrorMessage</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.NetworkError" title="Permalink to this definition"></a></dt>
<dd><dl class="method"> <dd></dd></dl>
<dt id="royalnet.network.NetworkError.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>error_msg: royalnet.network.messages.ServerErrorMessage</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.NetworkError.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl>
<dl class="exception"> <dl class="exception">
<dt id="royalnet.network.NotConnectedError"> <dt id="royalnet.network.NotConnectedError">
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NotConnectedError</code><a class="headerlink" href="#royalnet.network.NotConnectedError" title="Permalink to this definition"></a></dt> <em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NotConnectedError</code><a class="headerlink" href="#royalnet.network.NotConnectedError" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd><p>The <a class="reference internal" href="#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> is not connected to a <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
</dd></dl>
<dl class="exception"> <dl class="exception">
<dt id="royalnet.network.NotIdentifiedError"> <dt id="royalnet.network.NotIdentifiedError">
@ -308,12 +291,6 @@
<dt id="royalnet.network.RoyalnetServer"> <dt id="royalnet.network.RoyalnetServer">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetServer</code><span class="sig-paren">(</span><em>address: str</em>, <em>port: int</em>, <em>required_secret: str</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetServer</code><span class="sig-paren">(</span><em>address: str</em>, <em>port: int</em>, <em>required_secret: str</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer" title="Permalink to this definition"></a></dt>
<dd><dl class="method"> <dd><dl class="method">
<dt id="royalnet.network.RoyalnetServer.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>address: str</em>, <em>port: int</em>, <em>required_secret: str</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.find_client"> <dt id="royalnet.network.RoyalnetServer.find_client">
<code class="descname">find_client</code><span class="sig-paren">(</span><em>*</em>, <em>nid: str = None</em>, <em>link_type: str = None</em><span class="sig-paren">)</span> &#x2192; List[royalnet.network.royalnetserver.ConnectedClient]<a class="headerlink" href="#royalnet.network.RoyalnetServer.find_client" title="Permalink to this definition"></a></dt> <code class="descname">find_client</code><span class="sig-paren">(</span><em>*</em>, <em>nid: str = None</em>, <em>link_type: str = None</em><span class="sig-paren">)</span> &#x2192; List[royalnet.network.royalnetserver.ConnectedClient]<a class="headerlink" href="#royalnet.network.RoyalnetServer.find_client" title="Permalink to this definition"></a></dt>
<dd></dd></dl> <dd></dd></dl>
@ -395,10 +372,17 @@
<dl class="class"> <dl class="class">
<dt id="royalnet.network.RoyalnetConfig"> <dt id="royalnet.network.RoyalnetConfig">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetConfig</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>master_secret: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetConfig" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetConfig</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>master_secret: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetConfig" title="Permalink to this definition"></a></dt>
<dd><dl class="method"> <dd></dd></dl>
<dt id="royalnet.network.RoyalnetConfig.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>master_secret: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetConfig.__init__" title="Permalink to this definition"></a></dt> <dl class="class">
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p> <dt id="royalnet.network.Reply">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">Reply</code><a class="headerlink" href="#royalnet.network.Reply" title="Permalink to this definition"></a></dt>
<dd><p>A reply to a request sent through the Royalnet.</p>
<dl class="method">
<dt id="royalnet.network.Reply.raise_on_error">
<code class="descname">raise_on_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.Reply.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 A <code class="xref py py-exc docutils literal notranslate"><span class="pre">RoyalnetError</span></code>, if the Reply is an error, otherwise, nothing.:</p>
</dd></dl> </dd></dl>
</dd></dl> </dd></dl>

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -165,12 +165,6 @@
<dt id="royalnet.utils.Call"> <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> <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. Still an abstract class, subbots should create a new call 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>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<dl class="attribute"> <dl class="attribute">
<dt id="royalnet.utils.Call.alchemy"> <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> <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>

View file

@ -30,12 +30,13 @@ author = 'Stefano Pigozzi'
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.intersphinx"] extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.intersphinx"]
intersphinx_mapping = {'python': ('https://docs.python.org/3.7', None), intersphinx_mapping = {'python': ('https://docs.python.org/3.7', None),
'discord': ('https://discordpy.readthedocs.io/en/latest/', None)} 'discord': ('https://discordpy.readthedocs.io/en/latest/', None),
"telegram": ("https://python-telegram-bot.readthedocs.io/en/stable/", None)}
def skip(app, what, name, obj, would_skip, options): def skip(app, what, name, obj, would_skip, options):
if name == "__init__": if name == "__init__":
return False return not bool(obj.__doc__)
return would_skip return would_skip

View file

@ -0,0 +1,3 @@
from . import audio, bots, commands, database, network, utils
__all__ = ["audio", "bots", "commands", "database", "network", "utils"]

View file

@ -6,7 +6,7 @@ from .generic import GenericBot
from ..commands import NullCommand from ..commands import NullCommand
from ..utils import asyncify, Call, Command from ..utils import asyncify, Call, Command
from ..error import UnregisteredError, NoneFoundError, TooManyFoundError, InvalidConfigError from ..error import UnregisteredError, NoneFoundError, TooManyFoundError, InvalidConfigError
from ..network import Message, RoyalnetConfig from ..network import Message, Reply, RoyalnetConfig
from ..database import DatabaseConfig from ..database import DatabaseConfig
from ..audio import PlayMode, Playlist, RoyalPCMAudio from ..audio import PlayMode, Playlist, RoyalPCMAudio
@ -19,7 +19,7 @@ if not discord.opus.is_loaded():
class DiscordConfig: class DiscordConfig:
"""The specific configuration to be used for :ref:`royalnet.database.DiscordBot`.""" """The specific configuration to be used for :py:class:`royalnet.bots.DiscordBot`."""
def __init__(self, token: str): def __init__(self, token: str):
self.token = token self.token = token
@ -30,6 +30,7 @@ class DiscordBot(GenericBot):
interface_name = "discord" interface_name = "discord"
def _init_voice(self): def _init_voice(self):
"""Initialize the variables needed for the connection to voice chat."""
log.debug(f"Creating music_data dict") log.debug(f"Creating music_data dict")
self.music_data: typing.Dict[discord.Guild, PlayMode] = {} self.music_data: typing.Dict[discord.Guild, PlayMode] = {}
@ -64,7 +65,7 @@ class DiscordBot(GenericBot):
async def net_request(call, message: Message, destination: str): async def net_request(call, message: Message, destination: str):
if self.network is None: if self.network is None:
raise InvalidConfigError("Royalnet is not enabled on this bot") raise InvalidConfigError("Royalnet is not enabled on this bot")
response: Message = await self.network.request(message, destination) response: Reply = await self.network.request(message, destination)
response.raise_on_error() response.raise_on_error()
return response return response
@ -83,7 +84,7 @@ class DiscordBot(GenericBot):
return DiscordCall return DiscordCall
def _bot_factory(self) -> typing.Type[discord.Client]: def _bot_factory(self) -> typing.Type[discord.Client]:
"""Create a new DiscordClient class based on this DiscordBot.""" """Create a custom DiscordClient class inheriting from :py:class:`discord.Client`."""
log.debug(f"Creating DiscordClient") log.debug(f"Creating DiscordClient")
# noinspection PyMethodParameters # noinspection PyMethodParameters
@ -129,8 +130,11 @@ class DiscordBot(GenericBot):
await cli.change_presence(status=discord.Status.online) await cli.change_presence(status=discord.Status.online)
def find_guild_by_name(cli, name: str) -> discord.Guild: def find_guild_by_name(cli, name: str) -> discord.Guild:
"""Find the Guild with the specified name. Case-insensitive. """Find the :py:class:`discord.Guild` with the specified name. Case-insensitive.
Will raise a NoneFoundError if no channels are found, or a TooManyFoundError if more than one is found."""
Raises:
:py:exc:`NoneFoundError` if no channels are found.
:py:exc:`TooManyFoundError` if more than one is found."""
all_guilds: typing.List[discord.Guild] = cli.guilds all_guilds: typing.List[discord.Guild] = cli.guilds
matching_channels: typing.List[discord.Guild] = [] matching_channels: typing.List[discord.Guild] = []
for guild in all_guilds: for guild in all_guilds:
@ -145,9 +149,9 @@ class DiscordBot(GenericBot):
def find_channel_by_name(cli, def find_channel_by_name(cli,
name: str, name: str,
guild: typing.Optional[discord.Guild] = None) -> discord.abc.GuildChannel: guild: typing.Optional[discord.Guild] = None) -> discord.abc.GuildChannel:
"""Find the TextChannel, VoiceChannel or CategoryChannel with the specified name. Case-insensitive. """Find the :py:class:`TextChannel`, :py:class:`VoiceChannel` or :py:class:`CategoryChannel` with the specified name. Case-insensitive.
Guild is optional, but the method will raise a TooManyFoundError if none is specified and there is more than one channel with the same name. Guild is optional, but the method will raise a :py:exc:`TooManyFoundError` if none is specified and there is more than one channel with the same name.
Will also raise a NoneFoundError if no channels are found.""" Will also raise a :py:exc:`NoneFoundError` if no channels are found."""
if guild is not None: if guild is not None:
all_channels = guild.channels all_channels = guild.channels
else: else:
@ -167,10 +171,11 @@ class DiscordBot(GenericBot):
return matching_channels[0] return matching_channels[0]
def find_voice_client_by_guild(cli, guild: discord.Guild): def find_voice_client_by_guild(cli, guild: discord.Guild):
"""Find the VoiceClient belonging to a specific Guild. """Find the :py:class:`discord.VoiceClient` belonging to a specific :py:class:`discord.Guild`.
Raises a NoneFoundError if the Guild currently has no VoiceClient."""
Raises:
:py:exc:`NoneFoundError` if the :py:class:`discord.Guild` currently has no :py:class:`discord.VoiceClient`."""
for voice_client in cli.voice_clients: for voice_client in cli.voice_clients:
voice_client: discord.VoiceClient
if voice_client.guild == guild: if voice_client.guild == guild:
return voice_client return voice_client
raise NoneFoundError("No voice clients found") raise NoneFoundError("No voice clients found")
@ -178,7 +183,7 @@ class DiscordBot(GenericBot):
return DiscordClient return DiscordClient
def _init_client(self): def _init_client(self):
"""Create a bot instance.""" """Create an instance of the DiscordClient class created in :py:func:`royalnet.bots.DiscordBot._bot_factory`."""
log.debug(f"Creating DiscordClient instance") log.debug(f"Creating DiscordClient instance")
self._Client = self._bot_factory() self._Client = self._bot_factory()
self.client = self._Client() self.client = self._Client()
@ -202,13 +207,14 @@ class DiscordBot(GenericBot):
self._init_voice() self._init_voice()
async def run(self): async def run(self):
"""Login to Discord, then run the bot."""
log.debug(f"Logging in to Discord") log.debug(f"Logging in to Discord")
await self.client.login(self._discord_config.token) await self.client.login(self._discord_config.token)
log.debug(f"Connecting to Discord") log.debug(f"Connecting to Discord")
await self.client.connect() await self.client.connect()
# TODO: how to stop? # TODO: how to stop?
async def add_to_music_data(self, audio_sources: typing.List[discord.AudioSource], guild: discord.Guild): async def add_to_music_data(self, audio_sources: typing.List[RoyalPCMAudio], guild: discord.Guild):
"""Add a file to the corresponding music_data object.""" """Add a file to the corresponding music_data object."""
guild_music_data = self.music_data[guild] guild_music_data = self.music_data[guild]
for audio_source in audio_sources: for audio_source in audio_sources:
@ -222,7 +228,7 @@ class DiscordBot(GenericBot):
guild_music_data = self.music_data[guild] guild_music_data = self.music_data[guild]
voice_client = self.client.find_voice_client_by_guild(guild) voice_client = self.client.find_voice_client_by_guild(guild)
next_source: RoyalPCMAudio = await guild_music_data.next() next_source: RoyalPCMAudio = await guild_music_data.next()
await self.update_activity_with_source_title(next_source) await self.update_activity_with_source_title()
if next_source is None: if next_source is None:
log.debug(f"Ending playback chain") log.debug(f"Ending playback chain")
return return
@ -235,18 +241,25 @@ class DiscordBot(GenericBot):
log.debug(f"Starting playback of {next_source}") log.debug(f"Starting playback of {next_source}")
voice_client.play(next_source, after=advance) voice_client.play(next_source, after=advance)
async def update_activity_with_source_title(self, rpa: typing.Optional[RoyalPCMAudio] = None): async def update_activity_with_source_title(self):
if len(self.music_data) > 1: """Change the bot's presence (using :py:func:`discord.Client.change_presence`) to match the current listening status.
If multiple guilds are using the bot, the bot will always have an empty presence."""
if len(self.music_data) != 1:
# Multiple guilds are using the bot, do not display anything # Multiple guilds are using the bot, do not display anything
log.debug(f"Updating current Activity: setting to None, as multiple guilds are using the bot") log.debug(f"Updating current Activity: setting to None, as multiple guilds are using the bot")
await self.client.change_presence(status=discord.Status.online) await self.client.change_presence(status=discord.Status.online)
return return
if rpa is None: # FIXME: PyCharm faulty inspection?
# noinspection PyUnresolvedReferences
play_mode: PlayMode = list(self.music_data.items())[0][1]
now_playing = play_mode.now_playing
if now_playing is None:
# No songs are playing now # No songs are playing now
log.debug(f"Updating current Activity: setting to None, as nothing is currently being played") log.debug(f"Updating current Activity: setting to None, as nothing is currently being played")
await self.client.change_presence(status=discord.Status.online) await self.client.change_presence(status=discord.Status.online)
return return
log.debug(f"Updating current Activity: listening to {rpa.rpf.info.title}") log.debug(f"Updating current Activity: listening to {now_playing.rpf.info.title}")
await self.client.change_presence(activity=discord.Activity(name=rpa.rpf.info.title, await self.client.change_presence(activity=discord.Activity(name=now_playing.rpf.info.title,
type=discord.ActivityType.listening), type=discord.ActivityType.listening),
status=discord.Status.online) status=discord.Status.online)

View file

@ -19,8 +19,8 @@ class GenericBot:
command_prefix: str, command_prefix: str,
commands: typing.List[typing.Type[Command]], commands: typing.List[typing.Type[Command]],
missing_command: typing.Type[Command], missing_command: typing.Type[Command],
error_command: typing.Type[Command]): error_command: typing.Type[Command]) -> None:
"""Generate the commands dictionary required to handle incoming messages, and the network_handlers dictionary required to handle incoming requests.""" """Generate the ``commands`` dictionary required to handle incoming messages, and the ``network_handlers`` dictionary required to handle incoming requests."""
log.debug(f"Now generating commands") log.debug(f"Now generating commands")
self.commands: typing.Dict[str, typing.Type[Command]] = {} self.commands: typing.Dict[str, typing.Type[Command]] = {}
self.network_handlers: typing.Dict[typing.Type[Message], typing.Type[NetworkHandler]] = {} self.network_handlers: typing.Dict[typing.Type[Message], typing.Type[NetworkHandler]] = {}
@ -33,18 +33,24 @@ class GenericBot:
log.debug(f"Successfully generated commands") log.debug(f"Successfully generated commands")
def _call_factory(self) -> typing.Type[Call]: def _call_factory(self) -> typing.Type[Call]:
"""Create the Call class, representing a Call command. It should inherit from the utils.Call class.""" """Create the TelegramCall class, representing a command call. It should inherit from :py:class:`royalnet.utils.Call`.
Returns:
The created TelegramCall class."""
raise NotImplementedError() raise NotImplementedError()
def _init_royalnet(self, royalnet_config: RoyalnetConfig): def _init_royalnet(self, royalnet_config: RoyalnetConfig):
"""Create a RoyalnetLink, and run it as a task.""" """Create a :py:class:`royalnet.network.RoyalnetLink`, and run it as a :py:class:`asyncio.Task`."""
self.network: RoyalnetLink = RoyalnetLink(royalnet_config.master_uri, royalnet_config.master_secret, self.interface_name, self.network: RoyalnetLink = RoyalnetLink(royalnet_config.master_uri, royalnet_config.master_secret, self.interface_name,
self._network_handler) self._network_handler)
log.debug(f"Running RoyalnetLink {self.network}") log.debug(f"Running RoyalnetLink {self.network}")
loop.create_task(self.network.run()) loop.create_task(self.network.run())
async def _network_handler(self, message: Message) -> Message: async def _network_handler(self, message: Message) -> Message:
"""Handle a single Message received from the RoyalnetLink""" """Handle a single :py:class:`royalnet.network.Message` received from the :py:class:`royalnet.network.RoyalnetLink`.
Returns:
Another message, to be sent as :py:class:`royalnet.network.Reply`."""
log.debug(f"Received {message} from the RoyalnetLink") log.debug(f"Received {message} from the RoyalnetLink")
try: try:
network_handler = self.network_handlers[message.__class__] network_handler = self.network_handlers[message.__class__]
@ -61,7 +67,7 @@ class GenericBot:
return RequestError(exc=exc) return RequestError(exc=exc)
def _init_database(self, commands: typing.List[typing.Type[Command]], database_config: DatabaseConfig): def _init_database(self, commands: typing.List[typing.Type[Command]], database_config: DatabaseConfig):
"""Connect to the database, and create the missing tables required by the selected commands.""" """Create an :py:class:`royalnet.database.Alchemy` with the tables required by the commands. Then, find the chain that links the ``master_table`` to the ``identity_table``."""
log.debug(f"Initializing database") log.debug(f"Initializing database")
required_tables = set() required_tables = set()
for command in commands: for command in commands:
@ -99,7 +105,11 @@ class GenericBot:
self._init_royalnet(royalnet_config=royalnet_config) self._init_royalnet(royalnet_config=royalnet_config)
async def call(self, command_name: str, channel, parameters: typing.List[str] = None, **kwargs): async def call(self, command_name: str, channel, parameters: typing.List[str] = None, **kwargs):
"""Call a command by its string, or missing_command if it doesn't exists, or error_command if an exception is raised during the execution.""" """Call the command with the specified name.
If it doesn't exist, call ``self.missing_command``.
If an exception is raised during the execution of the command, call ``self.error_command``."""
log.debug(f"Trying to call {command_name}") log.debug(f"Trying to call {command_name}")
if parameters is None: if parameters is None:
parameters = [] parameters = []

View file

@ -14,7 +14,7 @@ log = _logging.getLogger(__name__)
class TelegramConfig: class TelegramConfig:
"""The specific configuration to be used for :ref:`royalnet.database.TelegramBot`.""" """The specific configuration to be used for :py:class:`royalnet.database.TelegramBot`."""
def __init__(self, token: str): def __init__(self, token: str):
self.token: str = token self.token: str = token
@ -24,6 +24,7 @@ class TelegramBot(GenericBot):
interface_name = "telegram" interface_name = "telegram"
def _init_client(self): def _init_client(self):
"""Create the :py:class:`telegram.Bot`, and set the starting offset."""
self.client = telegram.Bot(self._telegram_config.token) self.client = telegram.Bot(self._telegram_config.token)
self._offset: int = -100 self._offset: int = -100

View file

@ -1,4 +1,4 @@
from .messages import Message, ServerErrorMessage, InvalidSecretEM, InvalidDestinationEM, InvalidPackageEM, RequestSuccessful, RequestError from .messages import Message, ServerErrorMessage, InvalidSecretEM, InvalidDestinationEM, InvalidPackageEM, RequestSuccessful, RequestError, Reply
from .packages import Package from .packages import Package
from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError from .royalnetlink import RoyalnetLink, NetworkError, NotConnectedError, NotIdentifiedError
from .royalnetserver import RoyalnetServer from .royalnetserver import RoyalnetServer
@ -17,4 +17,5 @@ __all__ = ["Message",
"RoyalnetServer", "RoyalnetServer",
"RequestSuccessful", "RequestSuccessful",
"RequestError", "RequestError",
"RoyalnetConfig"] "RoyalnetConfig",
"Reply"]

View file

@ -13,7 +13,7 @@ log = _logging.getLogger(__name__)
class NotConnectedError(Exception): class NotConnectedError(Exception):
pass """The :py:class:`royalnet.network.RoyalnetLink` is not connected to a :py:class:`royalnet.network.RoyalnetServer`."""
class NotIdentifiedError(Exception): class NotIdentifiedError(Exception):
@ -67,7 +67,7 @@ class RoyalnetLink:
self.secret: str = secret self.secret: str = secret
self.websocket: typing.Optional[websockets.WebSocketClientProtocol] = None self.websocket: typing.Optional[websockets.WebSocketClientProtocol] = None
self.request_handler = request_handler self.request_handler = request_handler
self._pending_requests: typing.Dict[typing.Optional[Message]] = {} self._pending_requests: typing.Dict[str, typing.Optional[Message]] = {}
self._loop: asyncio.AbstractEventLoop = loop self._loop: asyncio.AbstractEventLoop = loop
self._connect_event: asyncio.Event = asyncio.Event(loop=self._loop) self._connect_event: asyncio.Event = asyncio.Event(loop=self._loop)
self.identify_event: asyncio.Event = asyncio.Event(loop=self._loop) self.identify_event: asyncio.Event = asyncio.Event(loop=self._loop)