Skip to content

Commit

Permalink
图片缓存不存在时不报错
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdaYH committed Dec 10, 2024
1 parent 071b3fa commit 576e6f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nonebot_plugin_bottle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async def _(
+ f"你将编号No.{add_index}的漂流瓶以时速{random.randint(0,2**16)}km/h的速度扔出去,谁会捡到这个瓶子呢..."
+ ("(待审批)" if enable_approve else "" )
)
if approve_notice_admin:
if enable_approve and approve_notice_admin:
for user in bot.config.superusers:
await bot.send_private_msg(user_id=user, message=f"漂流瓶 {add_index} 等待审批,请前往web审批。")
else:
Expand Down
6 changes: 5 additions & 1 deletion nonebot_plugin_bottle/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ async def deserialize_message(message: List[Dict[str, Any]]) -> Message:
for seg in message:
if seg["type"] == "cached_image":
seg["type"] = "image"
seg["data"]["file"] = await file_to_b64(cache_dir / seg["data"]["file"])
try:
seg["data"]["file"] = await file_to_b64(cache_dir / seg["data"]["file"])
except FileNotFoundError:
seg["type"] = "text"
seg["data"] = {"text": "[图片]"}
return parse_obj_as(Message, message)


Expand Down

0 comments on commit 576e6f8

Please sign in to comment.