diff options
author | Kyomotoi <[email protected]> | 2021-07-31 16:21:23 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-07-31 16:21:23 +0800 |
commit | 1d54ec291f2c25cc01f24d0d0163d0bf889457fd (patch) | |
tree | 251004df3f659f79b96b9abce59cc1140e24498c /ATRI/plugins/setu/data_source.py | |
parent | beb16b60fe4d8586436f5ada5fdabb6db23f5a29 (diff) | |
parent | 36d26d1dc61c36b4601aaf75e148060c5bcb98a7 (diff) | |
download | ATRI-1d54ec291f2c25cc01f24d0d0163d0bf889457fd.tar.gz ATRI-1d54ec291f2c25cc01f24d0d0163d0bf889457fd.tar.bz2 ATRI-1d54ec291f2c25cc01f24d0d0163d0bf889457fd.zip |
Merge branch 'main' of https://github.com/Kyomotoi/ATRI into main
Diffstat (limited to 'ATRI/plugins/setu/data_source.py')
-rw-r--r-- | ATRI/plugins/setu/data_source.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/ATRI/plugins/setu/data_source.py b/ATRI/plugins/setu/data_source.py index 22fa69f..47f76b6 100644 --- a/ATRI/plugins/setu/data_source.py +++ b/ATRI/plugins/setu/data_source.py @@ -1,4 +1,5 @@ import base64 + # from pathlib import Path from random import choice from nonebot.adapters.cqhttp import MessageSegment @@ -16,10 +17,9 @@ SCHEDULER_FORMAT = """ class Setu(Service): - def __init__(self): Service.__init__(self, "涩图", "hso!", rule=is_in_service("涩图")) - + @staticmethod async def random_setu() -> tuple: """ @@ -28,14 +28,14 @@ class Setu(Service): res = await request.get(LOLICON_URL) data: dict = await res.json() temp_data: dict = data.get("data", list())[0] - - title = temp_data.get("title", "木陰のねこ") + + title = temp_data.get("title", "木陰のねこ") p_id = temp_data.get("pid", 88124144) url = temp_data["urls"].get("original", "ignore") - + setu = MessageSegment.image(url, timeout=114514) return setu, title, p_id - + @staticmethod async def tag_setu(tag: str) -> tuple: """ @@ -44,18 +44,18 @@ class Setu(Service): url = LOLICON_URL + f"?tag={tag}" res = await request.get(url) data: dict = await res.json() - + temp_data: dict = data.get("data", list())[0] if not temp_data: is_ok = False is_ok = True - - title = temp_data.get("title", "木陰のねこ") + + title = temp_data.get("title", "木陰のねこ") p_id = temp_data.get("pid", 88124144) url = temp_data["urls"].get("original", "ignore") setu = MessageSegment.image(url, timeout=114514) return setu, title, p_id, is_ok - + @staticmethod async def scheduler() -> str: """ @@ -67,13 +67,10 @@ class Setu(Service): res = await request.get(LOLICON_URL) data: dict = await res.json() temp_data: dict = data.get("data", list())[0] - + tag = choice(temp_data.get("tags", ["女孩子"])) - + url = temp_data["urls"].get("original", "ignore") setu = MessageSegment.image(url, timeout=114514) - repo = SCHEDULER_FORMAT.format( - tag=tag, - setu=setu - ) + repo = SCHEDULER_FORMAT.format(tag=tag, setu=setu) return repo |