From 7b0d8d8a0f7646333c3fcd3a4e0cf5539742d8d5 Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Sat, 31 Oct 2026 10:26:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=AF=84=E8=AE=BA):=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=96=87=E5=AD=97=E8=AF=BB=E5=8F=96=20comment=5Ftext=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=85=A5=E6=A1=86=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CommentItem.to_dict 的键是 comment_text,input_text 之前读 item['text'] 拿不到 → 步骤 ok 但没输入 - foreach_comment 兼容补 text 键 - test_comment 覆盖真实键名 --- scripts/tests/test_comment.py | 2 +- tasks/generic/task.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/tests/test_comment.py b/scripts/tests/test_comment.py index 9b39368..b124a38 100644 --- a/scripts/tests/test_comment.py +++ b/scripts/tests/test_comment.py @@ -187,7 +187,7 @@ class _D: w5 = gt.GenericStepsWorker("S1", {"steps": []}) -w5._vars["comment"] = {"text": "输入框评论"} +w5._vars["comment"] = {"comment_text": "输入框评论"} w5._verify_input = lambda d, text, clear: True w5._exec_input_text(_D(), {"text_source": "comment", "clear_first": True}) check("input_text 取评论内容", sent.get("text"), "输入框评论") diff --git a/tasks/generic/task.py b/tasks/generic/task.py index ab36d12..34042a8 100644 --- a/tasks/generic/task.py +++ b/tasks/generic/task.py @@ -2573,6 +2573,8 @@ class GenericStepsWorker(BaseWorker): if not item: _log.info(f"[{self.serial}] 『{target}』没有待评论了 → 这个号收工") break + item = dict(item) + item["text"] = item.get("comment_text") or "" self._last_comment = item self._vars["comment"] = item self._vars["comment_url"] = item.get("video_url") or "" @@ -2834,7 +2836,9 @@ class GenericStepsWorker(BaseWorker): text = "" if src == "comment": item = self._vars.get("comment") or {} - text = str(item.get("text") or "").strip() + # CommentItem.to_dict 的键是 comment_text(不是 text);两者都认, + # 避免"输入步骤显示 ok、实际一个字都没进去"(2026-10-31 实测踩过)。 + text = str(item.get("comment_text") or item.get("text") or "").strip() if not text: _log.warning(f"[{self.serial}] 输入文字:当前没有可用的评论内容 → 跳过" f"(前面要先有「循环评论」步骤)")