From 9c91cc1c7f39a7178e753d5f32a707db0ae19790 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 13 Sep 2020 16:36:05 +0800 Subject: [Update] --- ATRI/modules/funcControl/__init__.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'ATRI/modules/funcControl/__init__.py') diff --git a/ATRI/modules/funcControl/__init__.py b/ATRI/modules/funcControl/__init__.py index 089e673..f4dac26 100644 --- a/ATRI/modules/funcControl/__init__.py +++ b/ATRI/modules/funcControl/__init__.py @@ -1,3 +1,4 @@ +import os import json from pathlib import Path from typing import Optional @@ -10,14 +11,33 @@ def checkSwitch(funcName: str, g: int): if data[funcName] == "off": return False else: - file = Path('.') / 'ATRI' / 'data' / 'groupData' / f'{g}' / 'switch.json' - with open(file, 'r') as f: - data = json.load(f) + try: + file = Path('.') / 'ATRI' / 'data' / 'groupData' / f'{g}' / 'switch.json' + with open(file, 'r') as f: + data = json.load(f) + except: + try: + os.mkdir(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{g}') + except: + pass + data = {} + data["pixiv_seach_img"] = "on" + data["pixiv_seach_author"] = "on" + data["pixiv_daily_rank"] = "on" + data["setu"] = "on" + data["setu_img"] = "on" + data["anime_search"] = "on" + data["change_face"] = "on" + data["chouYou"] = "on" + data["saucenao_search"] = "on" + with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{g}' / 'switch.json', 'w') as f: + f.write(json.dumps(data)) + f.close() if data[funcName] == "on": return True -def checkNoob(user: int, group: Optional[int] = None): +def checkNoob(u: int, g: Optional[int] = None): fileU = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' fileG = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json' try: @@ -32,9 +52,9 @@ def checkNoob(user: int, group: Optional[int] = None): except: dataG = {} - if str(user) not in dataU.keys(): - if group: - if str(group) not in dataG.keys(): + if str(u) not in dataU.keys(): + if g: + if str(g) not in dataG.keys(): return True else: return True -- cgit v1.2.3