From 3e592878f9fbb8ad7e458676f6cf65c09d8f76ed Mon Sep 17 00:00:00 2001 From: Ricky8955555 Date: Sat, 13 May 2023 21:35:29 +0800 Subject: [PATCH] =?UTF-8?q?pixiv=20=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87=20?= =?UTF-8?q?ID=20=E8=8E=B7=E5=8F=96=E6=8F=92=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pixiv/main.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/pixiv/main.py b/pixiv/main.py index c75c8b3..6d89e93 100644 --- a/pixiv/main.py +++ b/pixiv/main.py @@ -219,7 +219,7 @@ def illust_sensitive_content_filter( illust for illust in illusts if not excluded.intersection(illust.tags) - and (needed.intersection(illust.tags) if needed else True) + and (not needed or len(needed.intersection(illust.tags)) == len(needed)) ] @@ -228,7 +228,7 @@ def illust_filter_by_tags(illusts: List[Illust], keywords: str) -> List[Illust]: return [ illust for illust in illusts - if (needed.intersection(illust.tags) if needed else True) + if not needed or len(needed.intersection(illust.tags)) == len(needed) ] @@ -358,6 +358,26 @@ async def help_cmd(_: Client, message: Message) -> None: ) +@cmdman.subcommand( + "id", "根据 ID 获取 Pixiv 相关插图", "" +) +async def id_cmd(_: Client, message: Message) -> None: + try: + id_ = int(message.arguments) + except ValueError: + await message.edit("你输入的不是正确的 ID 诶www") + return + await message.edit("正在发送中,请耐心等待www") + api = await get_api() + response = await api.illust_detail(id_) + if not (response := response.get("illust")): + await message.edit("呜呜呜 ~ 没有找到相应结果。") + return + illust = Illust.from_response(response) + await send_illust(message, illust) + await message.safe_delete() + + @cmdman.subcommand("alias", "重定向子命令", "{del <子指令>|list|set <子指令> <重定向子指令>}") async def alias_cmd(_: Client, message: Message) -> None: if not message.arguments: