#!/usr/bin/env python3
"""hc52: cek CJK + hashtag + mention pada 3 jadwal baru (baca ulang dari API)."""
import re
import sys

sys.path.insert(0, "/home/mantapman/.hermes/profiles/atun/workspace")
from repliz_client import ReplizClient

c = ReplizClient()
IDS = {"threads_album": "6abd5d401246a403edae84a7",
       "threads_reply1": "6abd5d411246a403edae84af",
       "threads_reply2": "6abd5d411733078385fdd10f",
       "linkedin": "6abd5d411246a403edae84c1",
       "facebook": "6abd5d411733078385fdd129"}
bad = 0
for name, sid in IDS.items():
    d = c.get("/public/schedule/%s" % sid)
    doc = d.get("doc") or d.get("data") or d
    txt = doc.get("description") or ""
    cjk = re.findall(r"[\u3000-\u9fff\uff00-\uffef]", txt)
    caps = [t for t in re.findall(r"#(\w+)", txt) if t != t.lower()]
    ment = re.findall(r"@\w+", txt)
    print("%-16s status=%-8s len=%-5d CJK=%d hashtag_kapital=%s mention=%s" % (
        name, doc.get("status"), len(txt), len(cjk), caps, ment))
    if cjk or caps or ment:
        bad += 1
print("\nTEMUAN:", bad)
sys.exit(1 if bad else 0)
