Per docs/plugin-audit-report.md (plugins normalized to Trigger(handlers) → Service(services) → Model(repository/models) + utils): - Split monolithic __init__.py into handlers/services/utils across dailywife, deer_pipe, dice, galgame_card, helldivers_tools, huoziyinshua, learning_chat, makeaquote, mc_server_status, ncm_saying, picfinder_take, picstatus, random_jm_code, regif, steam_info, video_analysis, group_tools - Move static assets under res/: deer_pipe font/img, makeaquote font, helldivers img/templates, huoziyinshua HuoZiYinShua - Add config.py + register_config_items to ncm_saying, random_jm_code, group_tools; learning_chat unified config bridge - Remove deprecated: voice_trans plugin, bf_bot/test.py, dead code in dailywife/deer_pipe, empty dirs, debug scripts under helldivers temp - Disable brash_general_supercredits_tools (stub comment only) - bot.py: optional stdout/stderr redirect to log file for Web log viewer, force ANSI colorize on non-TTY sinks - Move runtime data (jm_code.json) out of plugin dir into hexi/data - Docs: plugin-audit-report.md; README reflects removed plugins Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
import os
|
|
import random
|
|
from io import BytesIO
|
|
from datetime import datetime
|
|
from PIL import Image, ImageOps, ImageDraw, ImageFont
|
|
|
|
basic_path = os.path.dirname(os.path.dirname(__file__))
|
|
save_path = os.path.join(basic_path, "temp")
|
|
img_path = os.path.join(basic_path, "res", "img")
|
|
data_path = os.path.join(basic_path, "data")
|
|
|
|
|
|
def create_image(selected_equipment):
|
|
new_img = Image.new('RGBA', (800, 500), (0, 0, 0, 1000))
|
|
logo_path = img_path + "/super earth.png"
|
|
logo = Image.open(logo_path)
|
|
new_img = image_paste(logo, new_img, (682, 20))
|
|
draw = ImageDraw.Draw(new_img)
|
|
ch_text_font = ImageFont.truetype(data_path + '/font/msyh.ttc', 36)
|
|
pos_horizon = 20
|
|
|
|
for equipment in selected_equipment:
|
|
name = equipment['name']
|
|
alias = random.choice(equipment['alias']) if equipment['alias'] else None
|
|
|
|
path = basic_path + "/" + equipment['path'].replace("\\", "/")
|
|
icon = Image.open(path)
|
|
icon = icon.resize((100, 100))
|
|
new_img = image_paste(icon, new_img, (20, pos_horizon))
|
|
draw.text((140, pos_horizon + 5), '战备名称:', fill='white', font=ch_text_font)
|
|
draw.text((140, pos_horizon + 50), f'{name} - ({alias})', fill='white', font=ch_text_font)
|
|
pos_horizon += 120
|
|
|
|
b_io = BytesIO()
|
|
new_img = ImageOps.expand(new_img, border=10, fill="white")
|
|
new_img.save(b_io, format="PNG")
|
|
return b_io
|
|
|
|
|
|
def image_paste(paste_image, under_image, pos):
|
|
if paste_image.mode == 'RGBA':
|
|
under_image.paste(paste_image, pos, mask=paste_image.split()[3])
|
|
else:
|
|
under_image.paste(paste_image, pos)
|
|
return under_image |