aboutsummaryrefslogtreecommitdiffstats
path: root/bot/constants.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot/constants.py')
-rw-r--r--bot/constants.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/bot/constants.py b/bot/constants.py
index c696b202..5e97fa2d 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -1,3 +1,4 @@
+import dataclasses
import enum
import logging
from datetime import datetime
@@ -29,11 +30,27 @@ __all__ = (
log = logging.getLogger(__name__)
-class AdventOfCodeLeaderboard(NamedTuple):
+class AdventOfCodeLeaderboard:
id: str
- session: str
+ _session: str
join_code: str
+ # If we notice that the session for this board expired, we set
+ # this attribute to `True`. We will emit a Sentry error so we
+ # can handle it, but, in the meantime, we'll try using the
+ # fallback session to make sure the commands still work.
+ use_fallback_session: bool = False
+
+ @property
+ def session(self) -> str:
+ """Return either the actual `session` cookie or the fallback cookie."""
+ if self.use_fallback_session:
+ log.info(f"Returning fallback cookie for board `{self.id}`.")
+ return AdventOfCode.fallback_session
+
+ return self._session
+
def _parse_aoc_leaderboard_env() -> Dict[str, AdventOfCodeLeaderboard]:
"""
@@ -61,6 +78,7 @@ class AdventOfCode:
# Information for the several leaderboards we have
leaderboards = _parse_aoc_leaderboard_env()
staff_leaderboard_id = environ.get("AOC_STAFF_LEADERBOARD_ID", "")
+ fallback_session = environ.get("AOC_FALLBACK_SESSION", "")
# Other Advent of Code constants
ignored_days = environ.get("AOC_IGNORED_DAYS", "").split(",")
@@ -77,6 +95,7 @@ class Branding:
class Channels(NamedTuple):
admins = 365960823622991872
advent_of_code = int(environ.get("AOC_CHANNEL_ID", 782715290437943306))
+ advent_of_code_commands = int(environ.get("AOC_COMMANDS_CHANNEL_ID", 607247579608121354))
announcements = int(environ.get("CHANNEL_ANNOUNCEMENTS", 354619224620138496))
big_brother_logs = 468507907357409333
bot = 267659945086812160