forked from luoshuijs/TGGenshinPicBed_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
28 lines (21 loc) · 962 Bytes
/
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
import ujson
import os
class Config(object):
def __init__(self):
project_path = os.path.dirname(__file__)
config_file = os.path.join(project_path, './config', 'config.json')
if not os.path.exists(config_file):
config_file = os.path.join(project_path, './config', 'config.example.json')
with open(config_file, 'r', encoding='utf-8') as f:
self.config_json = ujson.load(f)
self.ADMINISTRATORS = self.get_config('administrators')
self.MYSQL = self.get_config('mysql')
self.REDIS = self.get_config('redis')
self.PIXIV = self.get_config('pixiv')
self.TELEGRAM = self.get_config('telegram')
self.SAUCENAO = self.get_config('saucenao')
def get_config(self, name: str):
# value = os.environ[name] if os.environ.get(name) else self.config_json.get(name, '')
value = self.config_json.get(name, '')
return value
config = Config()