This commit is contained in:
@ -17,7 +17,7 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
from playwright.async_api import ConsoleMessage, Page
|
||||
|
||||
from konabot.common.nb.extract_image import PIL_Image, extract_image_from_message
|
||||
from konabot.common.nb.extract_image import DepPILImage
|
||||
from konabot.common.web_render import konaweb
|
||||
from konabot.common.web_render.core import WebRenderer
|
||||
from konabot.common.web_render.host_images import host_tempdir
|
||||
@ -36,9 +36,6 @@ from konabot.plugins.memepack.drawing.saying import (
|
||||
)
|
||||
from konabot.plugins.memepack.drawing.watermark import draw_doubao_watermark
|
||||
|
||||
from nonebot.adapters import Bot, Event
|
||||
|
||||
from returns.result import Success, Failure
|
||||
|
||||
geimao = on_alconna(
|
||||
Alconna(
|
||||
@ -194,7 +191,7 @@ cao_display_cmd = on_message()
|
||||
|
||||
|
||||
@cao_display_cmd.handle()
|
||||
async def _(msg: UniMsg, evt: Event, bot: Bot):
|
||||
async def _(msg: UniMsg, img: DepPILImage):
|
||||
flag = False
|
||||
for text in cast(Iterable[Text], msg.get(Text)):
|
||||
if text.text.strip() == "小槽展示":
|
||||
@ -205,20 +202,10 @@ async def _(msg: UniMsg, evt: Event, bot: Bot):
|
||||
return
|
||||
if not flag:
|
||||
return
|
||||
match await extract_image_from_message(evt.get_message(), evt, bot):
|
||||
case Success(img):
|
||||
img_handled = await draw_cao_display(img)
|
||||
img_bytes = BytesIO()
|
||||
img_handled.save(img_bytes, format="PNG")
|
||||
await cao_display_cmd.send(await UniMessage().image(raw=img_bytes).export())
|
||||
case Failure(err):
|
||||
await cao_display_cmd.send(
|
||||
await UniMessage()
|
||||
.at(user_id=evt.get_user_id())
|
||||
.text(" ")
|
||||
.text(err)
|
||||
.export()
|
||||
)
|
||||
img_handled = await draw_cao_display(img)
|
||||
img_bytes = BytesIO()
|
||||
img_handled.save(img_bytes, format="PNG")
|
||||
await cao_display_cmd.send(await UniMessage().image(raw=img_bytes).export())
|
||||
|
||||
|
||||
snaur_display_cmd = on_alconna(
|
||||
@ -235,7 +222,7 @@ snaur_display_cmd = on_alconna(
|
||||
|
||||
@snaur_display_cmd.handle()
|
||||
async def _(
|
||||
img: PIL_Image,
|
||||
img: DepPILImage,
|
||||
whiteness: float = 0.0,
|
||||
black_level: float = 0.2,
|
||||
opacity: float = 0.8,
|
||||
@ -254,7 +241,7 @@ async def _(
|
||||
|
||||
anan_display_cmd = on_message()
|
||||
@anan_display_cmd.handle()
|
||||
async def _(msg: UniMsg, evt: Event, bot: Bot):
|
||||
async def _(msg: UniMsg, img: DepPILImage):
|
||||
flag = False
|
||||
for text in cast(Iterable[Text], msg.get(Text)):
|
||||
stripped = text.text.strip()
|
||||
@ -267,20 +254,10 @@ async def _(msg: UniMsg, evt: Event, bot: Bot):
|
||||
if not flag:
|
||||
return
|
||||
|
||||
match await extract_image_from_message(evt.get_message(), evt, bot):
|
||||
case Success(img):
|
||||
img_handled = await draw_anan_display(img)
|
||||
img_bytes = BytesIO()
|
||||
img_handled.save(img_bytes, format="PNG")
|
||||
await anan_display_cmd.send(await UniMessage().image(raw=img_bytes).export())
|
||||
case Failure(err):
|
||||
await anan_display_cmd.send(
|
||||
await UniMessage()
|
||||
.at(user_id=evt.get_user_id())
|
||||
.text(" ")
|
||||
.text(err)
|
||||
.export()
|
||||
)
|
||||
img_handled = await draw_anan_display(img)
|
||||
img_bytes = BytesIO()
|
||||
img_handled.save(img_bytes, format="PNG")
|
||||
await anan_display_cmd.send(await UniMessage().image(raw=img_bytes).export())
|
||||
|
||||
|
||||
kiosay = on_alconna(
|
||||
@ -316,7 +293,7 @@ quote_cmd = on_alconna(Alconna(
|
||||
), aliases={"quote"})
|
||||
|
||||
@quote_cmd.handle()
|
||||
async def _(quote: str, author: str, img: PIL_Image):
|
||||
async def _(quote: str, author: str, img: DepPILImage):
|
||||
async with host_tempdir() as tempdir:
|
||||
img_path = tempdir.path / "image.png"
|
||||
img_url = tempdir.url_of(img_path)
|
||||
@ -351,7 +328,7 @@ doubao_cmd = on_alconna(Alconna(
|
||||
|
||||
|
||||
@doubao_cmd.handle()
|
||||
async def _(img: PIL_Image):
|
||||
async def _(img: DepPILImage):
|
||||
result = await draw_doubao_watermark(img)
|
||||
result_bytes = BytesIO()
|
||||
result.save(result_bytes, format="PNG")
|
||||
|
||||
Reference in New Issue
Block a user