nonebot-plugin-osubot 6.21.0__py3-none-any.whl → 6.22.1__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.
- nonebot_plugin_osubot/api.py +8 -6
- nonebot_plugin_osubot/draw/catch_preview_templates/pic.html +2 -2
- nonebot_plugin_osubot/draw/score.py +14 -7
- nonebot_plugin_osubot/draw/static.py +1 -0
- nonebot_plugin_osubot/draw/templates/bpa_chart.html +1 -1
- nonebot_plugin_osubot/draw/utils.py +6 -5
- nonebot_plugin_osubot/matcher/bp_analyze.py +3 -10
- nonebot_plugin_osubot/matcher/guess.py +40 -40
- nonebot_plugin_osubot/network/manager.py +30 -0
- nonebot_plugin_osubot/osufile/work/stardiff.png +0 -0
- nonebot_plugin_osubot/schema/score.py +2 -0
- {nonebot_plugin_osubot-6.21.0.dist-info → nonebot_plugin_osubot-6.22.1.dist-info}/METADATA +1 -1
- {nonebot_plugin_osubot-6.21.0.dist-info → nonebot_plugin_osubot-6.22.1.dist-info}/RECORD +14 -12
- {nonebot_plugin_osubot-6.21.0.dist-info → nonebot_plugin_osubot-6.22.1.dist-info}/WHEEL +0 -0
nonebot_plugin_osubot/api.py
CHANGED
|
@@ -8,8 +8,9 @@ from typing import Union, Literal, Optional
|
|
|
8
8
|
from nonebot.log import logger
|
|
9
9
|
from expiringdict import ExpiringDict
|
|
10
10
|
from nonebot import get_plugin_config
|
|
11
|
-
from httpx import Response
|
|
11
|
+
from httpx import Response
|
|
12
12
|
|
|
13
|
+
from .network.manager import network_manager
|
|
13
14
|
from .utils import FGM
|
|
14
15
|
from .config import Config
|
|
15
16
|
from .mods import get_mods
|
|
@@ -25,7 +26,6 @@ api = "https://osu.ppy.sh/api/v2"
|
|
|
25
26
|
sayoapi = "https://api.sayobot.cn"
|
|
26
27
|
cache = ExpiringDict(max_len=1, max_age_seconds=86400)
|
|
27
28
|
plugin_config = get_plugin_config(Config)
|
|
28
|
-
proxy = plugin_config.osu_proxy
|
|
29
29
|
|
|
30
30
|
key = plugin_config.osu_key
|
|
31
31
|
client_id = plugin_config.osu_client
|
|
@@ -34,15 +34,15 @@ bg_url = plugin_config.info_bg
|
|
|
34
34
|
|
|
35
35
|
@auto_retry
|
|
36
36
|
async def safe_async_get(url, headers: Optional[dict] = None, params: Optional[dict] = None) -> Response:
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
client = await network_manager.get_client()
|
|
38
|
+
req = await client.get(url, headers=headers, params=params)
|
|
39
39
|
return req
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
@auto_retry
|
|
43
43
|
async def safe_async_post(url, headers=None, data=None, json=None) -> Response:
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
client = await network_manager.get_client()
|
|
45
|
+
req = await client.post(url, headers=headers, data=data, json=json)
|
|
46
46
|
return req
|
|
47
47
|
|
|
48
48
|
|
|
@@ -105,8 +105,10 @@ async def fetch_score_batch(
|
|
|
105
105
|
statistics=i.statistics,
|
|
106
106
|
legacy_total_score=i.legacy_total_score,
|
|
107
107
|
passed=i.passed,
|
|
108
|
+
pp=i.pp,
|
|
108
109
|
beatmap=UnifiedBeatmap(
|
|
109
110
|
id=i.beatmap_id,
|
|
111
|
+
user_id=i.beatmap.user_id,
|
|
110
112
|
set_id=i.beatmapset.id,
|
|
111
113
|
artist=i.beatmapset.artist,
|
|
112
114
|
title=i.beatmapset.title,
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
const createImg = function () {
|
|
43
43
|
const self = this;
|
|
44
|
-
const osufile =
|
|
44
|
+
const osufile = {{ osu_file|tojson }};
|
|
45
45
|
let SPEED = 1;
|
|
46
46
|
let mods = {
|
|
47
47
|
HR: {{ is_hr }},
|
|
@@ -85,4 +85,4 @@
|
|
|
85
85
|
</script>
|
|
86
86
|
</body>
|
|
87
87
|
|
|
88
|
-
</html>
|
|
88
|
+
</html>
|
|
@@ -45,6 +45,8 @@ from .static import (
|
|
|
45
45
|
Torus_SemiBold_30,
|
|
46
46
|
osufile,
|
|
47
47
|
extra_30,
|
|
48
|
+
Stardiff,
|
|
49
|
+
Stars,
|
|
48
50
|
)
|
|
49
51
|
|
|
50
52
|
|
|
@@ -234,14 +236,19 @@ async def draw_score_pic(score_info: UnifiedScore, info: UnifiedUser, map_json,
|
|
|
234
236
|
fill=(255, 255, 255, 255),
|
|
235
237
|
)
|
|
236
238
|
# 难度星星
|
|
237
|
-
stars_bg = stars_diff(pp_info.difficulty.stars)
|
|
239
|
+
stars_bg = stars_diff(pp_info.difficulty.stars, Stars)
|
|
238
240
|
stars_img = stars_bg.resize((85, 37))
|
|
239
241
|
im.alpha_composite(stars_img, (552, 67))
|
|
242
|
+
# 难度竖条
|
|
243
|
+
star_bg = stars_diff(pp_info.difficulty.stars, Stardiff)
|
|
244
|
+
star_img = star_bg.resize((20, 271))
|
|
245
|
+
im.alpha_composite(star_img, (0, 50))
|
|
246
|
+
# 星级
|
|
240
247
|
if pp_info.difficulty.stars < 6.5:
|
|
241
248
|
color = (0, 0, 0, 255)
|
|
242
249
|
else:
|
|
243
250
|
color = (255, 217, 102, 255)
|
|
244
|
-
|
|
251
|
+
|
|
245
252
|
draw.text(
|
|
246
253
|
(556, 85),
|
|
247
254
|
f"★{pp_info.difficulty.stars:.2f}",
|
|
@@ -417,7 +424,7 @@ async def draw_score_pic(score_info: UnifiedScore, info: UnifiedUser, map_json,
|
|
|
417
424
|
fill=(255, 255, 255, 255),
|
|
418
425
|
)
|
|
419
426
|
# setid
|
|
420
|
-
draw.text((
|
|
427
|
+
draw.text((32, 25), f"Setid:{mapinfo.beatmapset_id}", font=Torus_SemiBold_20, anchor="lm")
|
|
421
428
|
# mapid
|
|
422
429
|
draw.text((650, 25), f"Mapid: {mapinfo.id}", font=Torus_SemiBold_20, anchor="rm")
|
|
423
430
|
# 曲名
|
|
@@ -477,11 +484,11 @@ async def draw_score_pic(score_info: UnifiedScore, info: UnifiedUser, map_json,
|
|
|
477
484
|
anchor="lm",
|
|
478
485
|
)
|
|
479
486
|
# 时间
|
|
480
|
-
draw.text((883,
|
|
481
|
-
draw.text((985,
|
|
487
|
+
draw.text((883, 230), "达成时间:", font=Torus_SemiBold_20, anchor="lm")
|
|
488
|
+
draw.text((985, 230), score_info.ended_at.strftime("%Y-%m-%d %H:%M:%S"), font=Torus_SemiBold_20, anchor="lm")
|
|
482
489
|
# 全球排名
|
|
483
|
-
draw.text((
|
|
484
|
-
draw.text((
|
|
490
|
+
draw.text((883, 260), "全球排行:" if grank else "", font=Torus_SemiBold_20, anchor="lm")
|
|
491
|
+
draw.text((985, 260), f"#{grank}" if grank else "", font=Torus_SemiBold_25, anchor="lm")
|
|
485
492
|
# 左下玩家名
|
|
486
493
|
draw.text((208, 550), info.username, font=Torus_SemiBold_30, anchor="lm")
|
|
487
494
|
# 国内排名
|
|
@@ -37,6 +37,7 @@ MapBg = Image.open(osufile / "beatmapinfo.png").convert("RGBA")
|
|
|
37
37
|
MapBg1 = Image.open(osufile / "maniabeatmapinfo.png").convert("RGBA")
|
|
38
38
|
BarImg = Image.open(osufile / "work" / "bmap.png").convert("RGBA")
|
|
39
39
|
Stars = Image.open(osufile / "work" / "stars.png").convert("RGBA")
|
|
40
|
+
Stardiff = Image.open(osufile / "work" / "stardiff.png").convert("RGBA")
|
|
40
41
|
TeamBlue = Image.open(osufile / "match" / "team_blue.png").convert("RGBA")
|
|
41
42
|
TeamRed = Image.open(osufile / "match" / "team_red.png").convert("RGBA")
|
|
42
43
|
MpLink = Image.open(osufile / "match" / "mplink.png").convert("RGBA")
|
|
@@ -6,13 +6,14 @@ from io import BytesIO
|
|
|
6
6
|
from typing import Union, Optional
|
|
7
7
|
from difflib import SequenceMatcher
|
|
8
8
|
|
|
9
|
+
from PIL.ImageFile import ImageFile
|
|
9
10
|
from matplotlib.figure import Figure
|
|
10
11
|
from PIL import ImageDraw, ImageFilter, ImageEnhance, UnidentifiedImageError
|
|
11
12
|
|
|
12
13
|
from ..schema.user import UnifiedUser
|
|
13
14
|
from ..schema import SeasonalBackgrounds
|
|
14
15
|
from ..api import safe_async_get, get_seasonal_bg
|
|
15
|
-
from .static import Path, Image,
|
|
16
|
+
from .static import Path, Image, ColorArr, np, osufile
|
|
16
17
|
from ..file import map_path, download_osu, get_projectimg, user_cache_path, team_cache_path
|
|
17
18
|
|
|
18
19
|
|
|
@@ -183,7 +184,7 @@ async def crop_bg(size: tuple[int, int], path: Union[str, Path, BytesIO, Image.I
|
|
|
183
184
|
return sf
|
|
184
185
|
|
|
185
186
|
|
|
186
|
-
def stars_diff(stars: float):
|
|
187
|
+
def stars_diff(stars: float, stars_bg: ImageFile):
|
|
187
188
|
if stars < 0.1:
|
|
188
189
|
r, g, b = 170, 170, 170
|
|
189
190
|
elif stars >= 9:
|
|
@@ -192,10 +193,10 @@ def stars_diff(stars: float):
|
|
|
192
193
|
# 颜色取色参考 https://github.com/ppy/osu-web/blob/97997d9c7b7f9c49f9b3cdd776c71afb9872c34b/resources/js/utils/beatmap-helper.ts#L20
|
|
193
194
|
r, g, b, _a = ColorArr[int(stars * 100)]
|
|
194
195
|
# 打开底图
|
|
195
|
-
xx, yy =
|
|
196
|
+
xx, yy = stars_bg.size
|
|
196
197
|
# 填充背景
|
|
197
|
-
img = Image.new("RGBA",
|
|
198
|
-
img.paste(
|
|
198
|
+
img = Image.new("RGBA", stars_bg.size, (r, g, b))
|
|
199
|
+
img.paste(stars_bg, (0, 0, xx, yy), stars_bg)
|
|
199
200
|
# 把白色变透明
|
|
200
201
|
arr = np.array(img)
|
|
201
202
|
# 创建mask,将白色替换为True,其他颜色替换为False
|
|
@@ -7,9 +7,8 @@ from nonebot_plugin_alconna import UniMessage
|
|
|
7
7
|
|
|
8
8
|
from ..utils import NGM
|
|
9
9
|
from .utils import split_msg
|
|
10
|
-
from ..schema import NewScore
|
|
11
10
|
from ..database import UserData
|
|
12
|
-
from ..api import
|
|
11
|
+
from ..api import get_user_scores, get_users
|
|
13
12
|
from ..exceptions import NetworkError
|
|
14
13
|
from ..draw.score import cal_score_info
|
|
15
14
|
from ..draw.echarts import draw_bpa_plot
|
|
@@ -35,17 +34,11 @@ async def _(event: Event, state: T_State):
|
|
|
35
34
|
uid = state["user"]
|
|
36
35
|
lazer_mode = "lazer模式下" if state["is_lazer"] else "stable模式下"
|
|
37
36
|
try:
|
|
38
|
-
|
|
39
|
-
"bp",
|
|
40
|
-
uid,
|
|
41
|
-
NGM[state["mode"]],
|
|
42
|
-
legacy_only=int(not user.lazer_mode),
|
|
43
|
-
)
|
|
37
|
+
score_ls = await get_user_scores(uid, NGM[state["mode"]], "best", legacy_only=not state["is_lazer"])
|
|
44
38
|
except NetworkError as e:
|
|
45
39
|
await UniMessage.text(
|
|
46
40
|
f"在查找用户:{state['username']} {NGM[state['mode']]}模式 {lazer_mode}时 {str(e)}"
|
|
47
41
|
).finish(reply_to=True)
|
|
48
|
-
score_ls = [NewScore(**i) for i in bp_info]
|
|
49
42
|
for score in score_ls:
|
|
50
43
|
for mod in score.mods:
|
|
51
44
|
if mod.acronym == "DT" or mod.acronym == "NC":
|
|
@@ -106,6 +99,6 @@ async def _(event: Event, state: T_State):
|
|
|
106
99
|
mapper_pp_data.append({"name": user_dic.get(mapper, ""), "value": round(pp, 2)})
|
|
107
100
|
if len(mapper_pp_data) > 20:
|
|
108
101
|
mapper_pp_data = mapper_pp_data[:20]
|
|
109
|
-
name = f"{
|
|
102
|
+
name = f"{state['username']} {NGM[state['mode']]} 模式 "
|
|
110
103
|
byt = await draw_bpa_plot(name, pp_ls, length_ls, pp_data, mapper_pp_data)
|
|
111
104
|
await UniMessage.image(raw=byt).finish(reply_to=True)
|
|
@@ -16,6 +16,8 @@ from nonebot.internal.rule import Rule, Event
|
|
|
16
16
|
from nonebot_plugin_alconna import At, UniMsg, UniMessage
|
|
17
17
|
from nonebot_plugin_session import SessionId, SessionIdType
|
|
18
18
|
|
|
19
|
+
from ..draw.taiko_preview import parse_map, map_to_image
|
|
20
|
+
from ..schema.score import UnifiedScore
|
|
19
21
|
from ..utils import NGM
|
|
20
22
|
from ..info import get_bg
|
|
21
23
|
from .utils import split_msg
|
|
@@ -23,7 +25,7 @@ from ..schema import NewScore
|
|
|
23
25
|
from ..exceptions import NetworkError
|
|
24
26
|
from ..database.models import UserData
|
|
25
27
|
from ..mania import generate_preview_pic
|
|
26
|
-
from ..api import
|
|
28
|
+
from ..api import safe_async_get, get_user_scores
|
|
27
29
|
from ..file import map_path, download_tmp_osu
|
|
28
30
|
from ..draw.catch_preview import draw_cath_preview
|
|
29
31
|
|
|
@@ -46,23 +48,27 @@ data_path = Path() / "data" / "osu"
|
|
|
46
48
|
pcm_path = data_path / "out.pcm"
|
|
47
49
|
|
|
48
50
|
|
|
49
|
-
async def get_random_beatmap_set(binded_id, group_id
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
async def get_random_beatmap_set(binded_id, group_id) -> (UnifiedScore, str):
|
|
52
|
+
# 获取已猜过的歌曲集合
|
|
53
|
+
guessed_songs = guess_song_cache[group_id]
|
|
54
|
+
available_scores = []
|
|
55
|
+
for user_id in binded_id:
|
|
56
|
+
try:
|
|
57
|
+
user = await UserData.filter(user_id=user_id).first()
|
|
58
|
+
if not user:
|
|
59
|
+
continue
|
|
60
|
+
bp_info = await get_user_scores(user.osu_id, NGM[str(user.osu_mode)], "best")
|
|
61
|
+
# 过滤掉已猜过的歌曲
|
|
62
|
+
unguessed_scores = [(score, user.osu_name) for score in bp_info if score.beatmapset.id not in guessed_songs]
|
|
63
|
+
available_scores.extend(unguessed_scores)
|
|
64
|
+
except NetworkError:
|
|
65
|
+
continue # 跳过网络错误的用户,继续尝试其他用户
|
|
66
|
+
if not available_scores:
|
|
67
|
+
return None, None # 所有歌曲都被猜过了
|
|
68
|
+
# 随机选择一个未猜过的成绩
|
|
69
|
+
selected_score, osu_name = random.choice(available_scores)
|
|
70
|
+
guess_song_cache[group_id].add(selected_score.beatmapset.id)
|
|
71
|
+
return selected_score, osu_name
|
|
66
72
|
|
|
67
73
|
|
|
68
74
|
@guess_audio.handle(parameterless=[split_msg()])
|
|
@@ -89,12 +95,11 @@ async def _(
|
|
|
89
95
|
if not user_data:
|
|
90
96
|
await UniMessage.text("该用户未绑定osu账号").finish(reply_to=True)
|
|
91
97
|
try:
|
|
92
|
-
|
|
98
|
+
bp_ls = await get_user_scores(user_data.osu_id, NGM[state["mode"]], "best")
|
|
93
99
|
except NetworkError as e:
|
|
94
100
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
95
101
|
reply_to=True
|
|
96
102
|
)
|
|
97
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
98
103
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[group_id]]
|
|
99
104
|
if not filtered_bp_ls:
|
|
100
105
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -103,12 +108,11 @@ async def _(
|
|
|
103
108
|
selected_user = user_data.osu_name
|
|
104
109
|
elif state["user"]:
|
|
105
110
|
try:
|
|
106
|
-
|
|
111
|
+
bp_ls = await get_user_scores(state["user"], NGM[state["mode"]], "best")
|
|
107
112
|
except NetworkError as e:
|
|
108
113
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
109
114
|
reply_to=True
|
|
110
115
|
)
|
|
111
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
112
116
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[group_id]]
|
|
113
117
|
if not filtered_bp_ls:
|
|
114
118
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -354,12 +358,11 @@ async def _(
|
|
|
354
358
|
if not user_data:
|
|
355
359
|
await UniMessage.text("该用户未绑定osu账号").finish(reply_to=True)
|
|
356
360
|
try:
|
|
357
|
-
|
|
361
|
+
bp_ls = await get_user_scores(user_data.osu_id, NGM[state["mode"]], "best")
|
|
358
362
|
except NetworkError as e:
|
|
359
363
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
360
364
|
reply_to=True
|
|
361
365
|
)
|
|
362
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
363
366
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[session_id]]
|
|
364
367
|
if not filtered_bp_ls:
|
|
365
368
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -368,12 +371,11 @@ async def _(
|
|
|
368
371
|
selected_user = user_data.osu_name
|
|
369
372
|
elif state["user"]:
|
|
370
373
|
try:
|
|
371
|
-
|
|
374
|
+
bp_ls = await get_user_scores(state["user"], NGM[state["mode"]], "best")
|
|
372
375
|
except NetworkError as e:
|
|
373
376
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
374
377
|
reply_to=True
|
|
375
378
|
)
|
|
376
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
377
379
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[session_id]]
|
|
378
380
|
if not filtered_bp_ls:
|
|
379
381
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -422,7 +424,7 @@ async def _(
|
|
|
422
424
|
await UniMessage.text("由于未绑定OSU账号,本次随机选择模式进行猜歌\n" + state["error"]).send(reply_to=True)
|
|
423
425
|
else:
|
|
424
426
|
mode = state["mode"]
|
|
425
|
-
if mode == "0"
|
|
427
|
+
if mode == "0":
|
|
426
428
|
await UniMessage.text("该模式暂不支持猜歌").finish(reply_to=True)
|
|
427
429
|
binded_id = await UserData.filter(osu_mode=mode).values_list("user_id", flat=True)
|
|
428
430
|
if not binded_id:
|
|
@@ -435,12 +437,11 @@ async def _(
|
|
|
435
437
|
if not user_data:
|
|
436
438
|
await UniMessage.text("该用户未绑定osu账号").finish(reply_to=True)
|
|
437
439
|
try:
|
|
438
|
-
|
|
440
|
+
bp_ls = await get_user_scores(user_data.osu_id, NGM[state["mode"]], "best")
|
|
439
441
|
except NetworkError as e:
|
|
440
442
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
441
443
|
reply_to=True
|
|
442
444
|
)
|
|
443
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
444
445
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[session_id]]
|
|
445
446
|
if not filtered_bp_ls:
|
|
446
447
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -449,12 +450,11 @@ async def _(
|
|
|
449
450
|
guess_song_cache[session_id].add(selected_score.beatmapset.id)
|
|
450
451
|
elif state["user"]:
|
|
451
452
|
try:
|
|
452
|
-
|
|
453
|
+
bp_ls = await get_user_scores(state["user"], NGM[state["mode"]], "best")
|
|
453
454
|
except NetworkError as e:
|
|
454
455
|
await UniMessage.text(f"在查找用户:{state['username']} {NGM[state['mode']]}模式bp时 {str(e)}").finish(
|
|
455
456
|
reply_to=True
|
|
456
457
|
)
|
|
457
|
-
bp_ls = [NewScore(**i) for i in bp_info]
|
|
458
458
|
filtered_bp_ls = [i for i in bp_ls if i.beatmapset.id not in guess_song_cache[session_id]]
|
|
459
459
|
if not filtered_bp_ls:
|
|
460
460
|
await UniMessage.text(state["username"] + "的bp已经被你们猜过一遍了 -_-").finish(reply_to=True)
|
|
@@ -471,18 +471,18 @@ async def _(
|
|
|
471
471
|
chart_set_timeout(matcher, session_id)
|
|
472
472
|
if mode == "3":
|
|
473
473
|
osu = await download_tmp_osu(selected_score.beatmap.id)
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
474
|
+
pic = await generate_preview_pic(osu)
|
|
475
|
+
elif mode == "1":
|
|
476
|
+
osu = await download_tmp_osu(selected_score.beatmap.id)
|
|
477
|
+
beatmap = parse_map(osu)
|
|
478
|
+
pic = map_to_image(beatmap)
|
|
479
479
|
else:
|
|
480
480
|
mods = [i.acronym for i in selected_score.mods]
|
|
481
481
|
pic = await draw_cath_preview(selected_score.beatmap.id, selected_score.beatmapset.id, mods)
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
482
|
+
await (
|
|
483
|
+
UniMessage.text(f"开始谱面猜歌游戏,猜猜下面谱面的曲名吧,该曲抽选自 {selected_user} 的bp")
|
|
484
|
+
+ UniMessage.image(raw=pic)
|
|
485
|
+
).finish()
|
|
486
486
|
|
|
487
487
|
|
|
488
488
|
@chart_word_matcher.handle()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
import asyncio
|
|
3
|
+
from ..config import Config
|
|
4
|
+
from httpx import AsyncClient
|
|
5
|
+
from nonebot import get_plugin_config
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
plugin_config = get_plugin_config(Config)
|
|
9
|
+
proxy = plugin_config.osu_proxy
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class NetworkManager:
|
|
13
|
+
def __init__(self):
|
|
14
|
+
self._client = None
|
|
15
|
+
self._lock = asyncio.Lock()
|
|
16
|
+
|
|
17
|
+
async def get_client(self) -> AsyncClient:
|
|
18
|
+
if self._client is None:
|
|
19
|
+
async with self._lock:
|
|
20
|
+
if self._client is None:
|
|
21
|
+
self._client = AsyncClient(
|
|
22
|
+
proxy=proxy,
|
|
23
|
+
follow_redirects=True,
|
|
24
|
+
limits=httpx.Limits(max_keepalive_connections=20, max_connections=100, keepalive_expiry=30),
|
|
25
|
+
timeout=httpx.Timeout(30.0),
|
|
26
|
+
)
|
|
27
|
+
return self._client
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
network_manager = NetworkManager()
|
|
Binary file
|
|
@@ -113,6 +113,7 @@ class UnifiedBeatmap(Base):
|
|
|
113
113
|
ar: float
|
|
114
114
|
hp: float
|
|
115
115
|
stars: float
|
|
116
|
+
user_id: Optional[int] = None
|
|
116
117
|
|
|
117
118
|
|
|
118
119
|
class UnifiedScore(Base):
|
|
@@ -127,3 +128,4 @@ class UnifiedScore(Base):
|
|
|
127
128
|
statistics: NewStatistics
|
|
128
129
|
beatmap: Optional[UnifiedBeatmap] = None
|
|
129
130
|
passed: bool
|
|
131
|
+
pp: Optional[float] = None
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
nonebot_plugin_osubot/__init__.py,sha256=Q-mTTnOIdKiKG6JrVm-kqpPrAhOP9lWyiKHNRqA7gpc,1478
|
|
2
|
-
nonebot_plugin_osubot/api.py,sha256=
|
|
2
|
+
nonebot_plugin_osubot/api.py,sha256=0o6Gp_4YzVtYDDRJYoIl4yTW8gy4eSY0LY8COkzkOBo,16363
|
|
3
3
|
nonebot_plugin_osubot/beatmap_stats_moder.py,sha256=mNNTufc-gvO4NdYa3TnealSZI4-LBoiTlb599SeLBck,2915
|
|
4
4
|
nonebot_plugin_osubot/config.py,sha256=Ub2s5Ny09-d1ZwT6x8cirB6zWy0brtO-oZV3W0qEM5Q,311
|
|
5
5
|
nonebot_plugin_osubot/database/__init__.py,sha256=7CDo9xU_DGLQ6uTj_mU_Px92phg_DMU5mP6WvgOxFLY,101
|
|
@@ -36,20 +36,20 @@ nonebot_plugin_osubot/draw/catch_preview_templates/js/standard/spinner.js,sha256
|
|
|
36
36
|
nonebot_plugin_osubot/draw/catch_preview_templates/js/util.js,sha256=XveUlX-d0vrUnXaGbR8y428s6Nw2zhDR235pFko_MxM,1504
|
|
37
37
|
nonebot_plugin_osubot/draw/catch_preview_templates/js/viewbox.js,sha256=RPsUyoKNAQub2n7oUGwWyFppZu0iVuy6DD5gggQZS3E,1641
|
|
38
38
|
nonebot_plugin_osubot/draw/catch_preview_templates/js/zip.min.js,sha256=pQmrVxuGCMeLS-XS3QsVhzjwap28fr9Ya083uPlg1sM,86405
|
|
39
|
-
nonebot_plugin_osubot/draw/catch_preview_templates/pic.html,sha256=
|
|
39
|
+
nonebot_plugin_osubot/draw/catch_preview_templates/pic.html,sha256=jwPxxyYFLGpbD29h8u_j3LBY33ya7BS2R_t95EldAmk,3092
|
|
40
40
|
nonebot_plugin_osubot/draw/echarts.py,sha256=OzL_397yWrDAIXsEWf72hAiqdIUBz1D182cli6ORD6s,1037
|
|
41
41
|
nonebot_plugin_osubot/draw/info.py,sha256=i2YcJmSdTpwhZl_nDe7GJv4jQTB8_9oBfpq2Zw2hwo0,11162
|
|
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=
|
|
46
|
-
nonebot_plugin_osubot/draw/static.py,sha256=
|
|
45
|
+
nonebot_plugin_osubot/draw/score.py,sha256=z7HNBOFVHaarbeo2FK8vIpoGVhu47E2BgCqG_axTwSo,29610
|
|
46
|
+
nonebot_plugin_osubot/draw/static.py,sha256=wdlzNO3xyiauKiMLr_h-B9uAsFU7fX_Y-fOusYKZP3k,4132
|
|
47
47
|
nonebot_plugin_osubot/draw/taiko_preview.py,sha256=tqhuHSdxUJEuXqKHMJDeSLdusuJhSnMMiaG5FbUnaJw,11441
|
|
48
|
-
nonebot_plugin_osubot/draw/templates/bpa_chart.html,sha256=
|
|
48
|
+
nonebot_plugin_osubot/draw/templates/bpa_chart.html,sha256=R-fO46HtmC4y3brMFGz6MQkna8ke7WGHVIgUnvcY248,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=6QDbByPQZCxI0k_i5MsExyWZ-sHgJUw6nEWLv85IgLY,15826
|
|
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
|
|
@@ -59,9 +59,9 @@ nonebot_plugin_osubot/mania/__init__.py,sha256=XRPn563jDJiPohFekcoFFCqCJYznb-6uO
|
|
|
59
59
|
nonebot_plugin_osubot/matcher/__init__.py,sha256=yID7QcdQF6_Mouwbej3JwYUBbKSU3VQdrjq6B1Fz9P8,1331
|
|
60
60
|
nonebot_plugin_osubot/matcher/bind.py,sha256=QQJc2S7XFo5tu4CPloIET6fKaeiQixgb8M7QvULV6E0,2834
|
|
61
61
|
nonebot_plugin_osubot/matcher/bp.py,sha256=GidJfuZ9lJ7LwMq126DDOwMksNUOz4Bkab83OlKg8t8,3983
|
|
62
|
-
nonebot_plugin_osubot/matcher/bp_analyze.py,sha256=
|
|
62
|
+
nonebot_plugin_osubot/matcher/bp_analyze.py,sha256=L2ccAi7TQvpD036DyA27D8wuiqBBkcfLT0ldk_Apv8w,3820
|
|
63
63
|
nonebot_plugin_osubot/matcher/getbg.py,sha256=Ar2yIST556MYRxzuXCLSDAMAmESRENN1fCty-kdH7PI,699
|
|
64
|
-
nonebot_plugin_osubot/matcher/guess.py,sha256=
|
|
64
|
+
nonebot_plugin_osubot/matcher/guess.py,sha256=QmD-a88pnPfSSBAvSpD2tlHDGMRpYWqtxfNuLsHuBYM,24144
|
|
65
65
|
nonebot_plugin_osubot/matcher/history.py,sha256=ZYkVJHdXuVJmhovRhwxFdqNp0o2uJJOACAZhhutyS3w,1577
|
|
66
66
|
nonebot_plugin_osubot/matcher/info.py,sha256=8CJHTOMTx_nzJ4ZwXo6ZfBwCuO3DtLprRX7jnMtPilk,858
|
|
67
67
|
nonebot_plugin_osubot/matcher/map.py,sha256=sFpOoFv63y-NOkCJhE6aW0DRYDl_8SoQOPsdq50QxT0,1404
|
|
@@ -85,6 +85,7 @@ nonebot_plugin_osubot/mods.py,sha256=vxIWYX0HwTxetPAHWZK5ojEMfqV9HFlWT0YC4Yncgb8
|
|
|
85
85
|
nonebot_plugin_osubot/network/__init__.py,sha256=WOijcd81yhnpGKYeiDIOxbBDVI12GHPRGoOFfxrUuQk,61
|
|
86
86
|
nonebot_plugin_osubot/network/auto_retry.py,sha256=vDfYGbEVPF6WZLYXmRVkNvaxf6_6RyIqEAcA7TRwV_k,565
|
|
87
87
|
nonebot_plugin_osubot/network/first_response.py,sha256=zETRc6g0AG8ExLyHZTLUl7uzUCdUVIL0IfxvdEtCPt0,932
|
|
88
|
+
nonebot_plugin_osubot/network/manager.py,sha256=x0GI1cFv3m3ZIS4oNJed197PaRo8_Vut_2J7m9ySV30,858
|
|
88
89
|
nonebot_plugin_osubot/osufile/Best Performance.png,sha256=qBNeZcym5vIqyE23K62ohjVBEPCjlNP9wQgXaT20XyY,704
|
|
89
90
|
nonebot_plugin_osubot/osufile/History Score.jpg,sha256=yv3-GaJ7sBAbAPMFlUeoyg1PzMhv31Ip5bC4H0qJfSA,836
|
|
90
91
|
nonebot_plugin_osubot/osufile/beatmapinfo.png,sha256=QQjMIGgAdvH6VKgHrrCZWasawsBb95erij4a_B0gjwA,30694
|
|
@@ -389,6 +390,7 @@ nonebot_plugin_osubot/osufile/work/bmap.png,sha256=Uc2znhA_SQ5Zc5MxdtIlnK2YlkhQS
|
|
|
389
390
|
nonebot_plugin_osubot/osufile/work/center.png,sha256=AJkhRnPCv1aYPg5nLV2ZCtDGo3lPzP3orT62DvS3c_4,83
|
|
390
391
|
nonebot_plugin_osubot/osufile/work/left.png,sha256=wJtK_kGmtRumI3F-vK0cl2Q2N1v7DB5bc9qofe4LyqI,128
|
|
391
392
|
nonebot_plugin_osubot/osufile/work/right.png,sha256=WKkaefFr5C_pdm9mFMyYMUS_BNzMPATmqlvebVU36OY,136
|
|
393
|
+
nonebot_plugin_osubot/osufile/work/stardiff.png,sha256=mBPOspsqNr1FkDolzTpnyIz-8NIKfrYn_dXi_eMS34s,156
|
|
392
394
|
nonebot_plugin_osubot/osufile/work/stars.png,sha256=zifMmxxjOGzSZAm1tr-3ky_yy18p1bbjgkl3zYRMcp4,305
|
|
393
395
|
nonebot_plugin_osubot/osufile/work/stars_expertplus.png,sha256=cmfpErs-flPxHEhVmS9H8vy8H7mrChvV_Q4A77oSVFY,517
|
|
394
396
|
nonebot_plugin_osubot/osufile/work/suppoter.png,sha256=4V4eNhB8_8KIXsQ1jzFyHUkicKPb5LPehoIcri4h8E4,16061
|
|
@@ -400,9 +402,9 @@ nonebot_plugin_osubot/schema/beatmap.py,sha256=UnobfZEHq1V2HG-A4j3BECubO-dB1JzTM
|
|
|
400
402
|
nonebot_plugin_osubot/schema/match.py,sha256=lR3pGNVR9K_5GZAdOLG6Ki-W3fwJvgMlNhYOzKNE3lg,494
|
|
401
403
|
nonebot_plugin_osubot/schema/ppysb/__init__.py,sha256=JK2Z4n44gUJPVKdETMJYJ5uIw-4a8T50y6j5n-YrlYM,1375
|
|
402
404
|
nonebot_plugin_osubot/schema/sayo_beatmap.py,sha256=lS1PQZ-HvHl0VhkzlI0-pNLeJrLYWVqmKAo6xZr5I2U,959
|
|
403
|
-
nonebot_plugin_osubot/schema/score.py,sha256=
|
|
405
|
+
nonebot_plugin_osubot/schema/score.py,sha256=uqIKLKgnvnQKuJBFcmmioKeiU4ThG6uKsxMFHRov_dA,3189
|
|
404
406
|
nonebot_plugin_osubot/schema/user.py,sha256=sxNmqymG_kIVuGuzfchSv9UML6NPG70cqo2_h5xDIpM,2250
|
|
405
407
|
nonebot_plugin_osubot/utils/__init__.py,sha256=pyv8XxBcCOeQVDj1E4dgvktzcefgQXfKBlarsYGx1sg,815
|
|
406
|
-
nonebot_plugin_osubot-6.
|
|
407
|
-
nonebot_plugin_osubot-6.
|
|
408
|
-
nonebot_plugin_osubot-6.
|
|
408
|
+
nonebot_plugin_osubot-6.22.1.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
409
|
+
nonebot_plugin_osubot-6.22.1.dist-info/METADATA,sha256=ZN_77-BBWGsr45EC7w82GvWFWGaTAj0rFyDAKlaQj_w,4476
|
|
410
|
+
nonebot_plugin_osubot-6.22.1.dist-info/RECORD,,
|
|
File without changes
|