-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
46 lines (37 loc) · 1.22 KB
/
settings.py
File metadata and controls
46 lines (37 loc) · 1.22 KB
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
from environs import Env
from dataclasses import dataclass
@dataclass
class Bots:
TELEGRAM_TOKEN: str
TELEGRAM_ADMIN_CHAT_ID: int
OPENWEATHERMAP_TOKEN: str
IS_WORK_REDIS_DB: bool
REDIS_HOST: str
REDIS_PORT: int
REDIS_CURS_DB_NO: int
REDIS_SECURITIES_DB_NO: int
REDIS_STORAGE_DB_NO: int
REDIS_STORAGE_JOB_DB_NO: int
REDIS_PASSWORD: str
@dataclass
class Settings:
bots: Bots
def get_settings(path: str):
env = Env()
env.read_env(path)
return Settings(
bots=Bots(
TELEGRAM_TOKEN=env.str('TELEGRAM_TOKEN'),
TELEGRAM_ADMIN_CHAT_ID=env.int('TELEGRAM_ADMIN_CHAT_ID'),
OPENWEATHERMAP_TOKEN=env.str('OPENWEATHERMAP_TOKEN'),
IS_WORK_REDIS_DB=env.bool('IS_WORK_REDIS_DB'),
REDIS_HOST=env.str('REDIS_HOST'),
REDIS_PORT=env.int('REDIS_PORT'),
REDIS_CURS_DB_NO=env.int('REDIS_CURS_DB_NO'),
REDIS_SECURITIES_DB_NO=env.int('REDIS_SECURITIES_DB_NO'),
REDIS_STORAGE_DB_NO=env.int('REDIS_STORAGE_DB_NO'),
REDIS_STORAGE_JOB_DB_NO=env.int('REDIS_STORAGE_JOB_DB_NO'),
REDIS_PASSWORD=env.str('REDIS_PASSWORD')
)
)
settings = get_settings('settings')