From 8838b62e61307ba6d127e21059fde824fcdd2e40 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 4 Jan 2026 11:31:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E9=AB=98=E4=BB=B7?= =?UTF-8?q?=E5=80=BC=E7=A6=8F=E8=A2=8B=E9=A2=84=E7=BA=A6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=8F=90=E5=89=8D=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=92=8C=E6=8F=90=E9=AB=98=E6=9C=80=E4=BD=8E?= =?UTF-8?q?=E5=A5=96=E5=93=81=E4=BB=B7=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- Underlying_Operations.py | 26 +++++++------ config.json | 2 +- config/config.json | 8 ++-- douyin/core/state/reservations.json | 57 ++++------------------------- douyin/other/douyin_yanghao.py | 4 +- gui/gui_app.py | 6 +-- tools/check_gui_params_conflicts.py | 2 +- webui/app.js | 4 +- 9 files changed, 35 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 43dfbb3..69e0b16 100644 --- a/README.md +++ b/README.md @@ -587,7 +587,7 @@ python run_cli.py \ |--------|------|--------|------| | `high_value_fudai_enabled` | boolean | `true` | 是否启用高价值福袋预约功能 | | `high_value_fudai_threshold_yuan` | float | `500.0` | 高价值福袋的阈值(元),价值≥该值则预约 | -| `high_value_fudai_join_ahead_seconds` | integer | `120` | 提前参与秒数,开奖前 N 秒返回直播间参与 | +| `high_value_fudai_join_ahead_seconds` | integer | `300` | 提前参与秒数,开奖前 N 秒返回直播间参与 | | `high_value_fudai_max_swipe_back` | integer | `35` | 最多回退直播间次数,防止回退过远导致异常 | | `high_value_fudai_max_reservations` | integer | `3` | 最多同时记录的预约数量,超过后丢弃最晚开奖的 | | `high_value_fudai_after_action` | string | `"continue"` | 完成预约后的动作:`"stay"`=停留,`"continue"`=继续抢福袋 | diff --git a/Underlying_Operations.py b/Underlying_Operations.py index ccdb95c..5d5e507 100644 --- a/Underlying_Operations.py +++ b/Underlying_Operations.py @@ -1913,9 +1913,11 @@ class underlying_operations: debug_image = full_screenshot if full_screenshot is not None else img1 # 准备额外信息 + # 保留小数点(包括全角/中文标点归一化为英文点)以便调试时看到如 24.9 这样的值 digits_result = "" if text: - digits_result = "".join(ch for ch in str(text) if ch.isdigit()) + t_norm = str(text).replace("。", ".").replace(",", ".").replace(".", ".") + digits_result = "".join(ch for ch in t_norm if ch.isdigit() or ch == ".") extra_info_dict = { "mode": change_color, @@ -1973,27 +1975,29 @@ class underlying_operations: # 只提取数字字符,并进行智能过滤 if text: - # 提取所有数字字符 - digits = "".join(ch for ch in str(text) if ch.isdigit()) + # 同时准备两种数字抽取结果: + # 1) digits_only: 仅数字(用于倒计时/位置等只需整数的场景) + # 2) digits: 允许小数点(用于金额/带小数的数值),并规范化常见全角标点 + text_norm = str(text).replace("。", ".").replace(",", ".").replace(".", ".") + digits_only = "".join(ch for ch in text_norm if ch.isdigit()) + digits = "".join(ch for ch in text_norm if ch.isdigit() or ch == ".") # 智能过滤:如果识别到的数字太多(可能是识别到了文件名或坐标), # 尝试提取合理的数字段 - if len(digits) > 10: + if len(digits_only) > 10: # 对于价值:通常不超过6位数字(999999元以内) # 对于倒计时:通常是1-2位数字 # 尝试提取最后几个数字(通常是实际值) # 或者提取最短的连续数字段 - # 提取所有连续的数字段 - digit_segments = re.findall(r"\d+", str(text)) + # 提取所有连续的数字段(允许小数点的段落匹配) + digit_segments = re.findall(r"\d+(?:\.\d+)?", text_norm) if digit_segments: - # 对于价值,选择最大的合理数字段(不超过6位) + # 对于价值,选择最大的合理数字段(不超过6位数字,不计小数点) # 对于倒计时,选择1-2位的数字段 # 这里先返回所有数字,让调用方处理 - # 但优先选择较短的段(1-6位) - reasonable_segments = [ - s for s in digit_segments if 1 <= len(s) <= 6 - ] + # 但优先选择较短的段(1-6位),忽略小数点长度影响 + reasonable_segments = [s for s in digit_segments if 1 <= len(s.replace('.', '')) <= 6] if reasonable_segments: # 如果有多段,优先选择较短的(倒计时)或较长的(价值) # 这里返回最长的合理段(通常是价值) diff --git a/config.json b/config.json index 559b9d6..94fbc87 100644 --- a/config.json +++ b/config.json @@ -17,7 +17,7 @@ "lucky_draw_red_ratio_threshold": 0.8, "high_value_fudai_enabled": true, "high_value_fudai_threshold_yuan": 500.0, - "high_value_fudai_join_ahead_seconds": 120, + "high_value_fudai_join_ahead_seconds": 300, "high_value_fudai_max_swipe_back": 50, "high_value_fudai_max_reservations": 9999, "high_value_fudai_after_action": "continue", diff --git a/config/config.json b/config/config.json index 31be595..7c18b44 100644 --- a/config/config.json +++ b/config/config.json @@ -2,7 +2,7 @@ "needswitch": true, "infinite_loop_enabled": true, "wait_minutes": 5, - "min_prize_value_yuan": 200.0, + "min_prize_value_yuan": 250.0, "min_participants": 0, "max_participants": 0, "skip_if_countdown_gt_seconds": 180, @@ -16,8 +16,8 @@ "high_value_fudai_max_swipe_back": 50, "high_value_fudai_max_reservations": 9999, "high_value_fudai_after_action": "continue", - "high_value_room_revisit_enabled": true, - "high_value_room_revisit_only_current_run": true, + "high_value_room_revisit_enabled": false, + "high_value_room_revisit_only_current_run": false, "reservation_back_verify_enabled": true, "reservation_back_swipe_delay": 0.1, "reservation_preempt_min_value": 0.0, @@ -124,7 +124,7 @@ "fudai_template_match_enabled": false, "fudai_template_match_threshold": 0.7, "lucky_draw_red_ratio_threshold": 0.8, - "y_pianyi": 0, + "y_pianyi": -8, "skip_if_countdown_lt_seconds": 5, "no_attend_timeout_minutes": 30.0, "logging": { diff --git a/douyin/core/state/reservations.json b/douyin/core/state/reservations.json index 7f40ae1..837cbe4 100644 --- a/douyin/core/state/reservations.json +++ b/douyin/core/state/reservations.json @@ -1,51 +1,8 @@ { - "updated_ts": 1767493398.0220582, - "reason": "record_reservation", - "room_pos": 3, - "current_room_title": "带娃的小", - "current_room_title_raw": "带娃的小.", - "reservations": [ - { - "prize_value_yuan": 699.0, - "content": "", - "future_ts": 1767493819.527862, - "future_str": "2026-01-04 10:30:19", - "pos_seen": 3, - "room_title": "带娃的小", - "room_title_raw": "带娃的小.", - "created_ts": 1767493297.59925, - "task_count": 2, - "time_text": "08:47", - "participants": 0, - "copies": 0 - }, - { - "prize_value_yuan": 1999.0, - "content": "", - "future_ts": 1767494002.620423, - "future_str": "2026-01-04 10:33:22", - "pos_seen": 0, - "room_title": "作小帮粼", - "room_title_raw": "作小帮粼。。", - "created_ts": 1767493186.2436588, - "task_count": 2, - "time_text": "13:42", - "participants": 0, - "copies": 0 - }, - { - "prize_value_yuan": 1999.0, - "content": "", - "future_ts": 1767494003.40085, - "future_str": "2026-01-04 10:33:23", - "pos_seen": 0, - "room_title": "作川帮数", - "room_title_raw": "作川帮数。。", - "created_ts": 1767493120.9476802, - "task_count": 2, - "time_text": "14:48", - "participants": 0, - "copies": 0 - } - ] -} \ No newline at end of file + "updated_ts": 1767497510.8090184, + "reason": "startup_clear", + "room_pos": 0, + "current_room_title": "", + "current_room_title_raw": "", + "reservations": [] +} diff --git a/douyin/other/douyin_yanghao.py b/douyin/other/douyin_yanghao.py index d74dcc7..5380d09 100644 --- a/douyin/other/douyin_yanghao.py +++ b/douyin/other/douyin_yanghao.py @@ -89,6 +89,8 @@ def yanghao_idle(analyser, total_seconds: int) -> None: _human_delay(1.0, 2.2) need_settle_after_swipe = False _step_shot(f"before_detect_{roi_label}") + # 确保在所有分支中都定义了 roi_path,避免后续使用时未赋值错误 + roi_path = "" # 如果坐标未配置且提供了模板文件,则使用屏幕右侧的默认坐标作为 ROI tpl = str(template_path or "").strip() tpl_exists = False @@ -114,8 +116,6 @@ def yanghao_idle(analyser, total_seconds: int) -> None: except Exception: tpl_exists = False - # 确保 roi_path 在所有分支中都有定义,避免可能的未赋值使用 - roi_path = "" print( f"[养号][DEBUG] _detect_icon action={action} template_path='{template_path}' tpl_exists={tpl_exists}" ) diff --git a/gui/gui_app.py b/gui/gui_app.py index d326884..a6a637a 100644 --- a/gui/gui_app.py +++ b/gui/gui_app.py @@ -384,7 +384,7 @@ def main(): value=float(cfg.get("high_value_fudai_threshold_yuan", 1000) or 1000) ) high_value_fudai_join_ahead_seconds_var = tk.IntVar( - value=int(cfg.get("high_value_fudai_join_ahead_seconds", 120) or 120) + value=int(cfg.get("high_value_fudai_join_ahead_seconds", 300) or 300) ) high_value_fudai_max_swipe_back_var = tk.IntVar( value=int(cfg.get("high_value_fudai_max_swipe_back", 60) or 60) @@ -1577,7 +1577,7 @@ def main(): float(cfg.get("high_value_fudai_threshold_yuan", 1000) or 1000) ) high_value_fudai_join_ahead_seconds_var.set( - int(cfg.get("high_value_fudai_join_ahead_seconds", 120) or 120) + int(cfg.get("high_value_fudai_join_ahead_seconds", 300) or 300) ) high_value_fudai_max_swipe_back_var.set( int(cfg.get("high_value_fudai_max_swipe_back", 60) or 60) @@ -1805,7 +1805,7 @@ def main(): high_value_fudai_threshold_yuan_var.get() or 1000 ) cfg2["high_value_fudai_join_ahead_seconds"] = int( - high_value_fudai_join_ahead_seconds_var.get() or 120 + high_value_fudai_join_ahead_seconds_var.get() or 300 ) cfg2["high_value_fudai_max_swipe_back"] = int( high_value_fudai_max_swipe_back_var.get() or 60 diff --git a/tools/check_gui_params_conflicts.py b/tools/check_gui_params_conflicts.py index d860474..ee61ed0 100644 --- a/tools/check_gui_params_conflicts.py +++ b/tools/check_gui_params_conflicts.py @@ -32,7 +32,7 @@ def check_conflicts(cfg: dict) -> list: # 1. 检查倒计时参数冲突 skip_gt = int(cfg.get("skip_if_countdown_gt_seconds", 900) or 900) skip_lt = int(cfg.get("skip_if_countdown_lt_seconds", 5) or 5) - join_ahead = int(cfg.get("high_value_fudai_join_ahead_seconds", 120) or 120) + join_ahead = int(cfg.get("high_value_fudai_join_ahead_seconds", 300) or 300) if skip_lt >= skip_gt: conflicts.append({ diff --git a/webui/app.js b/webui/app.js index 3fb5df7..bd49363 100644 --- a/webui/app.js +++ b/webui/app.js @@ -36,13 +36,12 @@ const DEFAULTS = { // 高价值福袋预约 high_value_fudai_enabled: false, high_value_fudai_threshold_yuan: 1000, - high_value_fudai_join_ahead_seconds: 120, + high_value_fudai_join_ahead_seconds: 300, high_value_fudai_max_swipe_back: 60, high_value_fudai_max_reservations: 5, high_value_fudai_after_action: "continue", high_value_room_revisit_enabled: true, high_value_room_revisit_only_current_run: false, - high_value_room_revisit_interval_seconds: 3600, reservation_back_verify_enabled: true, // 找福袋图标相关 fudai_find_max_attempts: 5, @@ -567,7 +566,6 @@ async function startRun() { fansclub_fail_action: cfgPart.fansclub_fail_action, high_value_room_revisit_enabled: cfgPart.high_value_room_revisit_enabled, high_value_room_revisit_only_current_run: cfgPart.high_value_room_revisit_only_current_run, - high_value_room_revisit_interval_seconds: cfgPart.high_value_room_revisit_interval_seconds, reservation_back_verify_enabled: cfgPart.reservation_back_verify_enabled, reservation_back_swipe_delay: cfgPart.reservation_back_swipe_delay, fudai_find_max_attempts: cfgPart.fudai_find_max_attempts,