This commit is contained in:
HibiKier 2022-07-04 20:21:35 +08:00
parent 7ba129b3bf
commit 1bb9b2cb3f
2 changed files with 52 additions and 10 deletions

View File

@ -247,6 +247,7 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
* 修复商品未设置限购时无法购买 * 修复商品未设置限购时无法购买
* 修复B站订阅UP动态 [@pull/886](https://github.com/HibiKier/zhenxun_bot/pull/886) * 修复B站订阅UP动态 [@pull/886](https://github.com/HibiKier/zhenxun_bot/pull/886)
* 修复色图命令带tag时配置项`MAX_ONCE_NUM2FORWARD`无法生效
### 2022/7/3 \[v0.1.6.1] ### 2022/7/3 \[v0.1.6.1]

View File

@ -254,8 +254,10 @@ async def send_setu_handle(
if code == 401: if code == 401:
await setu.finish(urls[0], at_sender=True) await setu.finish(urls[0], at_sender=True)
if code == 200: if code == 200:
forward_list = []
for i in range(len(urls)): for i in range(len(urls)):
try: try:
msg_id = None
setu_img, index = await search_online_setu(urls[i]) setu_img, index = await search_online_setu(urls[i])
# 下载成功的话 # 下载成功的话
if index != -1: if index != -1:
@ -264,6 +266,14 @@ async def send_setu_handle(
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})" f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
f" 发送色图 {index}.png" f" 发送色图 {index}.png"
) )
if (
Config.get_config("send_setu", "MAX_ONCE_NUM2FORWARD")
and num
>= Config.get_config("send_setu", "MAX_ONCE_NUM2FORWARD")
and isinstance(event, GroupMessageEvent)
):
forward_list.append(Message(f"{text_list[i]}\n{setu_img}"))
else:
msg_id = await matcher.send( msg_id = await matcher.send(
Message(f"{text_list[i]}\n{setu_img}") Message(f"{text_list[i]}\n{setu_img}")
) )
@ -275,11 +285,32 @@ async def send_setu_handle(
if setu_list: if setu_list:
setu_image = random.choice(setu_list) setu_image = random.choice(setu_list)
setu_list.remove(setu_image) setu_list.remove(setu_image)
if (
Config.get_config("send_setu", "MAX_ONCE_NUM2FORWARD")
and num
>= Config.get_config(
"send_setu", "MAX_ONCE_NUM2FORWARD"
)
and isinstance(event, GroupMessageEvent)
):
forward_list.append(
Message(
gen_message(setu_image)
+ (
await check_local_exists_or_download(
setu_image
)
)[0]
)
)
else:
msg_id = await matcher.send( msg_id = await matcher.send(
Message( Message(
gen_message(setu_image) gen_message(setu_image)
+ ( + (
await check_local_exists_or_download(setu_image) await check_local_exists_or_download(
setu_image
)
)[0] )[0]
) )
) )
@ -298,6 +329,16 @@ async def send_setu_handle(
) )
except ActionFailed: except ActionFailed:
await matcher.finish("坏了,这张图色过头了,我自己看看就行了!", at_sender=True) await matcher.finish("坏了,这张图色过头了,我自己看看就行了!", at_sender=True)
if forward_list:
msg_id = await bot.send_group_forward_msg(
group_id=event.group_id,
messages=custom_forward_msg(forward_list, bot.self_id),
)
withdraw_message_manager.withdraw_message(
event,
msg_id,
Config.get_config("send_setu", "WITHDRAW_SETU_MESSAGE"),
)
return return
if code != 200: if code != 200:
await matcher.finish("网络连接失败...", at_sender=True) await matcher.finish("网络连接失败...", at_sender=True)