From 0aa94e5d8ffd4cd5f2832278bd167074562d673f Mon Sep 17 00:00:00 2001 From: Joseph Banks Date: Wed, 26 Dec 2018 09:38:12 +0000 Subject: Fix is_in_advent() function --- bot/seasons/christmas/adventofcode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot/seasons/christmas/adventofcode.py') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 458eb19f..f9ca9f01 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -29,7 +29,8 @@ def is_in_advent() -> bool: Utility function to check if we are between December 1st and December 25th. """ - return datetime.now(EST).day in range(1, 26) and datetime.now(EST).month == 12 + # Run the code from the 1st to the 24th + return datetime.now(EST).day in range(1, 25) and datetime.now(EST).month == 12 def time_left_to_aoc_midnight() -> Tuple[datetime, timedelta]: -- cgit v1.2.3 From 7877a47182acae5413c2bbd49863fb0227425c34 Mon Sep 17 00:00:00 2001 From: Joseph Banks Date: Wed, 26 Dec 2018 09:38:37 +0000 Subject: Add a notice to AoC countdown to find out if we are still in the advent of code --- bot/seasons/christmas/adventofcode.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bot/seasons/christmas/adventofcode.py') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index f9ca9f01..af72466b 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -180,6 +180,10 @@ class AdventOfCode: """ Return time left until next day """ + if not is_in_advent(): + await ctx.send(f"Advent of Code is no longer running this year! Come back next year for more puzzles!") + return + tomorrow, time_left = time_left_to_aoc_midnight() hours, minutes = time_left.seconds // 3600, time_left.seconds // 60 % 60 -- cgit v1.2.3 From 049a42d825fe12fe611783dff5531f4fd05af56c Mon Sep 17 00:00:00 2001 From: Joseph Banks Date: Wed, 26 Dec 2018 11:16:44 +0000 Subject: Address review comments --- bot/seasons/christmas/adventofcode.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bot/seasons/christmas/adventofcode.py') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index af72466b..261762fd 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -181,7 +181,10 @@ class AdventOfCode: Return time left until next day """ if not is_in_advent(): - await ctx.send(f"Advent of Code is no longer running this year! Come back next year for more puzzles!") + datetime_now = datetime.datetime.now(EST) + december_first = datetime.datetime(datetime_now.year + 1, 12, 1, tzinfo=EST) + delta = december_first - datetime_now + await ctx.send(f"Advent of Code event is not currently running. The next event will start in {delta.days} days.") return tomorrow, time_left = time_left_to_aoc_midnight() -- cgit v1.2.3 From 7aa3eb29e445c826e3683e11e12c477520aa7b11 Mon Sep 17 00:00:00 2001 From: Joseph Banks Date: Wed, 26 Dec 2018 11:18:10 +0000 Subject: Fix the grammar on the message --- bot/seasons/christmas/adventofcode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/seasons/christmas/adventofcode.py') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 261762fd..d45477a0 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -184,7 +184,7 @@ class AdventOfCode: datetime_now = datetime.datetime.now(EST) december_first = datetime.datetime(datetime_now.year + 1, 12, 1, tzinfo=EST) delta = december_first - datetime_now - await ctx.send(f"Advent of Code event is not currently running. The next event will start in {delta.days} days.") + await ctx.send(f"The Advent of Code event is not currently running. The next event will start in {delta.days} days.") return tomorrow, time_left = time_left_to_aoc_midnight() -- cgit v1.2.3 From 2f693d82ca6ad26905db85616dcc9a70a4373bdc Mon Sep 17 00:00:00 2001 From: Joseph Banks Date: Wed, 26 Dec 2018 11:21:06 +0000 Subject: Address flake8 complaints --- bot/seasons/christmas/adventofcode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot/seasons/christmas/adventofcode.py') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index d45477a0..486d3b18 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -184,7 +184,8 @@ class AdventOfCode: datetime_now = datetime.datetime.now(EST) december_first = datetime.datetime(datetime_now.year + 1, 12, 1, tzinfo=EST) delta = december_first - datetime_now - await ctx.send(f"The Advent of Code event is not currently running. The next event will start in {delta.days} days.") + await ctx.send(f"The Advent of Code event is not currently running. " + f"The next event will start in {delta.days} days.") return tomorrow, time_left = time_left_to_aoc_midnight() -- cgit v1.2.3