优化截图,但是会残留大量的文件

This commit is contained in:
liuwei
2025-05-27 17:29:53 +08:00
parent 86b257ce20
commit d326467a04
2 changed files with 15 additions and 8 deletions

View File

@@ -154,7 +154,8 @@ class DifyPlugin(MessagePluginInterface):
# 如果是普通文本则在长度大于100字时转为图片发送
if len(response) > 400:
# 转图片
respath = await convert_md_str_to_image(response, "dify_output.jpg")
output_image = f"dify_output_{int(time.time())}.png"
respath = await convert_md_str_to_image(response, output_image)
await bot.send_image_message((roomid if roomid else sender), Path(respath))
else:
# 如果是普通文本,使用发送文本方法
@@ -217,7 +218,8 @@ class DifyPlugin(MessagePluginInterface):
# 如果是普通文本则在长度大于100字时转为图片发送
if len(response) > 400:
# 转图片
respath = await convert_md_str_to_image(response, "dify_output.jpg")
output_image = f"dify_output_{int(time.time())}.png"
respath = await convert_md_str_to_image(response, output_image)
await bot.send_image_message((roomid if roomid else sender), Path(respath))
else:
# 如果是普通文本,使用发送文本方法