2022-09-17 19:22:27 +02:00
|
|
|
from dataclasses import dataclass
|
2022-09-17 23:20:46 +02:00
|
|
|
from enum import Enum
|
2022-06-19 00:23:25 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2022-06-10 01:48:02 +02:00
|
|
|
from environs import Env
|
|
|
|
|
|
|
|
# Read the .env file (if present)
|
|
|
|
env = Env()
|
|
|
|
env.read_env()
|
|
|
|
|
2022-07-13 22:54:16 +02:00
|
|
|
__all__ = [
|
|
|
|
"SANDBOX",
|
2022-07-27 22:02:59 +02:00
|
|
|
"TESTING",
|
2022-07-13 22:54:16 +02:00
|
|
|
"LOGFILE",
|
2022-09-20 01:40:05 +02:00
|
|
|
"SEMESTER",
|
|
|
|
"YEAR",
|
|
|
|
"MENU_TIMEOUT",
|
|
|
|
"EASTER_EGG_CHANCE",
|
2022-07-25 19:07:57 +02:00
|
|
|
"POSTGRES_DB",
|
|
|
|
"POSTGRES_USER",
|
|
|
|
"POSTGRES_PASS",
|
|
|
|
"POSTGRES_HOST",
|
|
|
|
"POSTGRES_PORT",
|
2022-07-13 22:54:16 +02:00
|
|
|
"DISCORD_TOKEN",
|
|
|
|
"DISCORD_READY_MESSAGE",
|
|
|
|
"DISCORD_STATUS_MESSAGE",
|
|
|
|
"DISCORD_TEST_GUILDS",
|
|
|
|
"DISCORD_BOOS_REACT",
|
|
|
|
"DISCORD_CUSTOM_COMMAND_PREFIX",
|
2022-10-13 20:00:46 +02:00
|
|
|
"ERRORS_CHANNEL",
|
|
|
|
"FREE_GAMES_CHANNEL",
|
2022-07-13 22:54:16 +02:00
|
|
|
"UFORA_ANNOUNCEMENTS_CHANNEL",
|
|
|
|
"UFORA_RSS_TOKEN",
|
2022-08-25 02:07:02 +02:00
|
|
|
"IMGFLIP_NAME",
|
|
|
|
"IMGFLIP_PASSWORD",
|
2022-09-17 23:20:46 +02:00
|
|
|
"ScheduleType",
|
|
|
|
"ScheduleInfo",
|
2022-09-17 19:22:27 +02:00
|
|
|
"SCHEDULE_DATA",
|
2022-07-13 22:54:16 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-06-10 01:48:02 +02:00
|
|
|
"""General config"""
|
|
|
|
SANDBOX: bool = env.bool("SANDBOX", True)
|
2022-07-27 22:02:59 +02:00
|
|
|
TESTING: bool = env.bool("TESTING", False)
|
2022-06-10 01:48:02 +02:00
|
|
|
LOGFILE: str = env.str("LOGFILE", "didier.log")
|
2022-07-15 23:14:56 +02:00
|
|
|
SEMESTER: int = env.int("SEMESTER", 2)
|
|
|
|
YEAR: int = env.int("YEAR", 3)
|
2022-09-17 19:22:27 +02:00
|
|
|
MENU_TIMEOUT: int = env.int("MENU_TIMEOUT", 30)
|
2022-09-20 01:40:05 +02:00
|
|
|
EASTER_EGG_CHANCE: int = env.int("EASTER_EGG_CHANCE", 15)
|
2022-06-10 01:48:02 +02:00
|
|
|
|
|
|
|
"""Database"""
|
2022-07-25 19:07:57 +02:00
|
|
|
# PostgreSQL
|
2022-09-21 00:50:58 +02:00
|
|
|
POSTGRES_DB: str = env.str("POSTGRES_DB", "didier_dev")
|
2022-07-25 19:07:57 +02:00
|
|
|
POSTGRES_USER: str = env.str("POSTGRES_USER", "postgres")
|
2022-09-21 00:50:58 +02:00
|
|
|
POSTGRES_PASS: str = env.str("POSTGRES_PASS", "postgres")
|
2022-07-25 19:07:57 +02:00
|
|
|
POSTGRES_HOST: str = env.str("POSTGRES_HOST", "localhost")
|
|
|
|
POSTGRES_PORT: int = env.int("POSTGRES_PORT", "5432")
|
2022-06-10 01:48:02 +02:00
|
|
|
|
|
|
|
"""Discord"""
|
2022-07-13 22:54:16 +02:00
|
|
|
DISCORD_TOKEN: str = env.str("DISCORD_TOKEN")
|
|
|
|
DISCORD_READY_MESSAGE: str = env.str("DISCORD_READY_MESSAGE", "I'M READY I'M READY I'M READY")
|
|
|
|
DISCORD_STATUS_MESSAGE: str = env.str("DISCORD_STATUS_MESSAGE", "with your Didier Dinks.")
|
2022-09-18 01:16:19 +02:00
|
|
|
DISCORD_MAIN_GUILD: int = env.int("DISCORD_MAIN_GUILD")
|
2022-07-13 22:54:16 +02:00
|
|
|
DISCORD_TEST_GUILDS: list[int] = env.list("DISCORD_TEST_GUILDS", [], subcast=int)
|
2022-07-24 16:39:27 +02:00
|
|
|
DISCORD_OWNER_GUILDS: Optional[list[int]] = env.list("DISCORD_OWNER_GUILDS", [], subcast=int) or None
|
2022-07-13 22:54:16 +02:00
|
|
|
DISCORD_BOOS_REACT: str = env.str("DISCORD_BOOS_REACT", "<:boos:629603785840263179>")
|
|
|
|
DISCORD_CUSTOM_COMMAND_PREFIX: str = env.str("DISCORD_CUSTOM_COMMAND_PREFIX", "?")
|
2022-07-23 23:21:32 +02:00
|
|
|
BIRTHDAY_ANNOUNCEMENT_CHANNEL: Optional[int] = env.int("BIRTHDAY_ANNOUNCEMENT_CHANNEL", None)
|
|
|
|
ERRORS_CHANNEL: Optional[int] = env.int("ERRORS_CHANNEL", None)
|
2022-10-13 20:00:46 +02:00
|
|
|
FREE_GAMES_CHANNEL: Optional[int] = env.int("FREE_GAMES_CHANNEL", None)
|
2022-06-19 00:23:25 +02:00
|
|
|
UFORA_ANNOUNCEMENTS_CHANNEL: Optional[int] = env.int("UFORA_ANNOUNCEMENTS_CHANNEL", None)
|
|
|
|
|
2022-09-17 19:22:27 +02:00
|
|
|
"""Discord Role ID's"""
|
|
|
|
BA3_ROLE: Optional[int] = env.int("BA3_ROLE", 891743208248324196)
|
2022-09-25 00:17:36 +02:00
|
|
|
MA_CS_1_ROLE: Optional[int] = env.int("MA_CS_1_ROLE", 1023293447387496570)
|
|
|
|
MA_CS_2_ROLE: Optional[int] = env.int("MA_CS_2_ROLE", 1023302736210567208)
|
|
|
|
MA_CS_ENG_1_ROLE: Optional[int] = env.int("MA_CS_ENG_1_ROLE", 1023278462733127710)
|
|
|
|
MA_CS_ENG_2_ROLE: Optional[int] = env.int("MA_CS_ENG_2_ROLE", 1023300434800164914)
|
2022-08-29 16:21:47 +02:00
|
|
|
|
2022-06-19 00:23:25 +02:00
|
|
|
"""API Keys"""
|
|
|
|
UFORA_RSS_TOKEN: Optional[str] = env.str("UFORA_RSS_TOKEN", None)
|
2022-08-25 02:07:02 +02:00
|
|
|
IMGFLIP_NAME: Optional[str] = env.str("IMGFLIP_NAME", None)
|
|
|
|
IMGFLIP_PASSWORD: Optional[str] = env.str("IMGFLIP_PASSWORD", None)
|
2022-09-17 19:22:27 +02:00
|
|
|
|
|
|
|
"""Schedule URLs"""
|
|
|
|
BA3_SCHEDULE_URL: Optional[str] = env.str("BA3_SCHEDULE_URL", None)
|
2022-09-25 00:17:36 +02:00
|
|
|
MA_CS_1_SCHEDULE_URL: Optional[str] = env.str("MA_CS_1_SCHEDULE_URL", None)
|
|
|
|
MA_CS_2_SCHEDULE_URL: Optional[str] = env.str("MA_CS_2_SCHEDULE_URL", None)
|
|
|
|
MA_CS_ENG_1_SCHEDULE_URL: Optional[str] = env.str("MA_CS_ENG_1_SCHEDULE_URL", None)
|
|
|
|
MA_CS_ENG_2_SCHEDULE_URL: Optional[str] = env.str("MA_CS_ENG_2_SCHEDULE_URL", None)
|
2022-09-17 19:22:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
"""Computed properties"""
|
|
|
|
|
|
|
|
|
2022-09-17 23:20:46 +02:00
|
|
|
class ScheduleType(str, Enum):
|
|
|
|
"""Enum to differentiate schedules"""
|
|
|
|
|
|
|
|
BA3 = "ba3"
|
2022-09-25 00:17:36 +02:00
|
|
|
MA_CS_1 = "ma_cs_1"
|
|
|
|
MA_CS_2 = "ma_cs_2"
|
|
|
|
MA_CS_ENG_1 = "ma_cs_eng_1"
|
|
|
|
MA_CS_ENG_2 = "ma_cs_eng_2"
|
2022-09-17 23:20:46 +02:00
|
|
|
|
|
|
|
|
2022-09-17 19:22:27 +02:00
|
|
|
@dataclass
|
|
|
|
class ScheduleInfo:
|
|
|
|
"""Dataclass to hold and combine some information about schedule-related settings"""
|
|
|
|
|
|
|
|
role_id: Optional[int]
|
|
|
|
schedule_url: Optional[str]
|
|
|
|
name: Optional[str] = None
|
|
|
|
|
|
|
|
|
2022-09-18 17:25:39 +02:00
|
|
|
SCHEDULE_DATA = [
|
|
|
|
ScheduleInfo(name=ScheduleType.BA3, role_id=BA3_ROLE, schedule_url=BA3_SCHEDULE_URL),
|
2022-09-25 00:17:36 +02:00
|
|
|
ScheduleInfo(name=ScheduleType.MA_CS_1, role_id=MA_CS_1_ROLE, schedule_url=MA_CS_1_SCHEDULE_URL),
|
|
|
|
ScheduleInfo(name=ScheduleType.MA_CS_2, role_id=MA_CS_2_ROLE, schedule_url=MA_CS_2_SCHEDULE_URL),
|
|
|
|
ScheduleInfo(name=ScheduleType.MA_CS_ENG_1, role_id=MA_CS_ENG_1_ROLE, schedule_url=MA_CS_ENG_1_SCHEDULE_URL),
|
|
|
|
ScheduleInfo(name=ScheduleType.MA_CS_ENG_2, role_id=MA_CS_ENG_2_ROLE, schedule_url=MA_CS_ENG_2_SCHEDULE_URL),
|
2022-09-18 17:25:39 +02:00
|
|
|
]
|