2021-10-26 21:08:55 +00:00
|
|
|
from dataclasses import asdict, dataclass, field
|
|
|
|
from pathlib import Path
|
2021-10-26 19:05:45 +00:00
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Config:
|
2021-10-26 21:08:55 +00:00
|
|
|
PLAYERS = [
|
|
|
|
"Kamui",
|
|
|
|
"Oji",
|
|
|
|
"Dan",
|
|
|
|
"Tora",
|
|
|
|
"Delphine",
|
|
|
|
"Philia",
|
|
|
|
"Hanabi",
|
|
|
|
"Nona",
|
|
|
|
"Ennea",
|
|
|
|
]
|
|
|
|
|
|
|
|
discord_token: str = ""
|
|
|
|
guild: int = None
|
|
|
|
vote_category: int = None
|
|
|
|
secret_category: int = None
|
|
|
|
vote_channels: dict[str, int] = field(default_factory=dict)
|
|
|
|
backdoor_channel: int = None
|
|
|
|
telepathy_channel: int = None
|
2021-11-08 13:01:43 +00:00
|
|
|
brother_channel: int = None
|
|
|
|
brother_channel_webhook: int = None
|
2021-11-13 15:00:08 +00:00
|
|
|
sisters_channel: int = None
|
2021-10-26 21:08:55 +00:00
|
|
|
player_roles: dict[str, int] = field(default_factory=dict)
|
2021-11-13 14:54:59 +00:00
|
|
|
http_host: str = '127.0.0.1'
|
|
|
|
http_port: int = 5000
|
|
|
|
http_debug: bool = True
|
2021-10-26 19:05:45 +00:00
|
|
|
|
|
|
|
@classmethod
|
2021-11-12 13:32:02 +00:00
|
|
|
def load(cls, filename: str | None = None) -> "Config":
|
2021-10-26 21:08:55 +00:00
|
|
|
if filename is None:
|
|
|
|
filename = Path(__file__).parent.parent / 'config.yml'
|
|
|
|
|
2021-10-26 19:05:45 +00:00
|
|
|
with open(filename) as config_file:
|
2021-10-26 21:08:55 +00:00
|
|
|
return Config(**(yaml.safe_load(config_file) or {}))
|
|
|
|
|
2021-11-12 13:32:02 +00:00
|
|
|
def save(self, filename: str | None = None) -> None:
|
2021-10-26 21:08:55 +00:00
|
|
|
if filename is None:
|
|
|
|
filename = Path(__file__).parent.parent / 'config.yml'
|
|
|
|
|
|
|
|
with open(filename, 'w') as config_file:
|
|
|
|
yaml.safe_dump(asdict(self), config_file)
|