handle cfg defaults better
This commit is contained in:
parent
48faf4d3b3
commit
99d1d13fbf
1 changed files with 10 additions and 16 deletions
26
main.py
26
main.py
|
@ -12,25 +12,19 @@ import requests
|
||||||
import functions
|
import functions
|
||||||
|
|
||||||
scopes = ["read:statuses", "read:accounts", "read:follows", "write:statuses", "read:notifications"]
|
scopes = ["read:statuses", "read:accounts", "read:follows", "write:statuses", "read:notifications"]
|
||||||
|
#cfg defaults
|
||||||
|
cfg = {
|
||||||
|
"site": "https://botsin.space",
|
||||||
|
"cw": None,
|
||||||
|
"instance_blacklist": ["bofa.lol", "witches.town"],
|
||||||
|
"learn_from_cw": False
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
cfg = json.load(open('config.json', 'r'))
|
cfg.update(json.load(open('config.json', 'r')))
|
||||||
except:
|
except:
|
||||||
shutil.copy2("config.sample.json", "config.json")
|
|
||||||
cfg = json.load(open('config.json', 'r'))
|
|
||||||
|
|
||||||
#config.json should contain the instance URL, the instance blacklist (for dead/broken instances), and the CW text. if they're not provided, we'll fall back to defaults.
|
shutil.copy2("config.sample.json", "config.json")
|
||||||
# TODO: this is pretty messy
|
cfg.update(json.load(open('config.json', 'r')))
|
||||||
if 'site' not in cfg:
|
|
||||||
cfg['website'] = "https://botsin.space"
|
|
||||||
if 'cw' not in cfg:
|
|
||||||
cfg['cw'] = None
|
|
||||||
if 'instance_blacklist' not in cfg:
|
|
||||||
cfg["instance_blacklist"] = [
|
|
||||||
"bofa.lol",
|
|
||||||
"witches.town"
|
|
||||||
]
|
|
||||||
if 'learn_from_cw' not in cfg:
|
|
||||||
cfg['learn_from_cw'] = False
|
|
||||||
|
|
||||||
#if the user is using a (very!) old version that still uses the .secret files, migrate to the new method
|
#if the user is using a (very!) old version that still uses the .secret files, migrate to the new method
|
||||||
if os.path.exists("clientcred.secret"):
|
if os.path.exists("clientcred.secret"):
|
||||||
|
|
Loading…
Reference in a new issue