-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
34 lines (28 loc) · 1.12 KB
/
config.py
File metadata and controls
34 lines (28 loc) · 1.12 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
import os
import yaml
secrets_path = "secrets.yaml"
ENV = bool(os.environ.get('ENV', False))
if ENV:
apiID = os.environ.get('apiID', None)
apiHASH = os.environ.get('apiHASH', None)
botTOKEN = os.environ.get('botTOKEN', None)
MongoDB_URI = os.environ.get("mongouri", "")
database = os.environ.get("database", None)
user_collection = os.environ.get('userCollection', "usercache")
group_collection = os.environ.get('groupCollection', "groupcache")
collection = {'user': user_collection, 'group': group_collection}
elif os.path.isfile(secrets_path):
yaml_file = open(secrets_path, 'r')
yaml_content = yaml.load(yaml_file, Loader=yaml.FullLoader)
apiID = yaml_content['telegram'][0]['apiID']
apiHASH = yaml_content['telegram'][1]['apiHASH']
botTOKEN = yaml_content['telegram'][2]['botTOKEN']
MongoDB_URI = yaml_content['MongoDB'][0]['URI']
database = yaml_content['MongoDB'][1]["database"]
collection = yaml_content['MongoDB'][2]["collection"]
print(collection)
else:
print(
'This app is not configured correctly. Check README or contact support.'
)
quit(1)