🐛 添加更新依赖配置,修复因PIL版本导致的get_size问题

This commit is contained in:
Wuyi无疑 2023-08-06 22:20:43 +08:00
parent 542beff78c
commit 1f4083f801
4 changed files with 18 additions and 3 deletions

View File

@ -64,7 +64,11 @@ async def get_help(
bc = deepcopy(banner)
bc_draw = ImageDraw.Draw(bc)
bc_draw.text((30, 25), sv_name, text_color, font(35), 'lm')
size, _ = font(35).getsize(sv_name)
if hasattr(font, 'getsize'):
size, _ = font(35).getsize(sv_name)
else:
bbox = font(35).getbbox(sv_name)
size, _ = bbox[2] - bbox[0], bbox[3] - bbox[1]
bc_draw.text((42 + size, 30), sv_desc, sub_color, font(20), 'lm')
sv_img = easy_alpha_composite(sv_img, bc, (0, 10))
# sv_img.paste(bc, (0, 10), bc)

View File

@ -98,7 +98,13 @@ def get_str_size(
continue
line += i
size, _ = font.getsize(line)
if hasattr(font, 'getsize'):
size, _ = font.getsize(line)
else:
bbox = font.getbbox(line)
size, _ = bbox[2] - bbox[0], bbox[3] - bbox[1]
if size >= limit:
result += f'{line}\n'
line = ''

View File

@ -58,4 +58,5 @@ CONIFG_DEFAULT: Dict[str, GSC] = {
'TextToPicThreshold': GsStrConfig('文转图阈值', '开启自动转图后超过该阈值的文字会转成图片', '20'),
'EnableSpecificMsgId': GsBoolConfig('启用回复特殊ID', '如不知道请勿开启', False),
'SpecificMsgId': GsStrConfig('特殊返回消息ID', '如不知道请勿填写', ''),
'AutoUpdateDep': GsBoolConfig('自动更新依赖', '更新插件时将会自动更新依赖', False),
}

View File

@ -9,11 +9,14 @@ from git.repo import Repo
from git.exc import GitCommandError, NoSuchPathError, InvalidGitRepositoryError
from gsuid_core.logger import logger
from gsuid_core.utils.plugins_config.gs_config import core_plugins_config
from .api import CORE_PATH, PLUGINS_PATH, proxy_url, plugins_lib
plugins_list: Dict[str, Dict[str, str]] = {}
is_update_dep = core_plugins_config.get_config('AutoUpdateDep').data
# 传入一个path对象
async def run_poetry_install(path: Optional[Path] = None) -> int:
@ -182,7 +185,8 @@ def update_from_git(
if repo_like is None:
repo = Repo(CORE_PATH)
plugin_name = '早柚核心'
asyncio.create_task(run_poetry_install(CORE_PATH))
if is_update_dep:
asyncio.create_task(run_poetry_install(CORE_PATH))
elif isinstance(repo_like, Path):
repo = Repo(repo_like)
plugin_name = repo_like.name