-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
68 lines (49 loc) · 1.98 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
def get_environment():
from os import getenv
from dotenv import load_dotenv
load_dotenv()
ENV_TYPE: str = getenv("ENV_TYPE")
if ENV_TYPE == "PROD":
ENV_TOKEN = "BOT_TOKEN"
ENV_MONGODB_HOST = "MONGODB_HOST"
ENV_MONGODB_PORT = "MONGODB_PORT"
ENV_MONGODB_DATABASE = "MONGODB_DATABASE"
ENV_MONGODB_USERNAME = "MONGODB_USERNAME"
ENV_MONGODB_PASSWORD = "MONGODB_PASSWORD"
elif ENV_TYPE == "DEV":
ENV_TOKEN = "DEV_BOT_TOKEN"
ENV_MONGODB_HOST = "DEV_MONGODB_HOST"
ENV_MONGODB_PORT = "DEV_MONGODB_PORT"
ENV_MONGODB_DATABASE = "DEV_MONGODB_DATABASE"
ENV_MONGODB_USERNAME = "DEV_MONGODB_USERNAME"
ENV_MONGODB_PASSWORD = "DEV_MONGODB_PASSWORD"
else:
raise "Неверная конфигурация среды"
TOKEN: str = getenv(ENV_TOKEN)
if TOKEN is None:
raise f"{ENV_TOKEN} не установлен"
MONGODB_HOST: str = getenv(ENV_MONGODB_HOST)
if MONGODB_HOST is None:
raise f"{ENV_MONGODB_HOST} не установлен"
MONGODB_PORT: str = getenv(ENV_MONGODB_PORT)
if MONGODB_PORT is None:
raise f"{ENV_MONGODB_PORT} не установлен"
MONGODB_DATABASE: str = getenv(ENV_MONGODB_DATABASE)
if MONGODB_DATABASE is None:
raise f"{ENV_MONGODB_DATABASE} не установлен"
MONGODB_USERNAME: str = getenv(ENV_MONGODB_USERNAME)
if MONGODB_USERNAME is None:
raise f"{ENV_MONGODB_USERNAME} не установлен"
MONGODB_PASSWORD: str = getenv(ENV_MONGODB_PASSWORD)
if MONGODB_PASSWORD is None:
raise f"{ENV_MONGODB_PASSWORD} не установлен"
config = {
"BOT_TOKEN": TOKEN,
"MONGODB_HOST": MONGODB_HOST,
"MONGODB_PORT": MONGODB_PORT,
"MONGODB_DATABASE": MONGODB_DATABASE,
"MONGODB_USERNAME": MONGODB_USERNAME,
"MONGODB_PASSWORD": MONGODB_PASSWORD,
}
return config
EXPIRATION_TIME_LIMIT_SECONDS = 86400