fix: global plugin config read

This commit is contained in:
zhayujie
2023-07-20 14:24:40 +08:00
parent 954e55f4b4
commit 4bab4299f2
5 changed files with 38 additions and 29 deletions

View File

@@ -180,14 +180,16 @@ class Godcmd(Plugin):
curdir = os.path.dirname(__file__)
config_path = os.path.join(curdir, "config.json")
gconf = None
if not os.path.exists(config_path):
gconf = {"password": "", "admin_users": []}
with open(config_path, "w") as f:
json.dump(gconf, f, indent=4)
else:
with open(config_path, "r") as f:
gconf = super().load_config() or json.load(f)
# loading config from global plugin config
gconf = super().load_config()
if not gconf:
if not os.path.exists(config_path):
gconf = {"password": "", "admin_users": []}
with open(config_path, "w") as f:
json.dump(gconf, f, indent=4)
else:
with open(config_path, "r") as f:
gconf = json.load(f)
if gconf["password"] == "":
self.temp_password = "".join(random.sample(string.digits, 4))
logger.info("[Godcmd] 因未设置口令,本次的临时口令为%s" % self.temp_password)