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/favoIMP/__init__.py | 58 ++++++++++++++++++++++++++++++++++++ ATRI/modules/favoIMP/user.json | 1 + ATRI/modules/funcControl/__init__.py | 34 ++++++++++++++++----- ATRI/modules/time/__init__.py | 24 +++++++++++++++ 4 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 ATRI/modules/favoIMP/__init__.py create mode 100644 ATRI/modules/favoIMP/user.json create mode 100644 ATRI/modules/time/__init__.py (limited to 'ATRI/modules') diff --git a/ATRI/modules/favoIMP/__init__.py b/ATRI/modules/favoIMP/__init__.py new file mode 100644 index 0000000..3dabdae --- /dev/null +++ b/ATRI/modules/favoIMP/__init__.py @@ -0,0 +1,58 @@ +import json +from random import randint +from pathlib import Path + +def GetFavoIMP(u): + try: + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as f: + data = json.load(f) + except: + return 0 + + try: + if data[f"{u}"][0]: + pass + else: + return 0 + except: + return 0 + + return [data[f"{u}"][0], data[f"{u}"][1]] + +def AddFavoIMP(u, f:int, s:bool): + if s: + favoIMP = randint(1,f) + else: + favoIMP = f + try: + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as a: + data = json.load(a) + data[f"{u}"][0] = int(data[f"{u}"][0]) + favoIMP + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as a: + a.write(json.dumps(data)) + a.close() + except: + data = {} + data[f"{u}"] = [f"{favoIMP}"] + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as a: + a.write(json.dumps(data)) + a.close() + +def DelFavoIMP(u, f:int, s:bool): + if s: + favoIMP = randint(1,f) + else: + favoIMP = f + try: + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as a: + data = json.load(a) + data[f"{u}"][0] = int(data[f"{u}"][0]) - favoIMP + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as a: + a.write(json.dumps(data)) + a.close() + except: + data = {} + data[f"{u}"] = [f"{0 - favoIMP}"] + with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as a: + a.write(json.dumps(data)) + a.close() \ No newline at end of file diff --git a/ATRI/modules/favoIMP/user.json b/ATRI/modules/favoIMP/user.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/ATRI/modules/favoIMP/user.json @@ -0,0 +1 @@ +{} \ No newline at end of file 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 diff --git a/ATRI/modules/time/__init__.py b/ATRI/modules/time/__init__.py new file mode 100644 index 0000000..6e7806d --- /dev/null +++ b/ATRI/modules/time/__init__.py @@ -0,0 +1,24 @@ +from random import choice +from datetime import datetime + +def now_time(): + now_ = datetime.now() + hour = now_.hour + minute = now_.minute + now = hour + minute / 60 + return now + +def sleepTime(): + if 0 <= now_time() < 5.5: + msg = choice( + [ + 'zzzz......', + 'zzzzzzzz......', + 'zzz...好涩哦..zzz....', + '别...不要..zzz..那..zzz..', + '嘻嘻..zzz..呐~..zzzz..' + ] + ) + return msg + else: + return False \ No newline at end of file -- cgit v1.2.3