-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
55 lines (42 loc) · 1.46 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
from os import environ
import json
config_path = "./config.json"
class JSONProvider:
def __init__(self, path):
with open(path, "r") as f:
self.__config = json.load(f)
def get(self, *args):
data = self.__config[args[0]]
for i in range(1, len(args), 1):
data = data[args[i]]
return data
class SpotifyCFG(JSONProvider):
def __init__(self):
global config_path
super().__init__(config_path)
self.CLIENT_ID = self.get("SPOTIFY", "CLIENT_ID")
self.CLIENT_SECRET = self.get("SPOTIFY", "CLIENT_SECRET")
class DiscordCFG(JSONProvider):
def __init__(self):
global config_path
super().__init__(config_path)
self.BOT_TOKEN = self.get("DISCORD", "TOKEN")
class TGCFG(JSONProvider):
def __init__(self):
global config_path
super().__init__(config_path)
self.BOT_TOKEN = self.get("TGBOT", "TOKEN")
class DBCFG(JSONProvider):
def __init__(self):
global config_path
super().__init__(config_path)
self.HOST = self.get("DB", "host")
self.USERNAME = self.get("DB", "username")
self.PASSWORD = self.get("DB", "password")
self.DB = self.get("DB", "db")
self.CHARSET = self.get("DB", "charset")
class TikTokCFG(JSONProvider):
def __init__(self):
global config_path
super().__init__(config_path)
self.TOKEN("TIKTOK", "TOKEN")