From b53491e53d2c8bbaf89909537ea533ddc451eb93 Mon Sep 17 00:00:00 2001 From: Sam Curran <83888868+Sam2004-2@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:02:08 +0000 Subject: [PATCH 1/3] Added Regular Expression Checking for Good Morning and Easter Egg Phrases --- bot/__init__.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index a59360a..c690961 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -111,27 +111,28 @@ async def on_message(message): await message.add_reaction(BAD_MORNING_EMOJI) return - if any(element in contents for element in GOOD_MORNING_PHRASES): - print(f'gm detected > "{message.content}" by {message.author}') - if FIRST_GM is False: - FIRST_GM_USER = message.author - FIRST_GM = True + # Use regular expressions to check for good morning phrases + for pattern in GOOD_MORNING_PHRASES: + if re.search(rf'\b{re.escape(pattern)}\b', contents): + print(f'gm detected > "{message.content}" by {message.author}') + if FIRST_GM is False: + FIRST_GM_USER = message.author + FIRST_GM = True + + await message.add_reaction(EARLY_EMOJI) + server_leaders.add_point(message.author) + return - await message.add_reaction(EARLY_EMOJI) server_leaders.add_point(message.author) - return + await message.add_reaction(MORNING_EMOJI) - server_leaders.add_point(message.author) - await message.add_reaction(MORNING_EMOJI) + return + for egg_phrase, reaction in configuration_data["easter_egg_phrases"].items(): + if re.search(rf'\b{re.escape(egg_phrase)}\b', contents): + await message.add_reaction(reaction) return - for egg_phrase in configuration_data["easter_egg_phrases"].keys(): - if egg_phrase in contents: - await message.add_reaction( - configuration_data["easter_egg_phrases"][egg_phrase] - ) - if DEBUG_MODE: if re.match(PATTERN, contents.lower()): # debug block >1 extracted_number = re.match(PATTERN, contents.lower()).group(1) From fad9ceef8eccfc5173c18707aee6d39ea9645ca3 Mon Sep 17 00:00:00 2001 From: Sam Curran <83888868+Sam2004-2@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:04:53 +0000 Subject: [PATCH 2/3] Regular Expression (#37) --- bot/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/__init__.py b/bot/__init__.py index c690961..08cfc6e 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -111,7 +111,7 @@ async def on_message(message): await message.add_reaction(BAD_MORNING_EMOJI) return - # Use regular expressions to check for good morning phrases + # Use regular expressions to check for good morning phrases small changes for pattern in GOOD_MORNING_PHRASES: if re.search(rf'\b{re.escape(pattern)}\b', contents): print(f'gm detected > "{message.content}" by {message.author}') @@ -128,6 +128,7 @@ async def on_message(message): return + #Performing regular expression checking on easter egg phrases for egg_phrase, reaction in configuration_data["easter_egg_phrases"].items(): if re.search(rf'\b{re.escape(egg_phrase)}\b', contents): await message.add_reaction(reaction) From 8eef4c6707fb7006b605c7c3d981515eac4d8a97 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 17 Nov 2023 22:27:44 +0000 Subject: [PATCH 3/3] cheeky change to contributing --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46bce2c..8373a2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ 4. Write a concise title 5. Write a good description 6. Sit back and wait for review -7. Accept constructive feedback and comments +7. Build upon constructive feedback and comments 8. Get it merged :) ## General PR Guidelines