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"(前面要先有「循环评论」步骤)")