-
-
Notifications
You must be signed in to change notification settings - Fork 17
update aoc to support 12 stars this year rather than all 25 #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
onerandomusername
wants to merge
5
commits into
python-discord:main
Choose a base branch
from
onerandomusername:qt/aoc-12
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2b5826
update aoc to support 12 stars this year rather than all 25
onerandomusername d932f37
update summer to get days for year
onerandomusername 64638ab
add lb fix in day counts
onerandomusername f5634d6
update completionist count
onerandomusername e795694
Apply suggestions from code review
onerandomusername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,12 +11,13 @@ | |
|
|
||
| from bot.bot import SirRobin | ||
| from bot.constants import Bot, Channels, Roles | ||
| from bot.exts.advent_of_code._helpers import days_in_year | ||
| from bot.utils.time import time_until | ||
|
|
||
| log = logging.get_logger(__name__) | ||
|
|
||
| # TODO: Add support for different years in accordance with AOC changes | ||
| AOC_URL = "https://adventofcode.com/{year}/day/{day}" | ||
| LAST_DAY = 25 | ||
| FIRST_YEAR = 2015 | ||
| LAST_YEAR = arrow.get().year - 1 | ||
| PUBLIC_NAME = "Revival of Code" | ||
|
|
@@ -63,8 +64,9 @@ def __init__(self, bot: SirRobin): | |
| self.wait_task: asyncio.Task | None = None | ||
| self.loop_task: tasks.Loop | None = None | ||
|
|
||
| self.is_running = False | ||
| self.is_running: bool = False | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need an annotation? It should be inferable.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was writing this code with pyright strict mode enabled. I can remove this if that's necessary. |
||
| self.year: int | None = None | ||
| self.days_this_year: int | None = None | ||
| self.current_day: int | None = None | ||
| self.day_interval: int | None = None | ||
| self.post_time = 0 | ||
|
|
@@ -145,6 +147,7 @@ async def start(self, ctx: commands.Context, year: int, day_interval: int, post_ | |
|
|
||
| self.is_running = True | ||
| self.year = year | ||
| self.days_this_year = days_in_year(year) | ||
| self.current_day = 1 | ||
| self.day_interval = day_interval | ||
| self.post_time = post_time | ||
|
|
@@ -174,8 +177,8 @@ async def force_day(self, ctx: commands.Context, day: int, now: Literal["now"] | | |
| await ctx.send(embed=embed) | ||
| return | ||
|
|
||
| if not 1 <= day <= LAST_DAY: | ||
| raise commands.BadArgument(f"Start day must be between 1 and {LAST_DAY}, inclusive") | ||
| if not 1 <= day <= self.days_this_year: | ||
| raise commands.BadArgument(f"Start day must be between 1 and {self.days_this_year}, inclusive") | ||
|
|
||
| log.info(f"Setting the current day of Summer AoC to {day}") | ||
| await self.stop_event() | ||
|
|
@@ -187,7 +190,7 @@ async def force_day(self, ctx: commands.Context, day: int, now: Literal["now"] | | |
|
|
||
| embed = self.get_info_embed() | ||
| if now: | ||
| if self.current_day > LAST_DAY: | ||
| if self.current_day > self.days_this_year: | ||
| title = "Puzzle posted and event is now ending" | ||
| else: | ||
| title = "Puzzle posted and event is now running" | ||
|
|
@@ -197,7 +200,7 @@ async def force_day(self, ctx: commands.Context, day: int, now: Literal["now"] | | |
| embed.title = title | ||
| embed.color = discord.Color.green() | ||
| await ctx.send(embed=embed) | ||
| if self.current_day <= LAST_DAY: | ||
| if self.current_day <= self.days_this_year: | ||
| await self.start_event() | ||
|
|
||
| @summer_aoc_group.command(name="stop") | ||
|
|
@@ -290,7 +293,7 @@ async def stop_event(self) -> bool: | |
|
|
||
| async def post_puzzle(self) -> None: | ||
| """Create a thread for the current day's puzzle.""" | ||
| if self.current_day > LAST_DAY: | ||
| if self.current_day > self.days_this_year: | ||
| log.error("Attempted to post puzzle after last day, stopping event") | ||
| await self.stop_event() | ||
| return | ||
|
|
@@ -306,7 +309,7 @@ async def post_puzzle(self) -> None: | |
|
|
||
| self.current_day += 1 | ||
| await self.save_event_state() | ||
| if self.current_day > LAST_DAY: | ||
| if self.current_day > self.days_this_year: | ||
| await self.stop_event() | ||
|
|
||
| def get_info_embed(self) -> discord.Embed: | ||
|
|
@@ -326,7 +329,7 @@ def get_info_embed(self) -> discord.Embed: | |
|
|
||
| def get_puzzle_embed(self) -> discord.Embed: | ||
| """Generate an embed for the day's puzzle post.""" | ||
| if self.current_day == LAST_DAY: | ||
| if self.current_day == self.days_this_year: | ||
| next_puzzle_text = LAST_PUZZLE_TEXT.format(timestamp=int(arrow.get(REAL_AOC_START).timestamp())) | ||
| else: | ||
| next_puzzle_text = NEXT_PUZZLE_TEXT.format( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.