nonebot-plugin-osubot 6.18.1__py3-none-any.whl → 6.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nonebot-plugin-osubot might be problematic. Click here for more details.
- nonebot_plugin_osubot/draw/score.py +11 -1
- nonebot_plugin_osubot/draw/utils.py +38 -12
- nonebot_plugin_osubot/schema/beatmap.py +6 -0
- {nonebot_plugin_osubot-6.18.1.dist-info → nonebot_plugin_osubot-6.19.0.dist-info}/METADATA +2 -2
- {nonebot_plugin_osubot-6.18.1.dist-info → nonebot_plugin_osubot-6.19.0.dist-info}/RECORD +6 -6
- {nonebot_plugin_osubot-6.18.1.dist-info → nonebot_plugin_osubot-6.19.0.dist-info}/WHEEL +0 -0
|
@@ -27,6 +27,7 @@ from .utils import (
|
|
|
27
27
|
get_modeimage,
|
|
28
28
|
open_user_icon,
|
|
29
29
|
filter_scores_with_regex,
|
|
30
|
+
trim_text_with_ellipsis,
|
|
30
31
|
)
|
|
31
32
|
from .static import (
|
|
32
33
|
Image,
|
|
@@ -398,9 +399,18 @@ async def draw_score_pic(score_info: UnifiedScore, info: UnifiedUser, map_json,
|
|
|
398
399
|
anchor="lm",
|
|
399
400
|
)
|
|
400
401
|
# 谱面版本,mapper
|
|
402
|
+
if mapinfo.owners:
|
|
403
|
+
owner_names = [owner.username for owner in mapinfo.owners]
|
|
404
|
+
owners_str = ", ".join(owner_names)
|
|
405
|
+
mapper = f"{mapinfo.version} | 谱师: {owners_str}"
|
|
406
|
+
|
|
407
|
+
else:
|
|
408
|
+
mapper = f"{mapinfo.version} | 谱师: {mapinfo.beatmapset.creator}"
|
|
409
|
+
mapper = trim_text_with_ellipsis(mapper, 1000, Torus_SemiBold_20)
|
|
410
|
+
|
|
401
411
|
draw.text(
|
|
402
412
|
(225, 90),
|
|
403
|
-
|
|
413
|
+
mapper,
|
|
404
414
|
font=Torus_SemiBold_20,
|
|
405
415
|
anchor="lm",
|
|
406
416
|
)
|
|
@@ -267,18 +267,18 @@ async def update_icon(info: UnifiedUser):
|
|
|
267
267
|
user_icon = await get_projectimg(info.avatar_url)
|
|
268
268
|
with open(path / f"icon.{info.avatar_url.split('.')[-1]}", "wb") as f:
|
|
269
269
|
f.write(user_icon.getvalue())
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
270
|
+
if info.team:
|
|
271
|
+
team_path = team_cache_path / f"{info.team.id}.png"
|
|
272
|
+
if team_path.exists():
|
|
273
|
+
modified_time = team_path.stat().st_mtime
|
|
274
|
+
modified_datetime = datetime.datetime.fromtimestamp(modified_time)
|
|
275
|
+
time_diff = datetime.datetime.now() - modified_datetime
|
|
276
|
+
# 判断文件是否创建超过一天
|
|
277
|
+
if time_diff > datetime.timedelta(days=1):
|
|
278
|
+
team_path.unlink()
|
|
279
|
+
team_icon = await get_projectimg(info.team.flag_url)
|
|
280
|
+
with open(team_path, "wb") as f:
|
|
281
|
+
f.write(team_icon.getvalue())
|
|
282
282
|
|
|
283
283
|
|
|
284
284
|
async def update_map(set_id, map_id):
|
|
@@ -410,3 +410,29 @@ def filter_scores_with_regex(scores_with_index, conditions):
|
|
|
410
410
|
score for score in scores_with_index if matches_condition_with_regex(score, key, operator, value)
|
|
411
411
|
]
|
|
412
412
|
return scores_with_index
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def trim_text_with_ellipsis(text, max_width, font):
|
|
416
|
+
# 初始检查:空字符串或无需处理
|
|
417
|
+
if not text or font.getbbox(text) <= max_width:
|
|
418
|
+
return text
|
|
419
|
+
# 逐字符检查
|
|
420
|
+
ellipsis_symbol = "…"
|
|
421
|
+
ellipsis_width = font.getbbox("…")
|
|
422
|
+
# 确保最大宽度能至少容纳一个字符+省略号
|
|
423
|
+
if max_width < font.getbbox("A") + ellipsis_width:
|
|
424
|
+
return ellipsis_symbol
|
|
425
|
+
|
|
426
|
+
truncated_text = ""
|
|
427
|
+
current_width = 0
|
|
428
|
+
|
|
429
|
+
for char in text:
|
|
430
|
+
# 检查当前字符宽度 + 省略号宽度是否超标
|
|
431
|
+
char_width = font.getbbox(char)
|
|
432
|
+
if current_width + char_width + ellipsis_width > max_width:
|
|
433
|
+
break
|
|
434
|
+
truncated_text += char
|
|
435
|
+
current_width += char_width
|
|
436
|
+
|
|
437
|
+
# 返回截断后的字符串 + 省略号
|
|
438
|
+
return truncated_text + ellipsis_symbol if truncated_text else ellipsis_symbol
|
|
@@ -11,6 +11,11 @@ class Covers(Base):
|
|
|
11
11
|
slimcover: str
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
class Gds(Base):
|
|
15
|
+
id: int
|
|
16
|
+
username: str
|
|
17
|
+
|
|
18
|
+
|
|
14
19
|
class BeatmapsetCompact(Base):
|
|
15
20
|
artist: str
|
|
16
21
|
artist_unicode: str
|
|
@@ -78,6 +83,7 @@ class Beatmap(BeatmapCompact):
|
|
|
78
83
|
playcount: int
|
|
79
84
|
ranked: int
|
|
80
85
|
url: str
|
|
86
|
+
owners: Optional[list[Gds]] = None
|
|
81
87
|
|
|
82
88
|
|
|
83
89
|
class BackgroundsAttributes(Base):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-osubot
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.19.0
|
|
4
4
|
Summary: OSUbot in NoneBot2
|
|
5
5
|
License: AGPL-3.0
|
|
6
6
|
Author-email: yaowan233 <572473053@qq.com>
|
|
@@ -18,7 +18,7 @@ Requires-Dist: nonebot2>=2.3.0
|
|
|
18
18
|
Requires-Dist: pillow>=9.2.0
|
|
19
19
|
Requires-Dist: pydantic!=2.5.0,!=2.5.1,<3.0.0,>=1.10.0
|
|
20
20
|
Requires-Dist: reamber>=0.2.1
|
|
21
|
-
Requires-Dist: rosu-pp-py==
|
|
21
|
+
Requires-Dist: rosu-pp-py==3.0.0
|
|
22
22
|
Requires-Dist: tortoise-orm>=0.20.0
|
|
23
23
|
Requires-Dist: typing_extensions>=4.11.0
|
|
24
24
|
Project-URL: Homepage, https://github.com/yaowan233/nonebot-plugin-osubot
|
|
@@ -42,14 +42,14 @@ nonebot_plugin_osubot/draw/info.py,sha256=i2YcJmSdTpwhZl_nDe7GJv4jQTB8_9oBfpq2Zw
|
|
|
42
42
|
nonebot_plugin_osubot/draw/map.py,sha256=4M8xRd0dIbC5g1s8I4eTZ3vRglM6r_TSznFOZ62K2wk,8654
|
|
43
43
|
nonebot_plugin_osubot/draw/match_history.py,sha256=GBJl6lAA27U7NSMC2isEzD_YsoIPAeG6ijDu7Oflcl0,997
|
|
44
44
|
nonebot_plugin_osubot/draw/rating.py,sha256=pA7mGLI4IujmYB6kQf_tSkR7mZGpUAVLRLyaAsZhqTM,20397
|
|
45
|
-
nonebot_plugin_osubot/draw/score.py,sha256=
|
|
45
|
+
nonebot_plugin_osubot/draw/score.py,sha256=Y2-BUuKYgYoXk-Uq0PFNg3WaU_SUfSB6Ebo446xslUg,27553
|
|
46
46
|
nonebot_plugin_osubot/draw/static.py,sha256=2rznsXZTcKggQ5JSpsJg4y6uWP4e-Y40U7v_QAwLT4Q,3969
|
|
47
47
|
nonebot_plugin_osubot/draw/taiko_preview.py,sha256=tqhuHSdxUJEuXqKHMJDeSLdusuJhSnMMiaG5FbUnaJw,11441
|
|
48
48
|
nonebot_plugin_osubot/draw/templates/bpa_chart.html,sha256=cnpM0qRvvyCMTRP-mIOABQlaaqxQwG5kLUxlo4h7F7w,7012
|
|
49
49
|
nonebot_plugin_osubot/draw/templates/echarts.min.js,sha256=IF32ooP8NPIzQg_fs7lVHpwG92JcCPE1TZAEyFSgGZU,1022939
|
|
50
50
|
nonebot_plugin_osubot/draw/templates/mod_chart.html,sha256=Iz71KM5v9z_Rt2vqJ5WIZumRIHgDfcGIUmWGvVGZ-nQ,1508
|
|
51
51
|
nonebot_plugin_osubot/draw/templates/pp_rank_line_chart.html,sha256=Gyf-GR8ZBlWQTks0TlB3M8EWUBMVwiUaesFAmDISxLo,1417
|
|
52
|
-
nonebot_plugin_osubot/draw/utils.py,sha256=
|
|
52
|
+
nonebot_plugin_osubot/draw/utils.py,sha256=fvFs7h8G0UavHAe4vXWugKJZ2ZQmZb0bGl-BSPG95hc,15138
|
|
53
53
|
nonebot_plugin_osubot/exceptions.py,sha256=N_FsEk-9Eu2QnuznhdfWn6OoyA1HH73Q7bUaY89gVi0,40
|
|
54
54
|
nonebot_plugin_osubot/file.py,sha256=GhG54EdVsxFf8_8GZOPh4YGvw9iw5bAX9JFz4Mg4kMg,4379
|
|
55
55
|
nonebot_plugin_osubot/info/__init__.py,sha256=I7YlMQiuHExEeJWqyzZb2I-Vl2uql3Py2LdhSH2Z9N0,136
|
|
@@ -396,13 +396,13 @@ nonebot_plugin_osubot/pp.py,sha256=PSWGLWERr4vVtE9H5D2EBm-_hM5HOU3PQvv1cC4rqmQ,3
|
|
|
396
396
|
nonebot_plugin_osubot/schema/__init__.py,sha256=io5BqRRNeBUSWPw5VXQav_TMrDN4dsTVpoMzrU9lTCA,468
|
|
397
397
|
nonebot_plugin_osubot/schema/alphaosu.py,sha256=7cJLIwl4X-dshYsXMi8hHgcp7Ly6BiI3pqwXENhMaX0,693
|
|
398
398
|
nonebot_plugin_osubot/schema/basemodel.py,sha256=aZI1rdOHx-kmMXohazq1s5tYdtR-2WRzfYQATmWd6a4,99
|
|
399
|
-
nonebot_plugin_osubot/schema/beatmap.py,sha256=
|
|
399
|
+
nonebot_plugin_osubot/schema/beatmap.py,sha256=UnobfZEHq1V2HG-A4j3BECubO-dB1JzTMA2_QIXttNM,1960
|
|
400
400
|
nonebot_plugin_osubot/schema/match.py,sha256=lR3pGNVR9K_5GZAdOLG6Ki-W3fwJvgMlNhYOzKNE3lg,494
|
|
401
401
|
nonebot_plugin_osubot/schema/ppysb/__init__.py,sha256=JK2Z4n44gUJPVKdETMJYJ5uIw-4a8T50y6j5n-YrlYM,1375
|
|
402
402
|
nonebot_plugin_osubot/schema/sayo_beatmap.py,sha256=lS1PQZ-HvHl0VhkzlI0-pNLeJrLYWVqmKAo6xZr5I2U,959
|
|
403
403
|
nonebot_plugin_osubot/schema/score.py,sha256=zHU-w2e7RzMDL8vdPkX5vggcqalBo83JTvu96abcflo,3124
|
|
404
404
|
nonebot_plugin_osubot/schema/user.py,sha256=sxNmqymG_kIVuGuzfchSv9UML6NPG70cqo2_h5xDIpM,2250
|
|
405
405
|
nonebot_plugin_osubot/utils/__init__.py,sha256=pyv8XxBcCOeQVDj1E4dgvktzcefgQXfKBlarsYGx1sg,815
|
|
406
|
-
nonebot_plugin_osubot-6.
|
|
407
|
-
nonebot_plugin_osubot-6.
|
|
408
|
-
nonebot_plugin_osubot-6.
|
|
406
|
+
nonebot_plugin_osubot-6.19.0.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
407
|
+
nonebot_plugin_osubot-6.19.0.dist-info/METADATA,sha256=lHB8m5ljuFCJHaM6dNi-AwN82VMLvKMQFNiw67c0CkI,4476
|
|
408
|
+
nonebot_plugin_osubot-6.19.0.dist-info/RECORD,,
|
|
File without changes
|