#!/usr/bin/env python3
"""READ-ONLY: siapa pengomentar pada postingan uji."""
import json, sys

WS = "/home/mantapman/.hermes/profiles/atun/workspace"
sys.path.insert(0, WS)
from repliz_client import get_client, ACC

client = get_client()
semua, page = [], 1
while True:
    d = client.get(f"/public/comment?page={page}&limit=100")
    rows = d.get("docs", []) if isinstance(d, dict) else []
    semua += rows
    if len(rows) < 100:
        break
    page += 1

TARGET = {"17954840181261293", "17960526738226524"}
for c in semua:
    if c.get("accountId") != ACC.UKY_THREADS:
        continue
    k = c.get("content") or {}
    if isinstance(k, str):
        try: k = json.loads(k.replace("'", '"'))
        except Exception: k = {}
    if str(k.get("id")) not in TARGET:
        continue
    cm = c.get("comment") or {}
    if isinstance(cm, str):
        try: cm = json.loads(cm.replace("'", '"'))
        except Exception: cm = {}
    print(json.dumps({"post": k.get("id"), "createdAt": c.get("createdAt"), "status": c.get("status"),
                      "kunci_comment": sorted(cm.keys()), "comment": cm}, ensure_ascii=False)[:900])
    print()
