forked from daisyUniverse/TwitFix
-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathconfigHandler.py
More file actions
46 lines (43 loc) · 2.09 KB
/
configHandler.py
File metadata and controls
46 lines (43 loc) · 2.09 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
import json
import os
if ('RUNNING_SERVERLESS' in os.environ and os.environ['RUNNING_SERVERLESS'] == '1'): # pragma: no cover
config = {
"config":{
"link_cache":os.getenv("VXTWITTER_LINK_CACHE","none"),
"database":os.getenv("VXTWITTER_DATABASE",""),
"table":os.getenv("VXTWITTER_CACHE_TABLE",""),
"color":os.getenv("VXTWITTER_COLOR",""),
"appname": os.getenv("VXTWITTER_APP_NAME","vxTwitter"),
"repo": os.getenv("VXTWITTER_REPO","https://github.com/dylanpdx/BetterTwitFix"),
"url": os.getenv("VXTWITTER_URL","https://vxtwitter.com"),
"combination_method": os.getenv("VXTWITTER_COMBINATION_METHOD","local"), # can either be 'local' or a URL to a server handling requests in the same format
"gifConvertAPI":os.getenv("VXTWITTER_GIF_CONVERT_API",""),
"workaroundTokens":os.getenv("VXTWITTER_WORKAROUND_TOKENS",None),
"deeplKey":os.getenv("DEEPL_API_KEY",None),
}
}
else:
# Read config from config.json. If it does not exist, create new.
if not os.path.exists("config.json"):
with open("config.json", "w") as outfile:
default_config = {
"config":{
"link_cache":"json",
"database":"[url to mongo database goes here]",
"table":"TwiFix",
"color":"#43B581",
"appname": "vxTwitter",
"repo": "https://github.com/dylanpdx/BetterTwitFix",
"url": "https://vxtwitter.com",
"combination_method": "local", # can either be 'local' or a URL to a server handling requests in the same format
"gifConvertAPI":"",
"workaroundTokens":None,
"deeplKey":None
}
}
json.dump(default_config, outfile, indent=4, sort_keys=True)
config = default_config
else:
f = open("config.json")
config = json.load(f)
f.close()