command clear_cache youtube dl, prise en compte des commandes dans l'historique kabot

This commit is contained in:
BFlow 2020-09-04 22:02:46 +02:00
parent fc29b8931b
commit 0995303080
3 changed files with 34 additions and 20 deletions

View file

@ -2,10 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.7 (kivy_tuto)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module> </module>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (kabot)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (kivy_tuto)" project-jdk-type="Python SDK" />
</project> </project>

View file

@ -83,6 +83,13 @@ class Mybot(commands.Cog):
detail = commit.attributes detail = commit.attributes
await ctx.channel.send("__" + detail['author_name'] + "__: " + detail['title'] + '\n' + detail['web_url']) 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() @commands.command()
async def disconnect(self, ctx): async def disconnect(self, ctx):
await ctx.guild.voice_client.disconnect() await ctx.guild.voice_client.disconnect()
@ -352,15 +359,20 @@ class Mybot(commands.Cog):
@commands.command(help="Faire dire des choses au bot") @commands.command(help="Faire dire des choses au bot")
async def say(self, ctx, *message): async def say(self, ctx, *message):
sentence = ' '.join(message) sentence = ' '.join(message)
for word in sentence.split(): if sentence.startswith('!'):
if word.startswith('@'): command_name = sentence.split()[0].replace('!', '')
guild = self.bot.guilds[0] cmd = self.bot.get_command(command_name)
members = guild.members await cmd.invoke(message)
for member in members: else:
if member.name == word[1:]: for word in sentence.split():
sentence = sentence.replace(word, member.mention) if word.startswith('@'):
channel = [x for x in self.bot.get_all_channels() if x.name == "général"][0] guild = self.bot.guilds[0]
await channel.send(sentence) 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') @commands.command(help='slap this ass')
async def slap(self, ctx, user=None): async def slap(self, ctx, user=None):
@ -538,12 +550,17 @@ def main():
with open(path, 'a') as f: with open(path, 'a') as f:
f.write(message.content + '\n') f.write(message.content + '\n')
response = random.choice(lines).replace(str(bot.user.id), str(message.author.id)) response = random.choice(lines).replace(str(bot.user.id), str(message.author.id))
with message.channel.typing(): if response.startswith('!'):
if "http" in response: command_name = response.split()[0].replace('!', '')
await asyncio.sleep(len(response) / 8) cmd = bot.get_command(command_name)
else: await cmd.invoke(message)
await asyncio.sleep(len(response) / 6) else:
await message.channel.send(response) 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) await bot.process_commands(message)
@bot.event @bot.event