forked from mttu-developers/konabot
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6362ed4a88 | |||
| 7e3611afcd | |||
| c307aef5bb |
@ -1,14 +1,17 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from nonebot_plugin_alconna import Alconna, Args, Field, MultiVar, UniMessage, on_alconna
|
|
||||||
|
from nonebot_plugin_alconna import (Alconna, Args, Field, MultiVar, UniMessage,
|
||||||
|
on_alconna)
|
||||||
|
|
||||||
from konabot.plugins.memepack.drawing.geimao import draw_geimao
|
from konabot.plugins.memepack.drawing.geimao import draw_geimao
|
||||||
|
from konabot.plugins.memepack.drawing.pt import draw_pt
|
||||||
|
|
||||||
geimao = on_alconna(Alconna(
|
geimao = on_alconna(Alconna(
|
||||||
"给猫说",
|
"给猫说",
|
||||||
Args["saying", MultiVar(str, '+'), Field(
|
Args["saying", MultiVar(str, '+'), Field(
|
||||||
missing_tips=lambda: "你没有写给猫说了什么"
|
missing_tips=lambda: "你没有写给猫说了什么"
|
||||||
)]
|
)]
|
||||||
), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=False)
|
), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=False, aliases={"给猫哈"})
|
||||||
|
|
||||||
@geimao.handle()
|
@geimao.handle()
|
||||||
async def _(saying: list[str]):
|
async def _(saying: list[str]):
|
||||||
@ -17,3 +20,19 @@ async def _(saying: list[str]):
|
|||||||
img.save(img_bytes, format="PNG")
|
img.save(img_bytes, format="PNG")
|
||||||
|
|
||||||
await geimao.send(await UniMessage().image(raw=img_bytes).export())
|
await geimao.send(await UniMessage().image(raw=img_bytes).export())
|
||||||
|
|
||||||
|
|
||||||
|
pt = on_alconna(Alconna(
|
||||||
|
"pt说",
|
||||||
|
Args["saying", MultiVar(str, '+'), Field(
|
||||||
|
missing_tips=lambda: "你没有写小帕说了什么"
|
||||||
|
)]
|
||||||
|
), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=False, aliases={"小帕说"})
|
||||||
|
|
||||||
|
@pt.handle()
|
||||||
|
async def _(saying: list[str]):
|
||||||
|
img = await draw_pt("\n".join(saying))
|
||||||
|
img_bytes = BytesIO()
|
||||||
|
img.save(img_bytes, format="PNG")
|
||||||
|
|
||||||
|
await pt.send(await UniMessage().image(raw=img_bytes).export())
|
||||||
|
|||||||
BIN
konabot/plugins/memepack/assets/HarmonyOS_Sans_SC_Regular.ttf
Normal file
BIN
konabot/plugins/memepack/assets/HarmonyOS_Sans_SC_Regular.ttf
Normal file
Binary file not shown.
BIN
konabot/plugins/memepack/assets/NotoColorEmoji-Regular.ttf
Normal file
BIN
konabot/plugins/memepack/assets/NotoColorEmoji-Regular.ttf
Normal file
Binary file not shown.
BIN
konabot/plugins/memepack/assets/ptsay.png
Normal file
BIN
konabot/plugins/memepack/assets/ptsay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
@ -1,6 +1,12 @@
|
|||||||
from imagetext_py import FontDB
|
from imagetext_py import EmojiOptions, FontDB
|
||||||
|
|
||||||
from .path import assets
|
from .path import ASSETS
|
||||||
|
|
||||||
|
FontDB.LoadFromDir(str(ASSETS))
|
||||||
|
|
||||||
|
FontDB.SetDefaultEmojiOptions(EmojiOptions(
|
||||||
|
parse_shortcodes=False,
|
||||||
|
))
|
||||||
|
|
||||||
FontDB.LoadFromDir(str(assets))
|
|
||||||
HARMONYOS_SANS_SC_BLACK = FontDB.Query("HarmonyOS_Sans_SC_Black")
|
HARMONYOS_SANS_SC_BLACK = FontDB.Query("HarmonyOS_Sans_SC_Black")
|
||||||
|
HARMONYOS_SANS_SC_REGULAR = FontDB.Query("HarmonyOS_Sans_SC_Regular")
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
assets = Path(__file__).parent.parent.parent / "assets"
|
ASSETS = Path(__file__).parent.parent.parent / "assets"
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import imagetext_py
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
|
||||||
from .base.fonts import HARMONYOS_SANS_SC_BLACK
|
from .base.fonts import HARMONYOS_SANS_SC_BLACK
|
||||||
from .base.path import assets
|
from .base.path import ASSETS
|
||||||
|
|
||||||
geimao_image = PIL.Image.open(assets / "geimao.jpg").convert("RGBA")
|
geimao_image = PIL.Image.open(ASSETS / "geimao.jpg").convert("RGBA")
|
||||||
|
|
||||||
|
|
||||||
def _draw_geimao(saying: str):
|
def _draw_geimao(saying: str):
|
||||||
@ -20,6 +20,7 @@ def _draw_geimao(saying: str):
|
|||||||
imagetext_py.TextAlign.Center,
|
imagetext_py.TextAlign.Center,
|
||||||
cast(Any, 30.0),
|
cast(Any, 30.0),
|
||||||
imagetext_py.Paint.Color(imagetext_py.Color.from_hex("FFFFFFFF")),
|
imagetext_py.Paint.Color(imagetext_py.Color.from_hex("FFFFFFFF")),
|
||||||
|
draw_emojis=True,
|
||||||
)
|
)
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|||||||
26
konabot/plugins/memepack/drawing/pt.py
Normal file
26
konabot/plugins/memepack/drawing/pt.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
import imagetext_py
|
||||||
|
import PIL.Image
|
||||||
|
|
||||||
|
from .base.fonts import HARMONYOS_SANS_SC_REGULAR
|
||||||
|
from .base.path import ASSETS
|
||||||
|
|
||||||
|
pt_image = PIL.Image.open(ASSETS / "ptsay.png").convert("RGBA")
|
||||||
|
|
||||||
|
|
||||||
|
def _draw_pt(saying: str):
|
||||||
|
img = pt_image.copy()
|
||||||
|
with imagetext_py.Writer(img) as iw:
|
||||||
|
iw.draw_text_wrapped(
|
||||||
|
saying, 259, 278, 0.5, 0.5, 360, 48, HARMONYOS_SANS_SC_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_pt(saying: str):
|
||||||
|
return await asyncio.to_thread(_draw_pt, saying)
|
||||||
@ -28,6 +28,7 @@ httptools==0.6.4 ; python_version >= "3.12" and python_version < "4.0"
|
|||||||
httpx==0.28.1 ; python_version >= "3.12" and python_version < "4.0"
|
httpx==0.28.1 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
hyperframe==6.1.0 ; python_version >= "3.12" and python_version < "4.0"
|
hyperframe==6.1.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
idna==3.10 ; python_version >= "3.12" and python_version < "4.0"
|
idna==3.10 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
|
imagetext-py==2.2.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
importlib-metadata==8.7.0 ; python_version >= "3.12" and python_version < "4.0"
|
importlib-metadata==8.7.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
linkify-it-py==2.0.3 ; python_version >= "3.12" and python_version < "4.0"
|
linkify-it-py==2.0.3 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
loguru==0.7.3 ; python_version >= "3.12" and python_version < "4.0"
|
loguru==0.7.3 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
@ -47,6 +48,7 @@ nonebot-plugin-apscheduler==0.5.0 ; python_version >= "3.12" and python_version
|
|||||||
nonebot-plugin-waiter==0.8.1 ; python_version >= "3.12" and python_version < "4.0"
|
nonebot-plugin-waiter==0.8.1 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
nonebot2==2.4.3 ; python_version >= "3.12" and python_version < "4.0"
|
nonebot2==2.4.3 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
nonechat==0.6.1 ; python_version >= "3.12" and python_version < "4.0"
|
nonechat==0.6.1 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
|
pillow==11.3.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
platformdirs==4.4.0 ; python_version >= "3.12" and python_version < "4.0"
|
platformdirs==4.4.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
propcache==0.3.2 ; python_version >= "3.12" and python_version < "4.0"
|
propcache==0.3.2 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
pycares==4.11.0 ; python_version >= "3.12" and python_version < "4.0"
|
pycares==4.11.0 ; python_version >= "3.12" and python_version < "4.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user