diff options
author | Kyomotoi <[email protected]> | 2020-09-13 16:36:05 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2020-09-13 16:36:05 +0800 |
commit | 9c91cc1c7f39a7178e753d5f32a707db0ae19790 (patch) | |
tree | 3c6c24745985fc8703a3dab1d188c0bade31c2af /ATRI/modules/funcControl/__init__.py | |
parent | 681b8c7c8841c8c889f77bf54d1cf1ce9914c016 (diff) | |
download | ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.gz ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.bz2 ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.zip |
[Update]
Diffstat (limited to 'ATRI/modules/funcControl/__init__.py')
-rw-r--r-- | ATRI/modules/funcControl/__init__.py | 34 |
1 files changed, 27 insertions, 7 deletions
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 |