fix(评论): 输入文字读取 comment_text,修复输入框为空
- CommentItem.to_dict 的键是 comment_text,input_text 之前读 item['text'] 拿不到 → 步骤 ok 但没输入 - foreach_comment 兼容补 text 键 - test_comment 覆盖真实键名
This commit is contained in:
@@ -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"), "输入框评论")
|
||||
|
||||
@@ -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"(前面要先有「循环评论」步骤)")
|
||||
|
||||
Reference in New Issue
Block a user