Skip to content

Commit

Permalink
Fix missing times in aoc
Browse files Browse the repository at this point in the history
Fixed missing "time since last update" and "time until next challenge" in `aoc`
  • Loading branch information
Heryin committed Nov 30, 2024
1 parent f9c6293 commit e6f1e71
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pychan/commands/utilities/aoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __init__(self, id: int, local_score: int, global_score, name: str, stars: in
self.last_star_ts: int = last_star_ts
self.completion: Completion = completion


class TrackedChannel:
def __init__(self, leaderboard_id: int, messages: List[Message]) -> None:
self.leaderboard_id = leaderboard_id
Expand Down Expand Up @@ -112,9 +111,6 @@ async def force_update(self, ctx: Context):

@tasks.loop(minutes=15)
async def loop(self):
# timezone issue :clown:
tomorrow = datetime.combine(date.today(), time(6, 0))
tomorrow += timedelta(days=1)
for _, tracked_channel in self.tracked_channels.items():
data = self.fetch_data(tracked_channel.leaderboard_id)
extracted_data = self.parse_data(data)
Expand Down Expand Up @@ -157,7 +153,12 @@ def get_rows(self, data: List[AoCMember]) -> List[str]:

def split_message(self, rows: List[str]) -> List[str]:
messages = []
current_message = '```\n'
tomorrow = datetime.combine(date.today(), time(6, 0))
tomorrow += timedelta(days=1)
current_message = f'# AoC {datetime.today().year} Leaderboard\n \
Ostatnia aktualizacja: <t:{int(datetime.today().timestamp())}:R>\n \
Czas do następnego wyzwania: <t:{int(tomorrow.timestamp())}:R> \
```\n'
for row in rows:
if len(current_message) + len(row) + 4 > 2000: # 4 for closing ```
current_message += '```'
Expand Down

0 comments on commit e6f1e71

Please sign in to comment.