diff options
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 |