build(deps): 更新项目依赖版本

- 将多个依赖的版本从具体的版本号改为使用 >= 操作符,以允许安装更高版本来获得安全更新修复
- 调整 bilireq 的版本从 0.2.3post0 到 >=0.2.10
- 修改 nonebot-plugin-alconna 的版本从 ^0.54.0 到 >=0.56.0
- 变更 nonebot-plugin-uninfo 的版本从 >0.4.1 到 >=0.7.3
- pillow 的版本从 ^10.0.0 改为 >=10.0.0
- nb-cli 的版本从 ^1.3.0 改为 >=1.3.0
- nonebot2 的版本从 ^2.3.3 改为 >=2.3.3
- ujson 的版本从 ^5.9.0 改为 >=5.9.0
- pypinyin 的版本从 ^0.51.0 改为 >=0.51.0
- tortoise-orm 的版本从 ^0.20.0 改为 >=0.20.0
- nonebot-plugin-session 的版本从 ^0.2.3 到 ^0.3.2
- 对 `_build_image` 文件进行兼容性适配
This commit is contained in:
molanp 2025-08-08 00:59:32 +08:00
parent 3deffcb46c
commit 86c1165c12
3 changed files with 1001 additions and 726 deletions

1673
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,21 +14,21 @@ priority = "primary"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10" python = "^3.10"
playwright = "^1.41.1" playwright = "^1.41.1"
nonebot-adapter-onebot = "^2.3.1" nonebot-adapter-onebot = ">=2.3.1"
nonebot-plugin-apscheduler = "^0.5" nonebot-plugin-apscheduler = "^0.5"
tortoise-orm = "^0.20.0" tortoise-orm = ">=0.20.0"
cattrs = "^23.2.3" cattrs = "^23.2.3"
ruamel-yaml = "^0.18.5" ruamel-yaml = "^0.18.5"
strenum = "^0.4.15" strenum = "^0.4.15"
nonebot-plugin-session = "^0.2.3" nonebot-plugin-session = "^0.3.2"
ujson = "^5.9.0" ujson = ">=5.9.0"
nb-cli = "^1.3.0" nb-cli = ">=1.3.0"
nonebot2 = { extras = ["fastapi"], version = "^2.3.3" } nonebot2 = { extras = ["fastapi"], version = ">=2.3.3" }
pillow = "^10.0.0" pillow = ">=10.0.0"
retrying = "^1.3.4" retrying = "^1.3.4"
aiofiles = "^23.2.1" aiofiles = "^23.2.1"
nonebot-plugin-htmlrender = ">=0.6.0,<1.0.0" nonebot-plugin-htmlrender = ">=0.6.0,<1.0.0"
pypinyin = "^0.51.0" pypinyin = ">=0.51.0"
beautifulsoup4 = "^4.12.3" beautifulsoup4 = "^4.12.3"
lxml = "^5.1.0" lxml = "^5.1.0"
psutil = "^5.9.8" psutil = "^5.9.8"
@ -36,14 +36,14 @@ feedparser = "^6.0.11"
imagehash = "^4.3.1" imagehash = "^4.3.1"
cn2an = "^0.5.22" cn2an = "^0.5.22"
dateparser = "^1.2.0" dateparser = "^1.2.0"
bilireq = "0.2.3post0" bilireq = ">=0.2.10"
python-jose = { extras = ["cryptography"], version = "^3.3.0" } python-jose = { extras = ["cryptography"], version = "^3.3.0" }
python-multipart = "^0.0.9" python-multipart = "^0.0.9"
aiocache = {extras = ["redis"], version = "^0.12.3"} aiocache = {extras = ["redis"], version = "^0.12.3"}
py-cpuinfo = "^9.0.0" py-cpuinfo = "^9.0.0"
nonebot-plugin-alconna = "^0.54.0" nonebot-plugin-alconna = ">=0.56.0"
tenacity = "^9.0.0" tenacity = "^9.0.0"
nonebot-plugin-uninfo = ">0.4.1" nonebot-plugin-uninfo = ">=0.7.3"
nonebot-plugin-waiter = "^0.8.1" nonebot-plugin-waiter = "^0.8.1"
multidict = ">=6.0.0,!=6.3.2" multidict = ">=6.0.0,!=6.3.2"

View File

@ -222,7 +222,7 @@ class BuildImage:
text: str, text: str,
font: str | FreeTypeFont | None = "HYWenHei-85W.ttf", font: str | FreeTypeFont | None = "HYWenHei-85W.ttf",
font_size: int = 10, font_size: int = 10,
) -> tuple[int, int]: # sourcery skip: remove-unnecessary-cast ) -> tuple[float, float]:
"""获取该字体下文本需要的长宽 """获取该字体下文本需要的长宽
参数: 参数:
@ -231,7 +231,7 @@ class BuildImage:
font_size: 字体大小 font_size: 字体大小
返回: 返回:
tuple[int, int]: 长宽 tuple[float, float]: 长宽
""" """
_font = font _font = font
if font and type(font) is str: if font and type(font) is str:
@ -244,7 +244,7 @@ class BuildImage:
return text_width, text_height + 10 return text_width, text_height + 10
# return _font.getsize(str(text)) # type: ignore # return _font.getsize(str(text)) # type: ignore
def getsize(self, msg: str) -> tuple[int, int]: def getsize(self, msg: str) -> tuple[float, float]:
# sourcery skip: remove-unnecessary-cast # sourcery skip: remove-unnecessary-cast
""" """
获取文字在该图片 font_size 下所需要的空间 获取文字在该图片 font_size 下所需要的空间
@ -253,7 +253,7 @@ class BuildImage:
msg: 文本 msg: 文本
返回: 返回:
tuple[int, int]: 长宽 tuple[float, float]: 长宽
""" """
temp_image = Image.new("RGB", (1, 1), (255, 255, 255)) temp_image = Image.new("RGB", (1, 1), (255, 255, 255))
draw = ImageDraw.Draw(temp_image) draw = ImageDraw.Draw(temp_image)
@ -265,9 +265,9 @@ class BuildImage:
def __center_xy( def __center_xy(
self, self,
pos: tuple[int, int], pos: tuple[float, float],
width: int, width: float,
height: int, height: float,
center_type: CenterType | None, center_type: CenterType | None,
) -> tuple[int, int]: ) -> tuple[int, int]:
""" """
@ -284,21 +284,21 @@ class BuildImage:
# _width, _height = pos # _width, _height = pos
if self.width and self.height: if self.width and self.height:
if center_type == "center": if center_type == "center":
width = int((self.width - width) / 2) width = (self.width - width) / 2
height = int((self.height - height) / 2) height = (self.height - height) / 2
elif center_type == "width": elif center_type == "width":
width = int((self.width - width) / 2) width = (self.width - width) / 2
height = pos[1] height = pos[1]
elif center_type == "height": elif center_type == "height":
width = pos[0] width = pos[0]
height = int((self.height - height) / 2) height = (self.height - height) / 2
return width, height return int(width), int(height)
@run_sync @run_sync
def paste( def paste(
self, self,
image: Self | tImage, image: Self | tImage,
pos: tuple[int, int] = (0, 0), pos: tuple[float, float] = (0, 0),
center_type: CenterType | None = None, center_type: CenterType | None = None,
) -> Self: ) -> Self:
"""贴图 """贴图
@ -370,7 +370,7 @@ class BuildImage:
@run_sync @run_sync
def text( def text(
self, self,
pos: tuple[int, int], pos: tuple[float, float],
text: str, text: str,
fill: str | tuple[int, int, int] = (0, 0, 0), fill: str | tuple[int, int, int] = (0, 0, 0),
center_type: CenterType | None = None, center_type: CenterType | None = None,
@ -457,7 +457,7 @@ class BuildImage:
return self return self
@run_sync @run_sync
def crop(self, box: tuple[int, int, int, int]) -> Self: def crop(self, box: tuple[float, float, float, float]) -> Self:
""" """
裁剪图片 裁剪图片
@ -488,7 +488,7 @@ class BuildImage:
x, y = self.markImg.size x, y = self.markImg.size
for i, k in itertools.product(range(n, x - n), range(n, y - n)): for i, k in itertools.product(range(n, x - n), range(n, y - n)):
color = self.markImg.getpixel((i, k)) color = self.markImg.getpixel((i, k))
color = color[:-1] + (int(100 * alpha_ratio),) # type: ignore color = color[:-1] + (int(100 * alpha_ratio),) # type: ignore # noqa: RUF005
self.markImg.putpixel((i, k), color) self.markImg.putpixel((i, k), color)
self.draw = ImageDraw.Draw(self.markImg) self.draw = ImageDraw.Draw(self.markImg)
return self return self