From d8af1c1b42c31a0c1748ff64548d5d02bfe41174 Mon Sep 17 00:00:00 2001 From: Milka64 Date: Wed, 2 Oct 2019 09:28:50 +0200 Subject: [PATCH] write README for BENJAMIIIIIIIIIIIN !?? --- README.md | 2 -- README.rst | 24 ++++++++++++++++++++++++ kabot/kabot/kabot.py | 23 ++++++++++++++++++++++- kabot/setup.py | 6 +++++- 4 files changed, 51 insertions(+), 4 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 48920e8..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Kabot - diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..b74a02c --- /dev/null +++ b/README.rst @@ -0,0 +1,24 @@ +Kabot +===== + +Installation +------------ + +Prerquire : + +.. code-block:: bash + + pip3 install zc.buildout + +clone this repositori, then : + +.. code-block:: bash + + python3 bootstrap-buildout.py + ./bin/buildout + +Utilisation +----------- + +.. code-block:: bash + ./bin/kabot diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index 5936345..e400780 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -14,10 +14,20 @@ class Mybot(commands.Cog): self.bot = bot @commands.command() - async def join_channel(self, ctx): + async def join(self, ctx): channel = [x for x in self.bot.get_all_channels() if x.name == "Général"][0] await channel.connect() + @commands.command() + async def disconnect(self, ctx): + await ctx.guild.voice_client.disconnect() + + @commands.command() + async def benjamin(self, ctx): + source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio("/tmp/Benjamin_Prejent.mp3")) + ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) + await ctx.send('Now playing') + @commands.command(help='check if bot always online') async def ping(self, message): await message.channel.send('pong') @@ -75,6 +85,17 @@ def main(): response = random.choice(lines).replace(str(bot.user.id), str(message.author.id)) await message.channel.send(response) await bot.process_commands(message) + + @bot.event + async def on_voice_state_update(member,before,after): + if "BFlow" in member.name: + if before.channel is None and after.channel: + for channel in bot.get_all_channels(): + if channel.name == "général": + current_chan = channel + ctx = bot.get_context(current_chan.last_message) + benjamin = bot.get_command('benjamin') + await benjamin.invoke(ctx) bot.add_cog(Mybot(bot)) bot.run(token) diff --git a/kabot/setup.py b/kabot/setup.py index 4c6047b..28c21c7 100644 --- a/kabot/setup.py +++ b/kabot/setup.py @@ -11,7 +11,11 @@ with open('README.rst') as readme_file: with open('HISTORY.rst') as history_file: history = history_file.read() -requirements = ['discord.py','requests' ] +requirements = [ + 'discord.py', + 'requests', + 'PyNaCl', + ] setup_requirements = [ ]