@ -30,11 +30,7 @@ steps:
|
|||||||
image: docker:dind
|
image: docker:dind
|
||||||
privileged: true
|
privileged: true
|
||||||
commands:
|
commands:
|
||||||
- docker login -u kagami-ci -p ${KAGAMI_CI_PASSWORD} gitea.service.jazzwhom.top
|
- docker run --rm gitea.service.jazzwhom.top/mttu-developers/konabot:nightly-${DRONE_COMMIT_SHA} python scripts/test_plugin_load.py
|
||||||
- docker run --rm gitea.service.jazzwhom.top/mttu-developers/konabot:nightly-${DRONE_COMMIT_SHA} python test_plugin_load.py
|
|
||||||
environment:
|
|
||||||
KAGAMI_CI_PASSWORD:
|
|
||||||
from_secret: KAGAMI-CI-PASSWORD
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: docker-socket
|
- name: docker-socket
|
||||||
|
|||||||
@ -4,5 +4,8 @@ WORKDIR /app
|
|||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install -r requirements.txt --no-deps
|
RUN pip install -r requirements.txt --no-deps
|
||||||
|
|
||||||
COPY . .
|
COPY bot.py ./
|
||||||
|
COPY assets ./
|
||||||
|
COPY scripts ./
|
||||||
|
COPY konabot ./
|
||||||
CMD [ "python", "bot.py" ]
|
CMD [ "python", "bot.py" ]
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 219 KiB |
|
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 272 KiB |
4
konabot/common/path.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ASSETS_PATH = Path(__file__).resolve().parent.parent.parent / "assets"
|
||||||
|
FONTS_PATH = ASSETS_PATH / "fonts"
|
||||||
@ -1,8 +1,8 @@
|
|||||||
from imagetext_py import EmojiOptions, FontDB
|
from imagetext_py import EmojiOptions, FontDB
|
||||||
|
|
||||||
from .path import ASSETS
|
from konabot.common.path import FONTS_PATH
|
||||||
|
|
||||||
FontDB.LoadFromDir(str(ASSETS))
|
FontDB.LoadFromDir(str(FONTS_PATH))
|
||||||
|
|
||||||
FontDB.SetDefaultEmojiOptions(EmojiOptions(
|
FontDB.SetDefaultEmojiOptions(EmojiOptions(
|
||||||
parse_shortcodes=False,
|
parse_shortcodes=False,
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
ASSETS = Path(__file__).parent.parent.parent / "assets"
|
|
||||||
@ -4,10 +4,11 @@ from typing import Any, cast
|
|||||||
import imagetext_py
|
import imagetext_py
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
|
||||||
from .base.fonts import HARMONYOS_SANS_SC_BLACK
|
from konabot.common.path import ASSETS_PATH
|
||||||
from .base.path import ASSETS
|
|
||||||
|
|
||||||
geimao_image = PIL.Image.open(ASSETS / "geimao.jpg").convert("RGBA")
|
from .base.fonts import HARMONYOS_SANS_SC_BLACK
|
||||||
|
|
||||||
|
geimao_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "geimao.jpg").convert("RGBA")
|
||||||
|
|
||||||
|
|
||||||
def _draw_geimao(saying: str):
|
def _draw_geimao(saying: str):
|
||||||
|
|||||||
@ -3,10 +3,11 @@ import asyncio
|
|||||||
import imagetext_py
|
import imagetext_py
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
|
||||||
from .base.fonts import HARMONYOS_SANS_SC_REGULAR
|
from konabot.common.path import ASSETS_PATH
|
||||||
from .base.path import ASSETS
|
|
||||||
|
|
||||||
pt_image = PIL.Image.open(ASSETS / "ptsay.png").convert("RGBA")
|
from .base.fonts import HARMONYOS_SANS_SC_REGULAR
|
||||||
|
|
||||||
|
pt_image = PIL.Image.open(ASSETS_PATH / "img" / "meme" / "ptsay.png").convert("RGBA")
|
||||||
|
|
||||||
|
|
||||||
def _draw_pt(saying: str):
|
def _draw_pt(saying: str):
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from konabot.plugins.roll_dice.base.path import ASSETS
|
from konabot.common.path import ASSETS_PATH, FONTS_PATH
|
||||||
|
|
||||||
|
|
||||||
def text_to_transparent_image(text, font_size=40, padding=0, text_color=(0, 0, 0)):
|
def text_to_transparent_image(text, font_size=40, padding=0, text_color=(0, 0, 0)):
|
||||||
"""
|
"""
|
||||||
@ -13,15 +15,7 @@ def text_to_transparent_image(text, font_size=40, padding=0, text_color=(0, 0, 0
|
|||||||
temp_image = Image.new('RGB', (1, 1), (255, 255, 255))
|
temp_image = Image.new('RGB', (1, 1), (255, 255, 255))
|
||||||
temp_draw = ImageDraw.Draw(temp_image)
|
temp_draw = ImageDraw.Draw(temp_image)
|
||||||
|
|
||||||
font = ImageFont.truetype(ASSETS / "montserrat.otf", font_size)
|
font = ImageFont.truetype(FONTS_PATH / "montserrat.otf", font_size)
|
||||||
# try:
|
|
||||||
# font = ImageFont.truetype(ASSETS / "montserrat.otf", font_size)
|
|
||||||
# except:
|
|
||||||
# try:
|
|
||||||
# font = ImageFont.truetype("arial.ttf", font_size)
|
|
||||||
# except:
|
|
||||||
# # 如果系统字体不可用,使用默认字体
|
|
||||||
# font = ImageFont.load_default()
|
|
||||||
|
|
||||||
# 获取文本边界框
|
# 获取文本边界框
|
||||||
bbox = temp_draw.textbbox((0, 0), text, font=font)
|
bbox = temp_draw.textbbox((0, 0), text, font=font)
|
||||||
@ -177,7 +171,7 @@ async def generate_dice_image(number: int) -> BytesIO:
|
|||||||
], dtype=np.float32)
|
], dtype=np.float32)
|
||||||
|
|
||||||
# 加载背景图像,保留透明通道
|
# 加载背景图像,保留透明通道
|
||||||
background = cv2.imread(str(ASSETS / "template.png"), cv2.IMREAD_UNCHANGED)
|
background = cv2.imread(str(ASSETS_PATH / "img" / "dice" / "template.png"), cv2.IMREAD_UNCHANGED)
|
||||||
|
|
||||||
|
|
||||||
# 对文本图像进行3D变换(保持透明通道)
|
# 对文本图像进行3D变换(保持透明通道)
|
||||||
@ -189,7 +183,7 @@ async def generate_dice_image(number: int) -> BytesIO:
|
|||||||
|
|
||||||
pil_final = Image.fromarray(final_image_simple)
|
pil_final = Image.fromarray(final_image_simple)
|
||||||
# 导入一系列图像
|
# 导入一系列图像
|
||||||
images: list[Image.Image] = [Image.open(ASSETS / f"{i}.png") for i in range(1, 12)]
|
images: list[Image.Image] = [Image.open(ASSETS_PATH / "img" / "dice" / f"{i}.png") for i in range(1, 12)]
|
||||||
images.append(pil_final)
|
images.append(pil_final)
|
||||||
frame_durations = [100] * (len(images) - 1) + [100000]
|
frame_durations = [100] * (len(images) - 1) + [100000]
|
||||||
# 保存为BytesIO对象
|
# 保存为BytesIO对象
|
||||||
|
|||||||
@ -8,7 +8,9 @@ nonebot.load_plugins("konabot/plugins")
|
|||||||
|
|
||||||
plugins = nonebot.get_loaded_plugins()
|
plugins = nonebot.get_loaded_plugins()
|
||||||
len_requires = len(
|
len_requires = len(
|
||||||
[f for f in Path("konabot/plugins").iterdir() if f.is_dir() and (f / "__init__.py").exists()]
|
[f for f in (
|
||||||
|
Path(__file__).parent.parent / "konabot" / "plugins"
|
||||||
|
).iterdir() if f.is_dir() and (f / "__init__.py").exists()]
|
||||||
)
|
)
|
||||||
|
|
||||||
plugins = [p for p in plugins if p.module.__name__.startswith("konabot.plugins")]
|
plugins = [p for p in plugins if p.module.__name__.startswith("konabot.plugins")]
|
||||||