From 43057b949cb57c0b15754bbdb4a689f298408e75 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Tue, 30 Nov 2021 13:59:40 +0000 Subject: [PATCH] Add idle logging and tidy code --- app.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index e6a2f28..52e4859 100644 --- a/app.py +++ b/app.py @@ -9,6 +9,7 @@ bot = discord.Client() mincooldown = 3 maxcooldown = 10 counter = random.randrange(mincooldown, maxcooldown) +idleMessageCounter = 0 @bot.event @@ -27,7 +28,9 @@ async def on_message(message): if message.author == bot.user: return elif message.author.id == 581890740360052764: - reply = re.split("(^| )(I'M|IM|I AM|I'm|Im|I am|i'm|im|i am)( )", message.content, 1) + reply = re.split( + "(^| )(I'M|IM|I AM|I'm|Im|I am|i'm|im|i am)( )", message.content, 1 + ) if len(reply) > 1: print("Message from " + message.author.name + ": " + message.content) print( @@ -43,9 +46,13 @@ async def on_message(message): ) else: global counter + global idleMessageCounter # TODO: Add detection for "genshin" and replace with "g*nshin" - reply = re.split("(^| )(I'M|IM|I AM|I'm|Im|I am|i'm|im|i am)( )", message.content, 1) + reply = re.split( + "(^| )(I'M|IM|I AM|I'm|Im|I am|i'm|im|i am)( )", message.content, 1 + ) if len(reply) > 1: + idleMessageCounter = 0 print("Message from " + message.author.name + ": " + message.content) print( "Reply: Length:" @@ -61,6 +68,9 @@ async def on_message(message): counter = random.randrange(mincooldown, maxcooldown) await message.reply("Hi " + reply[-1] + ", I'm Dad") print("Replied to " + message.author.name + " with Dad Joke") + else: + idleMessageCounter += 1 + print("Idle Message Counter: " + str(idleMessageCounter), end="\r") with open("secrets.yaml") as stream: