summaryrefslogtreecommitdiff
path: root/ATRI/modules
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-09-13 16:36:05 +0800
committerKyomotoi <[email protected]>2020-09-13 16:36:05 +0800
commit9c91cc1c7f39a7178e753d5f32a707db0ae19790 (patch)
tree3c6c24745985fc8703a3dab1d188c0bade31c2af /ATRI/modules
parent681b8c7c8841c8c889f77bf54d1cf1ce9914c016 (diff)
downloadATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.gz
ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.tar.bz2
ATRI-9c91cc1c7f39a7178e753d5f32a707db0ae19790.zip
[Update]
Diffstat (limited to 'ATRI/modules')
-rw-r--r--ATRI/modules/favoIMP/__init__.py58
-rw-r--r--ATRI/modules/favoIMP/user.json1
-rw-r--r--ATRI/modules/funcControl/__init__.py34
-rw-r--r--ATRI/modules/time/__init__.py24
4 files changed, 110 insertions, 7 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
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