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/favoIMP/__init__.py | |
parent | 681b8c7c8841c8c889f77bf54d1cf1ce9914c016 (diff) | |
download | ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.gz ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.bz2 ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.zip |
[Update]
Diffstat (limited to 'ATRI/modules/favoIMP/__init__.py')
-rw-r--r-- | ATRI/modules/favoIMP/__init__.py | 58 |
1 files changed, 58 insertions, 0 deletions
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 |