diff --git a/assets/img/meme/tententen.png b/assets/img/meme/tententen.png new file mode 100644 index 0000000..5e66ebd Binary files /dev/null and b/assets/img/meme/tententen.png differ diff --git a/konabot/plugins/memepack/__init__.py b/konabot/plugins/memepack/__init__.py index 9dff667..7903d4e 100644 --- a/konabot/plugins/memepack/__init__.py +++ b/konabot/plugins/memepack/__init__.py @@ -3,7 +3,9 @@ from io import BytesIO from nonebot_plugin_alconna import (Alconna, Args, Field, MultiVar, UniMessage, on_alconna) -from konabot.plugins.memepack.drawing.saying import draw_geimao, draw_mnk, draw_pt, draw_suan +from konabot.plugins.memepack.drawing.saying import (draw_cute_ten, + draw_geimao, draw_mnk, + draw_pt, draw_suan) geimao = on_alconna(Alconna( "给猫说", @@ -83,3 +85,19 @@ async def _(saying: list[str]): img.save(img_bytes, format="PNG") await pt.send(await UniMessage().image(raw=img_bytes).export()) + + +dsuan = on_alconna(Alconna( + "乖猫说", + Args["saying", MultiVar(str, '+'), Field( + missing_tips=lambda: "你没有写十猫说了什么" + )] +), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=False, aliases={"十猫说"}) + +@dsuan.handle() +async def _(saying: list[str]): + img = await draw_cute_ten("\n".join(saying)) + img_bytes = BytesIO() + img.save(img_bytes, format="PNG") + + await pt.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 caa4a5b..1998e3d 100644 --- a/konabot/plugins/memepack/drawing/saying.py +++ b/konabot/plugins/memepack/drawing/saying.py @@ -13,6 +13,7 @@ pt_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "ptsay.png").convert("R mnk_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "mnksay.jpg").convert("RGBA") dasuan_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "dss.png").convert("RGBA") 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") def _draw_geimao(saying: str): @@ -88,3 +89,20 @@ def _draw_suan(saying: str, dasuan: bool = False): async def draw_suan(saying: str, dasuan: bool = False): return await asyncio.to_thread(_draw_suan, saying, dasuan) + + +def _draw_cute_ten(saying: str): + img = cute_ten_image.copy() + with imagetext_py.Writer(img) as iw: + iw.draw_text_wrapped( + saying, 390, 479, 0.5, 0.5, 760, 96, LXGWWENKAI_REGULAR, + imagetext_py.Paint.Color(imagetext_py.Color.from_hex("000000FF")), + 1.0, + imagetext_py.TextAlign.Center, + draw_emojis=True, + ) + return img + + +async def draw_cute_ten(saying: str): + return await asyncio.to_thread(_draw_cute_ten, saying)