diff --git a/basic_plugins/admin_bot_manage/_data_source.py b/basic_plugins/admin_bot_manage/_data_source.py index 57923262..61edb9bf 100644 --- a/basic_plugins/admin_bot_manage/_data_source.py +++ b/basic_plugins/admin_bot_manage/_data_source.py @@ -1,7 +1,7 @@ import asyncio import os import time -from datetime import datetime, timedelta, timezone +from datetime import datetime from pathlib import Path from typing import List diff --git a/plugins/open_cases/__init__.py b/plugins/open_cases/__init__.py index 8bb06661..e8fefd18 100755 --- a/plugins/open_cases/__init__.py +++ b/plugins/open_cases/__init__.py @@ -226,7 +226,8 @@ async def _(event: MessageEvent, arg: Message = CommandArg()): else: case_list.append(f"{i+1}.{case_name}") await update_data.finish("未指定武器箱, 当前已包含武器箱\n" + "\n".join(case_list)) - await update_data.send(await update_case_data(msg)) + await update_data.send(f"开始更新武器箱: {msg}, 请稍等") + await update_data.send(await update_case_data(msg), at_sender=True) # 重置开箱 diff --git a/plugins/open_cases/models/open_cases_user.py b/plugins/open_cases/models/open_cases_user.py index 05c8f66a..e2de05c1 100755 --- a/plugins/open_cases/models/open_cases_user.py +++ b/plugins/open_cases/models/open_cases_user.py @@ -33,7 +33,7 @@ class OpenCasesUser(Model): """金色""" knife_st_count: int = fields.IntField(default=0) """金色暗金""" - spend_money: int = fields.IntField(default=0) + spend_money: float = fields.IntField(default=0) """花费金币""" make_money: float = fields.FloatField(default=0) """赚取金币""" @@ -52,5 +52,6 @@ class OpenCasesUser(Model): @classmethod async def _run_script(cls): return [ - "alter table open_cases_users alter COLUMN make_money type float;" # 将make_money字段改为float + "alter table open_cases_users alter COLUMN make_money type float;", # 将make_money字段改为float + "alter table open_cases_users alter COLUMN spend_money type float;", # 将spend_money字段改为float ] diff --git a/plugins/open_cases/open_cases_c.py b/plugins/open_cases/open_cases_c.py index 1ab47eba..84b7fbf0 100755 --- a/plugins/open_cases/open_cases_c.py +++ b/plugins/open_cases/open_cases_c.py @@ -32,7 +32,7 @@ COLOR2NAME = {"BLUE": "军规", "PURPLE": "受限", "PINK": "保密", "RED": " COLOR2CN = {"BLUE": "蓝", "PURPLE": "紫", "PINK": "粉", "RED": "红", "KNIFE": "金"} -def add_count(user: OpenCasesUser, skin: BuffSkin): +def add_count(user: OpenCasesUser, skin: BuffSkin, case_price: float): if skin.color == "BLUE": if skin.is_stattrak: user.blue_st_count += 1 @@ -61,7 +61,7 @@ def add_count(user: OpenCasesUser, skin: BuffSkin): user.today_open_total += 1 user.total_count += 1 user.make_money += skin.sell_min_price - user.spend_money += 17 + user.spend_money += 17 + case_price async def get_user_max_count(user_qq: int, group_id: int) -> int: @@ -116,7 +116,10 @@ async def open_case(user_qq: int, group_id: int, case_name: str) -> Union[str, M return "未抽取到任何皮肤..." skin, rand = skin_list[0] rand = str(rand)[:11] - add_count(user, skin) + case_price = 0 + if case_skin := await BuffSkin.get_or_none(case_name=case_name, color="CASE"): + case_price = case_skin.sell_min_price + add_count(user, skin, case_price) ridicule_result = random.choice(RESULT_MESSAGE[skin.color]) price_result = skin.sell_min_price name = skin.name + "-" + skin.skin_name + "-" + skin.abrasion @@ -149,7 +152,7 @@ async def open_case(user_qq: int, group_id: int, case_name: str) -> Union[str, M + "\n" + f"皮肤:[{COLOR2NAME[skin.color]}]{skin.name}{'(StatTrak™)' if skin.is_stattrak else ''} | {skin.skin_name} ({skin.abrasion})\n" f"磨损:{rand}\n" - f"价格:{price_result}\n" + f"价格:{price_result}\n箱子单价:{case_price}\n花费:{17 + case_price}\n" f":{ridicule_result}" ) @@ -202,10 +205,13 @@ async def open_multiple_case( total_price = 0 log_list = [] now = datetime.now() + case_price = 0 + if case_skin := await BuffSkin.get_or_none(case_name=case_name, color="CASE"): + case_price = case_skin.sell_min_price for skin, rand in skin_list: total_price += skin.sell_min_price rand = str(rand)[:11] - add_count(user, skin) + add_count(user, skin, case_price) color_name = COLOR2CN[skin.color] if skin.is_stattrak: color_name += "(暗金)" @@ -266,7 +272,7 @@ async def open_multiple_case( + image(markImg.pic2bs4()) + "\n" + result[:-1] - + f"\n总获取金额:{total_price:.2f}\n总花费:{17 * num}" + + f"\n箱子单价:{case_price}\n总获取金额:{total_price:.2f}\n总花费:{(17 + case_price) * num}" ) diff --git a/plugins/open_cases/utils.py b/plugins/open_cases/utils.py index 99bcdfdf..c30fa423 100755 --- a/plugins/open_cases/utils.py +++ b/plugins/open_cases/utils.py @@ -186,20 +186,26 @@ async def search_skin_page( info = goods_info["info"] tags = info["tags"] obj["weapon_type"] = tags["type"]["localized_name"] # 枪械类型 - if obj["weapon_type"] in ["音乐盒", "印花", "武器箱"]: + if obj["weapon_type"] in ["音乐盒", "印花"]: continue if obj["weapon_type"] in ["匕首", "手套"]: obj["color"] = "KNIFE" obj["name"] = data["short_name"].split("(")[0].strip() # 名称 + if obj["weapon_type"] in ["武器箱"]: + obj["color"] = "CASE" + obj["name"] = data["short_name"] else: obj["color"] = NAME2COLOR[tags["rarity"]["localized_name"]] obj["name"] = tags["weapon"]["localized_name"] # 名称 + if obj["weapon_type"] not in ["武器箱"]: + obj["abrasion"] = tags["exterior"]["localized_name"] # 磨损 + obj["color"] = NAME2COLOR[tags["rarity"]["localized_name"]] # 品质颜色 + obj["is_stattrak"] = "StatTrak" in tags["quality"]["localized_name"] # type: ignore # 是否暗金 + else: + obj["abrasion"] = "CASE" obj["skin_name"] = data["short_name"].split("|")[-1].strip() # 皮肤名称 obj["img_url"] = goods_info["original_icon_url"] # 图片url obj["steam_price"] = goods_info["steam_price_cny"] # steam价格 - obj["abrasion"] = tags["exterior"]["localized_name"] # 磨损 - obj["color"] = NAME2COLOR[tags["rarity"]["localized_name"]] # 品质颜色 - obj["is_stattrak"] = "StatTrak" in tags["quality"]["localized_name"] # type: ignore # 是否暗金 obj["sell_min_price"] = data["sell_min_price"] # 售卖最低价格 obj["sell_num"] = data["sell_num"] # 售卖数量 obj["sell_reference_price"] = data["sell_reference_price"] # 参考价格 @@ -210,8 +216,8 @@ async def search_skin_page( ) return update_data, json_data["data"]["total_page"] else: - logger.warning(f'访问BUFF失败: {json_data["msg"]}') - return f'访问失败: {json_data["msg"]}', -1 + logger.warning(f'访问BUFF失败: {json_data["error"]}') + return f'访问失败: {json_data["error"]}', -1 async def reset_count_daily():