Merge pull request #1301 from YuS1aN/main

色图bug修复、增加指令
This commit is contained in:
HibiKier 2023-03-12 19:55:21 +08:00 committed by GitHub
commit ca9933a489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -1,5 +1,4 @@
import random
import re
from typing import Any, Optional, Tuple, Type
from nonebot import on_command, on_regex
@ -52,14 +51,15 @@ usage
色图 *[tags]: 在线搜索指定tag色图
色图r *[tags]: 同上
[1-9]张涩图: 本地随机色图连发
[1-9][tags]的涩图: 指定tag色图连发
[1-9][tags]的涩图: 在线搜索指定tag色图连发
[1-9]张涩图r[tags]: 同上
示例色图 萝莉|少女 白丝|黑丝
示例色图 萝莉 猫娘
tag至多取前20项| 为或萝莉|少女=萝莉或者少女
""".strip()
__plugin_des__ = "不要小看涩图啊混蛋!"
__plugin_cmd__ = ["色图 ?[id]", "色图 ?[tags]", "色图r ?[tags]", "[1-9]张?[tags]色图"]
__plugin_cmd__ = ["色图 ?[id]", "色图 ?[tags]", "色图r ?[tags]", "[1-9]张?[tags]色图", "[1-9]张色图?[tags]"]
__plugin_type__ = ("来点好康的",)
__plugin_version__ = 0.1
__plugin_author__ = "HibiKier"
@ -117,6 +117,12 @@ __plugin_configs__ = {
"default_value": None,
"type": int,
},
"MAX_ONCE_NUM": {
"value": 10,
"help": "单次发送图片数量限制",
"default_value": 10,
"type": int,
},
}
Config.add_plugin_config("pixiv", "PIXIV_NGINX_URL", "i.pixiv.re", help_="Pixiv反向代理")
@ -147,7 +153,7 @@ setu = on_command(
"色图", aliases={"涩图", "不够色", "来一发", "再来点", "色图r"}, priority=5, block=True
)
setu_reg = on_regex("(.*)[份|发|张|个|次|点](.*)[瑟|色|涩]图$", priority=5, block=True)
setu_reg = on_regex("(.*)[份|发|张|个|次|点](.*)[瑟|色|涩]图(r?)(.*)$", priority=5, block=True)
@setu.handle()
@ -228,7 +234,7 @@ async def _(bot: Bot, event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGro
luox = get_luoxiang(impression)
if luox:
await setu.finish(luox, at_sender=True)
num, tags = reg_group
num, tags, r18, tags2 = reg_group
num = num or 1
tags = tags[:-1] if tags and tags[-1] == "" else tags
if num_key.get(num):
@ -237,7 +243,16 @@ async def _(bot: Bot, event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGro
num = int(num)
except ValueError:
num = 1
await send_setu_handle(bot, setu_reg, event, "色图", tags, num, False)
if r18 and not Config.get_config("send_setu", "ALLOW_GROUP_R18"):
await setu.finish(
random.choice(["这种不好意思的东西怎么可能给这么多人看啦", "羞羞脸!给我滚出克私聊!", "变态变态变态变态大变态!"])
)
else:
limit = Config.get_config("send_setu", "MAX_ONCE_NUM")
if limit and num > limit:
num = limit
await setu.send(f"一次只能给你看 {num} 张哦")
await send_setu_handle(bot, setu_reg, event, "色图r" if r18 else "色图", tags + " " + tags2, num, r18)
async def send_setu_handle(

View File

@ -138,7 +138,7 @@ async def check_local_exists_or_download(
file = IMAGE_PATH / path_ / f"{setu_image.local_id}.jpg"
if file.exists():
change_img_md5(file)
return image(f"{setu_image.local_id}.jpg", path_), 200
return image(file), 200
return await search_online_setu(setu_image.img_url, id_, path_)
@ -187,7 +187,7 @@ async def get_setu_list(
# 初始化消息
def gen_message(
setu_image: Setu, img_msg: bool = False
setu_image: Setu
) -> Union[Message, MessageSegment]:
local_id = setu_image.local_id
title = setu_image.title