From 2fe04d520a344b9505ab8adc1a8925d12c402dd7 Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Tue, 15 Oct 2024 22:27:53 +0800 Subject: [PATCH 1/4] fix: check app version not work --- autopcr/http_server/httpserver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/autopcr/http_server/httpserver.py b/autopcr/http_server/httpserver.py index cb32139e..7b270045 100644 --- a/autopcr/http_server/httpserver.py +++ b/autopcr/http_server/httpserver.py @@ -78,7 +78,6 @@ def configure_routes(self): @self.api.before_request async def check_app_version(): - return None version = request.headers.get('X-App-Version', None) if version != APP_VERSION: return f"后端期望前端版本为{APP_VERSION},请更新", 400 From d7b4369cd553a9a7e412ade3c25268fe9bed94d6 Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Tue, 15 Oct 2024 22:28:46 +0800 Subject: [PATCH 2/4] fix: equip demand calc error --- autopcr/db/database.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autopcr/db/database.py b/autopcr/db/database.py index cf5c2da3..1939f848 100644 --- a/autopcr/db/database.py +++ b/autopcr/db/database.py @@ -981,9 +981,9 @@ def get_rank_promote_equip_demand(self, unit_id: int, start_rank: int, start_ran (flow(self.unit_promotion_equip_count[unit_id].items()) .where(lambda x: x[0] >= start_rank and x[0] < target_rank) .select(lambda x: x[1]) - .sum(seed=Counter())) - - Counter((eInventoryType(eInventoryType.Equip), int(getattr(self.unit_promotion[unit_id][start_rank], f"equip_slot_{i}"))) for i in range(1, 7) if start_rank_equip_slot[i - 1]) + - Counter((eInventoryType(eInventoryType.Equip), int(getattr(self.unit_promotion[unit_id][target_rank], f"equip_slot_{i}"))) for i in range(1, 7) if target_rank_equip_slot[i - 1]) + .sum(seed=Counter())) + + Counter((eInventoryType(eInventoryType.Equip), int(getattr(self.unit_promotion[unit_id][target_rank], f"equip_slot_{i}"))) for i in range(1, 7) if target_rank_equip_slot[i - 1]) - + Counter((eInventoryType(eInventoryType.Equip), int(getattr(self.unit_promotion[unit_id][start_rank], f"equip_slot_{i}"))) for i in range(1, 7) if start_rank_equip_slot[i - 1]) ) return ret From b42f3f85a5c196d6bb0d7c59d98f0be46d24e78f Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Tue, 15 Oct 2024 22:30:03 +0800 Subject: [PATCH 3/4] fix: gacha key error --- autopcr/module/modules/gacha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autopcr/module/modules/gacha.py b/autopcr/module/modules/gacha.py index f398d3fd..b355fcca 100644 --- a/autopcr/module/modules/gacha.py +++ b/autopcr/module/modules/gacha.py @@ -85,7 +85,7 @@ async def do_task(self, client: pcrclient): if res.campaign_info.fg10_exec_cnt == 0: raise SkipError("今日份免费十连已使用") cnt = res.campaign_info.fg10_exec_cnt - free_gacha_ids = set(gacha.gacha_id for gacha in gacha_list) + free_gacha_ids = set(gacha.gacha_id for gacha in gacha_list) & set(db.gacha_data) open_gacha_ids = set(gacha.id for gacha in res.gacha_info) open_free_gacha_ids = free_gacha_ids & open_gacha_ids close_free_gacha_ids = free_gacha_ids - open_gacha_ids From 28d5985becd8ab60e490ed253bb463eb0741a4e9 Mon Sep 17 00:00:00 2001 From: Lanly109 <1094916227@qq.com> Date: Wed, 16 Oct 2024 13:03:24 +0800 Subject: [PATCH 4/4] fix: result img error --- autopcr/http_server/httpserver.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/autopcr/http_server/httpserver.py b/autopcr/http_server/httpserver.py index 7b270045..ca43173c 100644 --- a/autopcr/http_server/httpserver.py +++ b/autopcr/http_server/httpserver.py @@ -25,6 +25,8 @@ def __init__(self, host = '0.0.0.0', port = 2, qq_mod = False): self.web = Blueprint('web', __name__, static_folder=static_path) + # version check & rate limit + self.api_limit = Blueprint('api_limit', __name__, url_prefix = "/api") self.api = Blueprint('api', __name__, url_prefix = "/api") self.app = Blueprint('app', __name__, url_prefix = "/daily") @@ -37,6 +39,7 @@ def __init__(self, host = '0.0.0.0', port = 2, qq_mod = False): self.app.register_blueprint(self.web) self.app.register_blueprint(self.api) + self.app.register_blueprint(self.api_limit) self.host = host self.port = port @@ -76,7 +79,7 @@ async def inner(*args, **kwargs): def configure_routes(self): - @self.api.before_request + @self.api_limit.before_request async def check_app_version(): version = request.headers.get('X-App-Version', None) if version != APP_VERSION: @@ -84,7 +87,7 @@ async def check_app_version(): else: return None - @self.api.errorhandler(RateLimitExceeded) + @self.api_limit.errorhandler(RateLimitExceeded) async def handle_rate_limit_exceeded_error(error): return "您冲得太快了,休息一下吧", 429 @@ -390,7 +393,7 @@ async def validate(): # TODO think to check login or not validate_ok_dict[id] = ValidateInfo.from_dict(data) return "", 200 - @self.api.route('/login/qq', methods = ['POST']) + @self.api_limit.route('/login/qq', methods = ['POST']) @rate_limit(1, timedelta(seconds=1)) @rate_limit(3, timedelta(minutes=1)) async def login_qq(): @@ -407,7 +410,7 @@ async def login_qq(): else: return "无效的QQ或密码", 400 - @self.api.route('/register', methods = ['POST']) + @self.api_limit.route('/register', methods = ['POST']) @rate_limit(1, timedelta(minutes=1)) async def register(): data = await request.get_json()