From 86c6f80b263e4c4c2cd9651a2f094c839fe9ca0a Mon Sep 17 00:00:00 2001 From: Milka64 Date: Tue, 1 Oct 2019 15:40:48 +0200 Subject: [PATCH] fix multilines && fix doublons in logs --- kabot/kabot/kabot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index 6404603..5936345 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -62,15 +62,16 @@ def main(): print(message.content) if message.author == bot.user: return - if message.content == 'pwet': - await message.channel.send('pong') else: - if bot.user in message.mentions and len(message.mentions) < 3: + if bot.user in message.mentions \ + and len(message.mentions) < 3 \ + and len(message.content.splitlines()) == 1: path = '/tmp/%s.log' % message.channel with open(path, 'r') as f : lines = f.read().splitlines() - with open(path, 'a') as f : - f.write(message.content + '\n') + if not message.content in lines: + with open(path, 'a') as f : + f.write(message.content + '\n') response = random.choice(lines).replace(str(bot.user.id), str(message.author.id)) await message.channel.send(response) await bot.process_commands(message)