fix: 발행 완료된 글감을 /collect, /write 목록에서 제외

- publish() 성공 시 topics/ 에서 해당 topic 파일 자동 삭제
- /write, /collect 목록에 발행 제목 유사도 80% 필터 추가
- _load_published_titles(), _filter_unpublished() 헬퍼 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JOUNGWOOK KWON
2026-03-31 08:55:27 +09:00
parent e1fb6c954a
commit 1bdd212639
2 changed files with 61 additions and 0 deletions
+19
View File
@@ -547,6 +547,22 @@ def log_published(article: dict, post_result: dict):
return record
def _cleanup_published_topic(article: dict):
"""발행 완료된 topic 파일을 topics/ 에서 삭제"""
import hashlib
topics_dir = DATA_DIR / 'topics'
topic_text = article.get('topic', '') or article.get('title', '')
if not topic_text:
return
topic_id = hashlib.md5(topic_text.encode()).hexdigest()[:8]
for f in topics_dir.glob(f'*_{topic_id}.json'):
try:
f.unlink()
logger.info(f"발행 완료 topic 파일 삭제: {f.name}")
except Exception as e:
logger.debug(f"topic 파일 삭제 실패: {e}")
def save_pending_review(article: dict, reason: str):
"""수동 검토 대기 글 저장"""
pending_dir = DATA_DIR / 'pending_review'
@@ -617,6 +633,9 @@ def publish(article: dict) -> bool:
# 발행 이력 저장
log_published(article, post_result)
# 발행 완료된 topic 파일 정리
_cleanup_published_topic(article)
# Telegram 알림
title = article.get('title', '')
corner = article.get('corner', '')