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

401 lines
No EOL
22 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>royalnet.bots &mdash; Royalnet documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="royalnet.commands" href="commands.html" />
<link rel="prev" title="royalnet.audio" href="audio.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Royalnet
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="audio.html">royalnet.audio</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">royalnet.bots</a><ul class="simple">
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="commands.html">royalnet.commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="database.html">royalnet.database</a></li>
<li class="toctree-l1"><a class="reference internal" href="network.html">royalnet.network</a></li>
<li class="toctree-l1"><a class="reference internal" href="utils.html">royalnet.utils</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Royalnet</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>royalnet.bots</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/bots.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="royalnet-bots">
<h1>royalnet.bots<a class="headerlink" href="#royalnet-bots" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
</div>
<span class="target" id="module-royalnet.bots"></span><dl class="class">
<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>
<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">
<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>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p>
</dd></dl>
<dl class="method">
<dt id="royalnet.bots.TelegramBot._handle_update">
<code class="descname">_handle_update</code><span class="sig-paren">(</span><em>update: telegram.update.Update</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.TelegramBot._handle_update" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<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>
<dd></dd></dl>
<dl class="attribute">
<dt id="royalnet.bots.TelegramBot.botfather_command_string">
<code class="descname">botfather_command_string</code><a class="headerlink" href="#royalnet.bots.TelegramBot.botfather_command_string" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="royalnet.bots.TelegramBot.interface_name">
<code class="descname">interface_name</code><em class="property"> = 'telegram'</em><a class="headerlink" href="#royalnet.bots.TelegramBot.interface_name" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.bots.TelegramBot.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="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>
</dd></dl>
</dd></dl>
<dl class="class">
<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>
<dd><p>The specific configuration to be used for <span class="xref std std-ref">royalnet.database.TelegramBot</span>.</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>
<dl class="class">
<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>
<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">
<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>
<dd><p>Create a new DiscordClient class based on this DiscordBot.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Create a bot instance.</p>
</dd></dl>
<dl class="method">
<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>
<dd></dd></dl>
<dl class="method">
<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>
<dd><p>Add a file to the corresponding music_data object.</p>
</dd></dl>
<dl class="method">
<dt id="royalnet.bots.DiscordBot.advance_music_data">
<code class="descname">advance_music_data</code><span class="sig-paren">(</span><em>guild: discord.guild.Guild</em><span class="sig-paren">)</span><a class="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>
<dl class="attribute">
<dt id="royalnet.bots.DiscordBot.interface_name">
<code class="descname">interface_name</code><em class="property"> = 'discord'</em><a class="headerlink" href="#royalnet.bots.DiscordBot.interface_name" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<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>
<dd><p>A blocking coroutine that should make the bot start listening to commands and requests.</p>
</dd></dl>
<dl class="method">
<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>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<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>
<dd><p>The specific configuration to be used for <span class="xref std std-ref">royalnet.database.DiscordBot</span>.</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>
<dl class="class">
<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>
<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">
<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>
<dd><p>Create the Call class, representing a Call command. It should inherit from the utils.Call class.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Generate the commands dictionary required to handle incoming messages, and the network_handlers dictionary required to handle incoming requests.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Connect to the database, and create the missing tables required by the selected commands.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Create a RoyalnetLink, and run it as a task.</p>
</dd></dl>
<dl class="method">
<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>
<dd><p>Handle a single Message received from the RoyalnetLink</p>
</dd></dl>
<dl class="method">
<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>
<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></dl>
<dl class="attribute">
<dt id="royalnet.bots.GenericBot.interface_name">
<code class="descname">interface_name</code><em class="property"> = NotImplemented</em><a class="headerlink" href="#royalnet.bots.GenericBot.interface_name" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.bots.GenericBot.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot.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></dl>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="commands.html" class="btn btn-neutral float-right" title="royalnet.commands" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="audio.html" class="btn btn-neutral float-left" title="royalnet.audio" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2019, Stefano Pigozzi
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>