This commit is contained in:
@ -1,11 +1,12 @@
|
||||
import asyncio as asynkio
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
import json
|
||||
import secrets
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from PIL import Image
|
||||
from loguru import logger
|
||||
from nonebot import on_message
|
||||
import nonebot
|
||||
@ -617,14 +618,23 @@ async def _(event: BaseEvent, target: DepLongTaskTarget):
|
||||
# 打开好吧狗本地文件
|
||||
with open(ASSETS_PATH / "img" / "dog" / "haoba_dog.jpg", "rb") as f:
|
||||
img_data = f.read()
|
||||
# 把好吧狗变成 GIF 格式以缩小尺寸
|
||||
img_data = await convert_image_to_gif(img_data)
|
||||
await evt.send(await UniMessage().image(raw=img_data).export())
|
||||
await end_game(event, group_id)
|
||||
else:
|
||||
await evt.send(
|
||||
await UniMessage().text("当前没有成语接龙游戏在进行中!").export()
|
||||
)
|
||||
# await evt.send(
|
||||
# await UniMessage().text("当前没有成语接龙游戏在进行中!").export()
|
||||
# )
|
||||
return
|
||||
|
||||
|
||||
async def convert_image_to_gif(image_data: bytes) -> bytes:
|
||||
with Image.open(BytesIO(image_data)) as img:
|
||||
with BytesIO() as output:
|
||||
img.save(output, format="GIF")
|
||||
return output.getvalue()
|
||||
|
||||
# 跳过
|
||||
evt = on_alconna(
|
||||
Alconna("跳过成语"), use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=True
|
||||
@ -642,6 +652,8 @@ async def _(target: DepLongTaskTarget):
|
||||
# 发送哈哈狗图片
|
||||
with open(ASSETS_PATH / "img" / "dog" / "haha_dog.jpg", "rb") as f:
|
||||
img_data = f.read()
|
||||
# 把哈哈狗变成 GIF 格式以缩小尺寸
|
||||
img_data = await convert_image_to_gif(img_data)
|
||||
await evt.send(await UniMessage().image(raw=img_data).export())
|
||||
await evt.send(await UniMessage().text(f"你们太菜了,全部扣100分!明明还可以接「{avaliable_idiom}」的!").export())
|
||||
idiom = await instance.skip_idiom(-100)
|
||||
|
||||
Reference in New Issue
Block a user