Merge branch 'master' of https://git.profitroll.eu/profitroll/HoloCheckerBot
This commit is contained in:
@@ -20,7 +20,6 @@ def jsonLoad(filename):
|
||||
except FileNotFoundError:
|
||||
logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{print_exc()}")
|
||||
raise
|
||||
file.close()
|
||||
return output
|
||||
|
||||
def jsonSave(contents, filename):
|
||||
@@ -28,7 +27,6 @@ def jsonSave(contents, filename):
|
||||
try:
|
||||
with open(filename, "w", encoding='utf8') as file:
|
||||
file.write(dumps(contents, ensure_ascii=False, indent=4))
|
||||
file.close()
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not save json file {filename}: {exp}\n{print_exc()}")
|
||||
return
|
||||
@@ -44,7 +42,8 @@ def configSet(key: str, value, *args: str, file: str = "config"):
|
||||
"""
|
||||
if file == "config":
|
||||
filepath = ""
|
||||
if this_dict["debug"]:
|
||||
this_dict = jsonLoad(f"{filepath}{file}.json")
|
||||
if this_dict["debug"] is True:
|
||||
try:
|
||||
this_dict = jsonLoad("config_debug.json")
|
||||
file = "config_debug"
|
||||
@@ -52,12 +51,16 @@ def configSet(key: str, value, *args: str, file: str = "config"):
|
||||
print("Debug mode is set but config_debug.json is not there! Falling back to config.json", flush=True)
|
||||
else:
|
||||
filepath = f"data{sep}users{sep}"
|
||||
this_dict = jsonLoad(f"{filepath}{file}.json")
|
||||
this_dict = jsonLoad(f"{filepath}{file}.json")
|
||||
string = "this_dict"
|
||||
for arg in args:
|
||||
string += f'["{arg}"]'
|
||||
if type(value) in [str]:
|
||||
string += f'["{key}"] = "{value}"'
|
||||
value.replace("'", "\'").replace('"', '\"')
|
||||
#if len(value) < 30:
|
||||
# string += f'["{key}"] = "{value}"'
|
||||
#else:
|
||||
string += f'["{key}"] = """{value}"""'
|
||||
else:
|
||||
string += f'["{key}"] = {value}'
|
||||
exec(string)
|
||||
@@ -79,7 +82,7 @@ def configGet(key: str, *args: str, file: str = "config"):
|
||||
except FileNotFoundError:
|
||||
print("Config file not found! Copy config_example.json to config.json, configure it and rerun the bot!", flush=True)
|
||||
exit()
|
||||
if this_dict["debug"]:
|
||||
if this_dict["debug"] is True:
|
||||
try:
|
||||
this_dict = jsonLoad("config_debug.json")
|
||||
except FileNotFoundError:
|
||||
|
Reference in New Issue
Block a user