from io import BytesIO import PIL import PIL.Image from nonebot.adapters import Bot from nonebot.matcher import Matcher from nonebot_plugin_alconna import UniMessage async def reply_image(matcher: type[Matcher], bot: Bot, img: PIL.Image.Image): data = BytesIO() img.save(data, "PNG") await matcher.send(await UniMessage().image(raw=data).export(bot))