From 660421f49ae66d44936574719c65644601aa561b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:10:19 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20`pre-commit-ci`?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.14 → v0.15.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.14...v0.15.4) - [github.com/astral-sh/uv-pre-commit: 0.9.28 → 0.10.7](https://github.com/astral-sh/uv-pre-commit/compare/0.9.28...0.10.7) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e9aa48..a042691 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: autoupdate_commit_msg: "⬆️ `pre-commit-ci`自动升级" repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.14 + rev: v0.15.4 hooks: - id: ruff args: [--fix] @@ -20,7 +20,7 @@ repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.9.28 + rev: 0.10.7 hooks: - id: uv-lock - id: uv-export From f8b8f763d05825b6490d527dcb2fe77bd1bdd45f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:12:43 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20`pre-commit-ci`=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=A0=BC=E5=BC=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CS2UID/csgo_info/__init__.py | 4 ++- CS2UID/csgo_info/csgo_5e.py | 26 ++++++++++++++----- CS2UID/csgo_info/csgo_goods.py | 20 +++++++++++---- CS2UID/csgo_info/csgo_info.py | 38 ++++++++++++++++++++++------ CS2UID/csgo_info/csgo_match.py | 12 ++++++--- CS2UID/csgo_info/csgo_matchdetail.py | 16 +++++++++--- CS2UID/csgo_info/csgohome_info.py | 16 +++++++++--- CS2UID/csgo_info/utils.py | 10 ++++++-- CS2UID/csgo_items/__init__.py | 20 ++++++++++++--- CS2UID/csgo_items/message.py | 6 ++++- CS2UID/csgo_items/utils.py | 20 +++++++++++---- CS2UID/csgo_user/__init__.py | 20 +++++++++++---- requirements.txt | 3 +++ 13 files changed, 163 insertions(+), 48 deletions(-) diff --git a/CS2UID/csgo_info/__init__.py b/CS2UID/csgo_info/__init__.py index 549c888..37f5eb3 100644 --- a/CS2UID/csgo_info/__init__.py +++ b/CS2UID/csgo_info/__init__.py @@ -114,7 +114,9 @@ async def send_csgo_match_msg(bot: Bot, ev: Event): type_i = determine_match_type(ev.text) # 获取比赛信息 - resp = await bot.receive_resp(await get_csgo_match_img(ev.user_id, uid, tag, type_i)) + resp = await bot.receive_resp( + await get_csgo_match_img(ev.user_id, uid, tag, type_i) + ) if resp is None: return diff --git a/CS2UID/csgo_info/csgo_5e.py b/CS2UID/csgo_info/csgo_5e.py index 720c1ed..cadc14b 100644 --- a/CS2UID/csgo_info/csgo_5e.py +++ b/CS2UID/csgo_info/csgo_5e.py @@ -33,7 +33,9 @@ async def get_csgo_5einfo_img(uid: str, season: str = "") -> Union[str, bytes]: return await draw_csgo_5einfo_img(detail, info) -async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> bytes | str: +async def draw_csgo_5einfo_img( + detail: UserHomeDetail5, info: UserSeason5 +) -> bytes | str: if not detail: return "token已过期" user_info = detail["user"] @@ -115,7 +117,9 @@ async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> by # 赛季信息 main2_img = Image.open(TEXTURE / "base" / "banner.png") main2_draw = ImageDraw.Draw(main2_img) - main2_draw.text((50, 10), season_info["now_season"], (255, 255, 255, 255), csgo_font_42) + main2_draw.text( + (50, 10), season_info["now_season"], (255, 255, 255, 255), csgo_font_42 + ) img.paste(main2_img, (0, 600), main2_img) @@ -345,7 +349,9 @@ async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> by base_img = Image.open(TEXTURE / "base" / "weapon_5ebg.png").resize((500, 110)) weapon_img = await save_img(usr_weapon["weapons_url"], "weapon5e") - weapon_img = weapon_img.resize((int(weapon_img.size[0] * 0.5), int(weapon_img.size[1] * 0.5))) + weapon_img = weapon_img.resize( + (int(weapon_img.size[0] * 0.5), int(weapon_img.size[1] * 0.5)) + ) easy_paste(base_img, weapon_img, (100, 70), "cc") weapon_draw = ImageDraw.Draw(base_img) @@ -370,7 +376,9 @@ async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> by csgo_font_20, "mm", ) - fsa = f"{usr_weapon['per_kill']}" if usr_weapon["per_kill"] is not None else "N/A" + fsa = ( + f"{usr_weapon['per_kill']}" if usr_weapon["per_kill"] is not None else "N/A" + ) if usr_weapon["avg_harm"] is None: weapon_draw.text( (285, 60), @@ -387,7 +395,11 @@ async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> by csgo_font_20, "mm", ) - hdr = f"{usr_weapon['per_headshot']}" if usr_weapon["per_headshot"] is not None else "0%" + hdr = ( + f"{usr_weapon['per_headshot']}" + if usr_weapon["per_headshot"] is not None + else "0%" + ) weapon_draw.text((430, 31), f"{hdr}", (255, 255, 255, 255), csgo_font_20, "mm") if i % 2 == 0: @@ -495,7 +507,9 @@ async def draw_csgo_5einfo_img(detail: UserHomeDetail5, info: UserSeason5) -> by filtered_data = {selected_keys[key]: filter_data[key] for key in selected_keys} total_value = sum(filtered_data.values()) - normalized_data = {label: value / total_value for label, value in filtered_data.items()} + normalized_data = { + label: value / total_value for label, value in filtered_data.items() + } width = 400 height = 400 diff --git a/CS2UID/csgo_info/csgo_goods.py b/CS2UID/csgo_info/csgo_goods.py index 1110e05..b7721e5 100644 --- a/CS2UID/csgo_info/csgo_goods.py +++ b/CS2UID/csgo_info/csgo_goods.py @@ -70,7 +70,9 @@ async def get_csgo_goods_img(uid: str) -> Union[str, bytes]: # return "出现意外错误,请重启core正常使用该功能" -async def draw_csgo_goods_img(detail: SteamGet, base: UserHomedetailData) -> bytes | str: +async def draw_csgo_goods_img( + detail: SteamGet, base: UserHomedetailData +) -> bytes | str: if not detail: return "token已过期" if not detail["previewItem"]: @@ -94,7 +96,9 @@ async def draw_csgo_goods_img(detail: SteamGet, base: UserHomedetailData) -> byt level_img = Image.open(ICON_PATH / "main1.png").resize((700, 220)) await simple_paste_img(level_img, "steam库存信息", (100, 30), 40) await simple_paste_img(level_img, f"总物品数量:{totalCount}", (100, 90), 40) - await simple_paste_img(level_img, f"总物品价值:{totalPrice / 100}馒头", (100, 150), 40) + await simple_paste_img( + level_img, f"总物品价值:{totalPrice / 100}馒头", (100, 150), 40 + ) img.paste(level_img, (100, 300), level_img) @@ -160,14 +164,18 @@ async def update_tag_data_for_special_types(tag_data: dict) -> None: async def update_quality_info(one_get: OneGet, tag_data: dict) -> dict: """更新物品的品质信息""" - qua_color, qua_text_replacement = quality_mapping.get(tag_data.get("品质", "_default"), quality_mapping["_default"]) + qua_color, qua_text_replacement = quality_mapping.get( + tag_data.get("品质", "_default"), quality_mapping["_default"] + ) if qua_text_replacement is not None: tag_data["品质"] = qua_text_replacement img_qua = Image.new("RGB", (5, 15), color=qua_color) return {"img_qua": img_qua, "qua_color": qua_color} -async def paste_item_name(good_img: Image.Image, name_out: list, tag_data: dict, description: str) -> None: +async def paste_item_name( + good_img: Image.Image, name_out: list, tag_data: dict, description: str +) -> None: """粘贴物品的名称和种类""" st = "ST™" if len(name_out) == 1: @@ -199,7 +207,9 @@ async def process_stat_trak( if st_count: await simple_paste_img(good_img, f"{st_count}个", (33, 5), color="red", size=13) - await simple_paste_img(good_img, msg1, (20, 60), color=tag_data.get("品质", "Purple")) + await simple_paste_img( + good_img, msg1, (20, 60), color=tag_data.get("品质", "Purple") + ) await simple_paste_img(good_img, msg2, (20, 25), color="Purple") diff --git a/CS2UID/csgo_info/csgo_info.py b/CS2UID/csgo_info/csgo_info.py index f2b36b2..5fec626 100644 --- a/CS2UID/csgo_info/csgo_info.py +++ b/CS2UID/csgo_info/csgo_info.py @@ -75,7 +75,11 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: # 主信息 main2_img = Image.open(TEXTURE / "base" / "base_bg.png") if detail["stars"] < 10: - rank_img = Image.open(TEXTURE / "base" / "rank_logo.png").convert("RGBA").resize((120, 120)) + rank_img = ( + Image.open(TEXTURE / "base" / "rank_logo.png") + .convert("RGBA") + .resize((120, 120)) + ) rank_draw = ImageDraw.Draw(rank_img) rank_draw.text((58, 58), rank[0], (255, 255, 255, 255), csgo_font_30, "mm") else: @@ -86,7 +90,9 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: else: pj_img = "1.png" - rank_img = Image.open(TEXTURE / "rank" / pj_img).convert("RGBA").resize((100, 120)) + rank_img = ( + Image.open(TEXTURE / "rank" / pj_img).convert("RGBA").resize((100, 120)) + ) easy_paste(main2_img, rank_img, (100, 100), "cc") if detail["stars"] > 0: @@ -136,7 +142,9 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: csgo_font_42, "mm", ) - main2_draw.text((105, 230), str(rank_scoce), (255, 255, 255, 255), csgo_font_42, "mm") + main2_draw.text( + (105, 230), str(rank_scoce), (255, 255, 255, 255), csgo_font_42, "mm" + ) main2_draw.text( (260, 230), str(detail["cnt"]), @@ -249,7 +257,9 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: base_img = Image.open(TEXTURE / "base" / "weapon_bg.png").resize((500, 110)) weapon_img = await save_img(usr_weapon["image"], "weapon") - weapon_img = weapon_img.resize((int(weapon_img.size[0] * 0.2), int(weapon_img.size[1] * 0.2))) + weapon_img = weapon_img.resize( + (int(weapon_img.size[0] * 0.2), int(weapon_img.size[1] * 0.2)) + ) easy_paste(base_img, weapon_img, (100, 70), "cc") weapon_draw = ImageDraw.Draw(base_img) @@ -274,7 +284,11 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: csgo_font_20, "mm", ) - fsa = f"{usr_weapon['firstShotAccuracy'] * 100:.2f}%" if usr_weapon["firstShotAccuracy"] is not None else "N/A" + fsa = ( + f"{usr_weapon['firstShotAccuracy'] * 100:.2f}%" + if usr_weapon["firstShotAccuracy"] is not None + else "N/A" + ) if usr_weapon["sprayAccuracy"] is None: weapon_draw.text( (285, 60), @@ -291,7 +305,11 @@ async def draw_csgo_info_img(detail: UserDetailData) -> bytes | str: csgo_font_20, "mm", ) - hdr = f"{usr_weapon['headshotRate'] * 100:.2f}" if usr_weapon["headshotRate"] is not None else 0 + hdr = ( + f"{usr_weapon['headshotRate'] * 100:.2f}" + if usr_weapon["headshotRate"] is not None + else 0 + ) weapon_draw.text((430, 31), f"{hdr}", (255, 255, 255, 255), csgo_font_20, "mm") if i % 2 == 0: @@ -431,7 +449,9 @@ def create_background(img_bg: Image.Image) -> Image.Image: return Image.merge("RGBA", img_bg.split()[:3] + (new_alpha,)) -def place_avatar_in_title(titel_img: Image.Image, round_head: Image.Image, name: str, uid: str) -> None: +def place_avatar_in_title( + titel_img: Image.Image, round_head: Image.Image, name: str, uid: str +) -> None: """在标题图像中放置头像和文本信息""" easy_paste(titel_img, round_head, (112, 108), "cc") head_draw = ImageDraw.Draw(titel_img) @@ -445,7 +465,9 @@ async def add_summary_and_stars(titel_img: Image.Image, detail: UserDetailData) pj_img = Image.open(TEXTURE / "base" / "blue.png") pj_text = detail["summary"] pj_draw = ImageDraw.Draw(pj_img) - pj_draw.text((118, 24), f"评价:{pj_text}", (255, 255, 255, 255), csgo_font_30, "mm") + pj_draw.text( + (118, 24), f"评价:{pj_text}", (255, 255, 255, 255), csgo_font_30, "mm" + ) titel_img.paste(pj_img, (235, 170), pj_img) if detail["stars"] > 0: diff --git a/CS2UID/csgo_info/csgo_match.py b/CS2UID/csgo_info/csgo_match.py index d1cda1e..bf61f21 100644 --- a/CS2UID/csgo_info/csgo_match.py +++ b/CS2UID/csgo_info/csgo_match.py @@ -19,7 +19,9 @@ FONT_PATH = Path(__file__).parent / "font/萝莉体 第二版.ttf" -async def get_csgo_match_img(user_id, uid: str, tag: int, _type: int) -> Union[str, bytes]: +async def get_csgo_match_img( + user_id, uid: str, tag: int, _type: int +) -> Union[str, bytes]: detail = await pf_api.get_csgopfmatch(uid, tag, _type) logger.debug(detail) if isinstance(detail, dict) and detail["data"] is None: @@ -63,7 +65,9 @@ async def get_csgo_match_img(user_id, uid: str, tag: int, _type: int) -> Union[s else: match_type = "完美平台对战" - return await draw_csgo_match_img(detail["data"]["matchList"], name, avatar, uid, match_type) + return await draw_csgo_match_img( + detail["data"]["matchList"], name, avatar, uid, match_type + ) async def create_one_match_img(detail: Match) -> Image.Image: @@ -103,7 +107,9 @@ async def create_one_match_img(detail: Match) -> Image.Image: return img -async def draw_csgo_match_img(detail: List[Match], name: str, avatar: str, uid: str, match_type: str) -> bytes | str: +async def draw_csgo_match_img( + detail: List[Match], name: str, avatar: str, uid: str, match_type: str +) -> bytes | str: if not detail: return "token已过期" diff --git a/CS2UID/csgo_info/csgo_matchdetail.py b/CS2UID/csgo_info/csgo_matchdetail.py index c14856f..8247776 100644 --- a/CS2UID/csgo_info/csgo_matchdetail.py +++ b/CS2UID/csgo_info/csgo_matchdetail.py @@ -89,13 +89,21 @@ async def draw_csgo_match_img(detail: MatchTotal) -> bytes | str: await simple_paste_img(map_img, "地图时长", (220, 250), size=30) await simple_paste_img(map_img, f"{base['duration']}分钟", (220, 300), size=30) await simple_paste_img(map_img, "结束时间", (390, 250), size=30) - await simple_paste_img(map_img, str(base["endTime"][:10]).strip(), (390, 300), size=30) - await simple_paste_img(map_img, str(base["endTime"][11:]).strip(), (390, 340), size=30) + await simple_paste_img( + map_img, str(base["endTime"][:10]).strip(), (390, 300), size=30 + ) + await simple_paste_img( + map_img, str(base["endTime"][11:]).strip(), (390, 340), size=30 + ) await simple_paste_img(map_img, "匹配方式", (560, 250), size=30) if base["greenMatch"]: - await simple_paste_img(map_img, "天梯绿色对局", (560, 300), size=30, color="green") + await simple_paste_img( + map_img, "天梯绿色对局", (560, 300), size=30, color="green" + ) else: - await simple_paste_img(map_img, "天梯普通对局", (560, 300), size=30, color="blue") + await simple_paste_img( + map_img, "天梯普通对局", (560, 300), size=30, color="blue" + ) img_bg.paste(map_img, (75, -100), mask=map_img) print(players[0]) diff --git a/CS2UID/csgo_info/csgohome_info.py b/CS2UID/csgo_info/csgohome_info.py index 19a3c52..6d27652 100644 --- a/CS2UID/csgo_info/csgohome_info.py +++ b/CS2UID/csgo_info/csgohome_info.py @@ -37,7 +37,9 @@ async def get_csgohome_info_img(uid: str, friend: bool = False): return await draw_csgohome_info_img(data["data"], fall["result"]) -async def draw_csgohome_info_img(detail: UserHomedetailData, fall: UserFall) -> bytes | str: +async def draw_csgohome_info_img( + detail: UserHomedetailData, fall: UserFall +) -> bytes | str: if not detail: return "token已过期" @@ -114,7 +116,9 @@ async def draw_csgohome_info_img(detail: UserHomedetailData, fall: UserFall) -> csgo_font_42, "mm", ) - main2_draw.text((105, 230), str(rank_scoce), (255, 255, 255, 255), csgo_font_42, "mm") + main2_draw.text( + (105, 230), str(rank_scoce), (255, 255, 255, 255), csgo_font_42, "mm" + ) main2_draw.text( (260, 230), str(detail["cnt"]), @@ -173,7 +177,9 @@ async def draw_csgohome_info_img(detail: UserHomedetailData, fall: UserFall) -> map_logo = (await save_img(usr_map["mapLogo"], "map")).resize((50, 50)) easy_paste(map_img, map_logo, (40, 60), "cc") rank_png = f"{usr_map['rank'] if usr_map['rank'] is not None else '0'}.png" - rank_img = Image.open(TEXTURE / "rank_gp" / rank_png).resize((100, 40)).convert("RGBA") + rank_img = ( + Image.open(TEXTURE / "rank_gp" / rank_png).resize((100, 40)).convert("RGBA") + ) easy_paste(map_img, rank_img, (70, 120), "cc") @@ -231,7 +237,9 @@ async def draw_csgohome_info_img(detail: UserHomedetailData, fall: UserFall) -> base_img = Image.open(TEXTURE / "base" / "weapon_bg.png").resize((500, 110)) weapon_img = await save_img(usr_weapon["weaponImage"], "weapon") - weapon_img = weapon_img.resize((int(weapon_img.size[0] * 0.2), int(weapon_img.size[1] * 0.2))) + weapon_img = weapon_img.resize( + (int(weapon_img.size[0] * 0.2), int(weapon_img.size[1] * 0.2)) + ) easy_paste(base_img, weapon_img, (100, 70), "cc") weapon_draw = ImageDraw.Draw(base_img) diff --git a/CS2UID/csgo_info/utils.py b/CS2UID/csgo_info/utils.py index 93d02d6..375baaf 100644 --- a/CS2UID/csgo_info/utils.py +++ b/CS2UID/csgo_info/utils.py @@ -192,7 +192,9 @@ async def load_groudback(bg_img_path: Path | Image.Image, alpha_percent: float = first_img = first_img.convert("RGBA") else: first_img = bg_img_path - transparent_img = Image.new("RGBA", first_img.size, (255, 255, 255, int(255 * alpha_percent))) + transparent_img = Image.new( + "RGBA", first_img.size, (255, 255, 255, int(255 * alpha_percent)) + ) first_img.paste(transparent_img, None, transparent_img) return first_img @@ -337,7 +339,11 @@ async def make_homeweapen_img(usr_weapon: UserhomeWeapon): await simple_paste_img(out_img, usr_weapon["weaponName"], (10, 70), size=30) avkill = usr_weapon["weaponKill"] / usr_weapon["totalMatch"] - hs = usr_weapon["weaponHeadShot"] / usr_weapon["weaponKill"] if usr_weapon["weaponKill"] else 0 + hs = ( + usr_weapon["weaponHeadShot"] / usr_weapon["weaponKill"] + if usr_weapon["weaponKill"] + else 0 + ) hs_out = f"{(hs * 100):.2f}%" if hs else "0%" print_msg = [ diff --git a/CS2UID/csgo_items/__init__.py b/CS2UID/csgo_items/__init__.py index 89684f2..19bb314 100644 --- a/CS2UID/csgo_items/__init__.py +++ b/CS2UID/csgo_items/__init__.py @@ -104,8 +104,16 @@ async def csgo_item_all(bot: Bot, ev: Event): elif len(tag_list) == 1: map_name = await find_map_key(tag_list[0]) if map_name in data: - points = [point_folder.name for point_folder in (root_path / map_name).glob("*/") if point_folder.is_dir()] - msg = f"当前地图{map_name}支持的点位有:\n" + ",".join(points) + "\n请输入【csgo道具 + 地图 + 点位】查询" + points = [ + point_folder.name + for point_folder in (root_path / map_name).glob("*/") + if point_folder.is_dir() + ] + msg = ( + f"当前地图{map_name}支持的点位有:\n" + + ",".join(points) + + "\n请输入【csgo道具 + 地图 + 点位】查询" + ) await bot.send(await text2pic(msg), at_sender=True) return else: @@ -114,7 +122,9 @@ async def csgo_item_all(bot: Bot, ev: Event): elif len(tag_list) == 2: map_name = await find_map_key(tag_list[0]) - if map_name not in data: # 如果没有找到匹配的地图,find_map_key 可能返回原始别名 + if ( + map_name not in data + ): # 如果没有找到匹配的地图,find_map_key 可能返回原始别名 await bot.send("没有该地图,请使用指令【csgo道具】查询地图") return @@ -150,7 +160,9 @@ async def csgo_item_all(bot: Bot, ev: Event): tag_list = [tag_list[0], tag_list[1], tag_list[1], tag_list[2]] if len(tag_list) != 4: - await bot.send("参数不正确,请输入【csgo道具 地图名 点位 目的点位 烟/火/闪】/n例如:沙2 匪口 b门 烟") + await bot.send( + "参数不正确,请输入【csgo道具 地图名 点位 目的点位 烟/火/闪】/n例如:沙2 匪口 b门 烟" + ) return if len(tag_list) == 4: diff --git a/CS2UID/csgo_items/message.py b/CS2UID/csgo_items/message.py index d7d9d22..39126b0 100644 --- a/CS2UID/csgo_items/message.py +++ b/CS2UID/csgo_items/message.py @@ -97,7 +97,11 @@ async def build_map_pattern(): # 将所有地图的别名转义并合并成一个大的选择组 - escaped_aliases = ["(?:{})".format(re.escape(alias)) for aliases in map_dict.values() for alias in aliases] + escaped_aliases = [ + "(?:{})".format(re.escape(alias)) + for aliases in map_dict.values() + for alias in aliases + ] return re.compile(f"^({'|'.join(escaped_aliases)})", re.IGNORECASE) diff --git a/CS2UID/csgo_items/utils.py b/CS2UID/csgo_items/utils.py index 72af083..b1e6bae 100644 --- a/CS2UID/csgo_items/utils.py +++ b/CS2UID/csgo_items/utils.py @@ -76,7 +76,9 @@ async def black_match(tag_list: List[str]) -> Union[str, Image.Image]: filtered_group = [one for one in one_group if "快烟" in one] else: # 如果关键词不是"快烟",则排除含有"快烟"的项,同时保留包含filter_keyword的项 - filtered_group = [one for one in one_group if "快烟" not in one and filter_keyword in one] + filtered_group = [ + one for one in one_group if "快烟" not in one and filter_keyword in one + ] print("fil", len(filtered_group)) # 如果filtered_group非空,则添加到item_list中 @@ -113,12 +115,16 @@ async def re_match(texts: str, bot: Bot): 目前暂时使用空格匹配""" map_pattern = await build_map_pattern() - tag_pattern = re.compile(rf"^{('|'.join(re.escape(tag) for tag in tag_lists))}\b", re.IGNORECASE) + tag_pattern = re.compile( + rf"^{('|'.join(re.escape(tag) for tag in tag_lists))}\b", re.IGNORECASE + ) pattern_list_1 = "|".join(re.escape(tag) for tag in tag_list_1) pattern_list_2 = "|".join(re.escape(tag) for tag in tag_list_2) # 构建匹配tag_list_1中的标签后跟tag_list_2中的标签的正则表达式,但不要求\b在tag_list_2后 - tag_pattern_combo = re.compile(rf"\b({pattern_list_1})({pattern_list_2})(?!\w)", re.IGNORECASE) + tag_pattern_combo = re.compile( + rf"\b({pattern_list_1})({pattern_list_2})(?!\w)", re.IGNORECASE + ) map_match = map_pattern.match(texts) if map_match: @@ -148,13 +154,17 @@ async def re_match(texts: str, bot: Bot): if len(positions) == 2: break - positions = [match.group() for match in tag_pattern.finditer(remaining_text)][:2] + positions = [ + match.group() for match in tag_pattern.finditer(remaining_text) + ][:2] print(positions) if len(positions) == 2: tag_set_1 = set(tag_list_1) tag_set_2 = set(tag_list_2) pos1, pos2 = positions - is_match = (pos1 in tag_set_1 and pos2 in tag_set_2) or (pos1 in tag_set_2 and pos2 in tag_set_1) + is_match = (pos1 in tag_set_1 and pos2 in tag_set_2) or ( + pos1 in tag_set_2 and pos2 in tag_set_1 + ) if is_match: # 查找pos2的结束位置并更新remaining_text diff --git a/CS2UID/csgo_user/__init__.py b/CS2UID/csgo_user/__init__.py index 2300742..483afc3 100644 --- a/CS2UID/csgo_user/__init__.py +++ b/CS2UID/csgo_user/__init__.py @@ -56,11 +56,15 @@ async def send_csgo_bind_uid_msg(bot: Bot, ev: Event): if "绑定" in ev.command: if not uid: - return await bot.send("该命令需要带上正确的uid!\n如果不知道, 可以使用[cs搜索5e xxx]查询uid") + return await bot.send( + "该命令需要带上正确的uid!\n如果不知道, 可以使用[cs搜索5e xxx]查询uid" + ) # data = await CS2Bind.insert_uid( # qid, ev.bot_id, uid, ev.group_id, is_digit=False # ) - data = await CS2Bind.update_data(qid, ev.bot_id, domain=uid, group_id=ev.group_id) + data = await CS2Bind.update_data( + qid, ev.bot_id, domain=uid, group_id=ev.group_id + ) return await send_diff_msg( bot, data, @@ -94,12 +98,18 @@ async def send_csgo_bind_uid_msg(bot: Bot, ev: Event): await bot.logger.info("[CS2] [绑定/解绑]UserID: {}".format(qid)) if uid and not uid.isdigit() or uid and len(uid) != 17: - return await bot.send("你输入了错误的格式!\n正确的UID是个人资料steam64位id\n可以使用[cs搜索 xxx]查询uid") + return await bot.send( + "你输入了错误的格式!\n正确的UID是个人资料steam64位id\n可以使用[cs搜索 xxx]查询uid" + ) if "绑定" in ev.command: if not uid: - return await bot.send("该命令需要带上正确的uid!(steam64位id)\n如果不知道, 可以使用[cs搜索 xxx]查询uid") - data = await CS2Bind.insert_uid(qid, ev.bot_id, uid, ev.group_id, is_digit=False) + return await bot.send( + "该命令需要带上正确的uid!(steam64位id)\n如果不知道, 可以使用[cs搜索 xxx]查询uid" + ) + data = await CS2Bind.insert_uid( + qid, ev.bot_id, uid, ev.group_id, is_digit=False + ) return await send_diff_msg( bot, data, diff --git a/requirements.txt b/requirements.txt index e69de29..d99071a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,3 @@ +# This file was autogenerated by uv via the following command: +# uv export --frozen --output-file=requirements.txt +-e .