summaryrefslogtreecommitdiff
path: root/ATRI/plugins/setu.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-12 00:05:21 +0800
committerKyomotoi <[email protected]>2020-08-12 00:05:21 +0800
commitb11b204043451334c33d827b776f230b6c8e84ce (patch)
tree32a1e42a3871e34401775bf7843444f3eeaa904a /ATRI/plugins/setu.py
parent0cd82d9166c38fa455895cc236f406902e8e6549 (diff)
downloadATRI-b11b204043451334c33d827b776f230b6c8e84ce.tar.gz
ATRI-b11b204043451334c33d827b776f230b6c8e84ce.tar.bz2
ATRI-b11b204043451334c33d827b776f230b6c8e84ce.zip
[Fix]
Diffstat (limited to 'ATRI/plugins/setu.py')
-rw-r--r--ATRI/plugins/setu.py115
1 files changed, 61 insertions, 54 deletions
diff --git a/ATRI/plugins/setu.py b/ATRI/plugins/setu.py
index cbf8ff6..70ef0b4 100644
--- a/ATRI/plugins/setu.py
+++ b/ATRI/plugins/setu.py
@@ -30,71 +30,78 @@ Complete time:{time}s"""
@on_command('setu', patterns = (r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]|[图圖]来|[我你她他它]想要[点丶张份副][涩色瑟][图圖]|我想要[1一][张份幅副个只][涩色瑟][图圖]|[我你她他它]想[看|look][涩涩|色色]的东西"), only_to_me = False)
async def setu(session: CommandSession):
group = session.event.group_id
- with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
- if data["setu"] == 0:
- await session.send('别急!正在找图!')
- start = time.perf_counter()
- values = {
- "apikey": apikey,
- "r18": "0",
- "num": "1"
- }
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:
+ data = json.load(f)
- res = randint(1,10)
- if 1 <= res <= 9:
- res = randint(1,4)
- if 1 <= res <= 3:
- try:
- dc = json.loads(response.request_api_params(URL, values))
- title = dc["data"][0]["title"]
- pid = dc["data"][0]["pid"]
- setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"])
- except:
- await session.send('失败了失败了失败了失...')
- return
-
+ if data["setu"] == 0:
+ await session.send('别急!正在找图!')
+ start = time.perf_counter()
+ values = {
+ "apikey": apikey,
+ "r18": "0",
+ "num": "1"
+ }
- res = randint(1,3)
- if 1 <= res <= 2:
- end = time.perf_counter()
- await session.send(
- SETU_REPLY.format(
- title = title,
- pid = pid,
- setu = dc["data"][0]["url"],
- time = round(end - start, 3)
+ res = randint(1,10)
+ if 1 <= res <= 9:
+ res = randint(1,4)
+ if 1 <= res <= 3:
+ try:
+ dc = json.loads(response.request_api_params(URL, values))
+ title = dc["data"][0]["title"]
+ pid = dc["data"][0]["pid"]
+ setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"])
+ except:
+ await session.send('失败了失败了失败了失...')
+ return
+
+
+ res = randint(1,3)
+ if 1 <= res <= 2:
+ end = time.perf_counter()
+ await session.send(
+ SETU_REPLY.format(
+ title = title,
+ pid = pid,
+ setu = dc["data"][0]["url"],
+ time = round(end - start, 3)
+ )
+ )
+
+ elif res == 3:
+ await session.send('我找到涩图了!但我发给主人了ο(=•ω<=)ρ⌒☆')
+ end = time.perf_counter()
+ await bot.send_private_msg( # type: ignore
+ user_id = master,
+ message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"
)
- )
- elif res == 3:
- await session.send('我找到涩图了!但我发给主人了ο(=•ω<=)ρ⌒☆')
- end = time.perf_counter()
- await bot.send_private_msg( # type: ignore
- user_id = master,
- message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"
+ elif res == 4:
+ img = choice(
+ [
+ 'SP.jpg', 'SP1.jpg', 'SP2.jpg'
+ ]
)
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
+
- elif res == 4:
+ elif res == 10:
img = choice(
[
- 'SP.jpg', 'SP1.jpg', 'SP2.jpg'
+ 'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg'
]
)
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
+ img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{img}'
await session.send(f'[CQ:image,file=file:///{img}]')
-
- elif res == 10:
- img = choice(
- [
- 'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg'
- ]
- )
- img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{img}'
- await session.send(f'[CQ:image,file=file:///{img}]')
-
- else:
- await session.send('该功能已被禁用...') \ No newline at end of file
+ else:
+ await session.send('该功能已被禁用...') \ No newline at end of file