-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
98 lines (68 loc) · 3.53 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from dynaconf import Dynaconf, Validator
from typing import Dict, List, Optional
_settings = Dynaconf(
envvar_prefix="ROULETTE",
environments=True,
load_dotenv=True,
settings_files=[
'settings.toml',
'.secrets.toml',
'settings.yml',
'.secrets.yml'
],
validators=[
# Bot settings
Validator("log_level", is_type_of=str),
Validator("bot_token", must_exist=True, is_type_of=str),
# Roulette settings
Validator("roulette_channels", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_protected_roles", is_type_of=list),
Validator("roulette_moderator_roles", is_type_of=list),
Validator("roulette_administrator_users", is_type_of=list),
Validator("roulette_roll_match_patterns", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_roll_timeout_affected_messages_self", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_roll_timeout_affected_messages_other", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_roll_timeout_protected_messages_self", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_roll_timeout_protected_messages_other", must_exist=True, is_type_of=list, len_min=1),
Validator("roulette_roll_timeout_leaderboard_webhook_urls", is_type_of=list),
Validator("roulette_roll_timeout_response_delay_seconds", is_type_of=int),
Validator("roulette_roll_timeout_intervals", must_exist=True, is_type_of=list)
]
)
def log_level() -> str:
"""
:return: The logging level that should be used for this application. Does not affect Discord.py logging.
"""
return str(_settings.get("log_level", "INFO")).upper()
def bot_token() -> str:
"""
:return: The bot token, as a string.
"""
return _settings.get("bot_token")
def roulette_roll_match_patterns() -> List[str]:
return _settings.get("roulette_roll_match_patterns")
def roulette_channels() -> List[str]:
return _settings.get("roulette_channels")
def roulette_protected_roles() -> Optional[List[str]]:
return _settings.get("roulette_protected_roles")
def roulette_moderator_roles() -> Optional[List[str]]:
return _settings.get("roulette_moderator_roles")
def roulette_administrator_users() -> Optional[List[str]]:
return _settings.get("roulette_administrator_users")
def roulette_roll_timeout_affected_messages_self() -> List[str]:
return _settings.get("roulette_roll_timeout_affected_messages_self")
def roulette_roll_timeout_affected_messages_other() -> List[str]:
return _settings.get("roulette_roll_timeout_affected_messages_other")
def roulette_roll_timeout_protected_messages_self() -> List[str]:
return _settings.get("roulette_roll_timeout_protected_messages_self")
def roulette_roll_timeout_protected_messages_other() -> List[str]:
return _settings.get("roulette_roll_timeout_protected_messages_other")
def roulette_roll_timeout_leaderboard_webhook_urls() -> Optional[List[str]]:
return _settings.get("roulette_roll_timeout_leaderboard_webhook_urls")
def roulette_roll_timeout_response_delay_seconds() -> Optional[int]:
return _settings.get("roulette_roll_timeout_response_delay_seconds")
def roulette_roll_timeout_intervals() -> List[Dict]:
return _settings.get("roulette_roll_timeout_intervals")
# `envvar_prefix` = export envvars with `export ROULETTE_FOO=bar`.
# `settings_files` = Load these files in the order.
# `environments` = Export `ENV_FOR_DYNACONF=` to set an environment.