diff --git a/assets/img/meme/vr.jpg b/assets/img/meme/vr.jpg new file mode 100755 index 0000000..1932658 Binary files /dev/null and b/assets/img/meme/vr.jpg differ diff --git a/konabot/plugins/memepack/__init__.py b/konabot/plugins/memepack/__init__.py index 894ea37..9260d9d 100644 --- a/konabot/plugins/memepack/__init__.py +++ b/konabot/plugins/memepack/__init__.py @@ -34,6 +34,7 @@ from konabot.plugins.memepack.drawing.saying import ( draw_mnk, draw_pt, draw_suan, + draw_vr, ) from konabot.plugins.memepack.drawing.watermark import draw_doubao_watermark @@ -334,3 +335,29 @@ async def _(img: DepPILImage): result_bytes = BytesIO() result.save(result_bytes, format="PNG") await doubao_cmd.send(await UniMessage().image(raw=result_bytes).export()) + + +vrsay = on_alconna( + Alconna( + "vr说", + Args[ + "saying", + MultiVar(str, "+"), + Field(missing_tips=lambda: "你没有写vr说了什么"), + ], + ), + use_cmd_start=True, + use_cmd_sep=False, + skip_for_unmatch=False, + aliases=set(), +) + + +@vrsay.handle() +async def _(saying: list[str]): + img = await draw_vr("\n".join(saying)) + img_bytes = BytesIO() + img.save(img_bytes, format="PNG") + + await vrsay.send(await UniMessage().image(raw=img_bytes).export()) + diff --git a/konabot/plugins/memepack/drawing/saying.py b/konabot/plugins/memepack/drawing/saying.py index 6ab6b2d..85eee9f 100644 --- a/konabot/plugins/memepack/drawing/saying.py +++ b/konabot/plugins/memepack/drawing/saying.py @@ -16,6 +16,7 @@ dasuan_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "dss.png").convert( suan_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "suanleba.png").convert("RGBA") cute_ten_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "tententen.png").convert("RGBA") kio_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "kiosay.jpg").convert("RGBA") +vr_image = PIL.Image.open(ASSETS_PATH / 'img' / 'meme' / 'vr.jpg').convert("RGBA") def _draw_geimao(saying: str): @@ -123,3 +124,24 @@ def draw_kiosay(saying: str): ) return img + +@make_async +def draw_vr(saying: str): + img = vr_image.copy() + w, h = img.size + hw = 300 + + img2 = PIL.Image.new("RGBA", (w, h + hw), 'white') + img2.paste(img, (0, hw)) + + with imagetext_py.Writer(img2) as iw: + iw.draw_text_wrapped( + saying, w // 2, hw // 2 + 15, 0.5, 0.5, w, 64, LXGWWENKAI_REGULAR, + imagetext_py.Paint.Color(imagetext_py.Color.from_hex("000000FF")), + 1.0, + imagetext_py.TextAlign.Center, + draw_emojis=True, + ) + + return img2 +