From 09953030808b6ce596c539dd3efb2802f381ad2d Mon Sep 17 00:00:00 2001 From: BFlow Date: Fri, 4 Sep 2020 22:02:46 +0200 Subject: [PATCH] command clear_cache youtube dl, prise en compte des commandes dans l'historique kabot --- .idea/kabot.iml | 5 +---- .idea/misc.xml | 2 +- kabot/kabot/kabot.py | 47 ++++++++++++++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.idea/kabot.iml b/.idea/kabot.iml index 6711606..fa46463 100644 --- a/.idea/kabot.iml +++ b/.idea/kabot.iml @@ -2,10 +2,7 @@ - + - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 57741fa..45ae0aa 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index 99512b2..3fea73d 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -83,6 +83,13 @@ class Mybot(commands.Cog): detail = commit.attributes await ctx.channel.send("__" + detail['author_name'] + "__: " + detail['title'] + '\n' + detail['web_url']) + @commands.command(help='clear cache youtube dl') + async def cache_clear(self, ctx): + fichiers = os.listdir('/tmp') + for fichier in fichiers: + if fichier.starwith('discord'): + os.remove("/tmp/" + fichier) + @commands.command() async def disconnect(self, ctx): await ctx.guild.voice_client.disconnect() @@ -352,15 +359,20 @@ class Mybot(commands.Cog): @commands.command(help="Faire dire des choses au bot") async def say(self, ctx, *message): sentence = ' '.join(message) - for word in sentence.split(): - if word.startswith('@'): - guild = self.bot.guilds[0] - members = guild.members - for member in members: - if member.name == word[1:]: - sentence = sentence.replace(word, member.mention) - channel = [x for x in self.bot.get_all_channels() if x.name == "général"][0] - await channel.send(sentence) + if sentence.startswith('!'): + command_name = sentence.split()[0].replace('!', '') + cmd = self.bot.get_command(command_name) + await cmd.invoke(message) + else: + for word in sentence.split(): + if word.startswith('@'): + guild = self.bot.guilds[0] + members = guild.members + for member in members: + if member.name == word[1:]: + sentence = sentence.replace(word, member.mention) + channel = [x for x in self.bot.get_all_channels() if x.name == "général"][0] + await channel.send(sentence) @commands.command(help='slap this ass') async def slap(self, ctx, user=None): @@ -538,12 +550,17 @@ def main(): with open(path, 'a') as f: f.write(message.content + '\n') response = random.choice(lines).replace(str(bot.user.id), str(message.author.id)) - with message.channel.typing(): - if "http" in response: - await asyncio.sleep(len(response) / 8) - else: - await asyncio.sleep(len(response) / 6) - await message.channel.send(response) + if response.startswith('!'): + command_name = response.split()[0].replace('!', '') + cmd = bot.get_command(command_name) + await cmd.invoke(message) + else: + with message.channel.typing(): + if "http" in response: + await asyncio.sleep(len(response) / 8) + else: + await asyncio.sleep(len(response) / 6) + await message.channel.send(response) await bot.process_commands(message) @bot.event