fix: pending 파일명 _pending.json 접미사 추가 + 에러 복구 강화
- _publish_next에서 파일명에 _pending 접미사 추가 (get_pending_list 매칭) - check_safety 실패 시에도 수동 검토로 전환 (무조건 pending 이동) - safety_keywords.json의 재테크절약 → 재테크 수정 - /write 후 인라인 버튼 callback_data도 _pending 파일명 사용 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -261,18 +261,27 @@ def _publish_next():
|
||||
originals_dir = DATA_DIR / 'originals'
|
||||
pending_dir = DATA_DIR / 'pending_review'
|
||||
pending_dir.mkdir(exist_ok=True)
|
||||
safety_cfg = publisher_bot.load_config('safety_keywords.json')
|
||||
try:
|
||||
safety_cfg = publisher_bot.load_config('safety_keywords.json')
|
||||
except Exception as e:
|
||||
logger.warning(f"safety_keywords.json 로드 실패, 기본값 사용: {e}")
|
||||
safety_cfg = {}
|
||||
for f in sorted(originals_dir.glob('*.json')):
|
||||
try:
|
||||
article = json.loads(f.read_text(encoding='utf-8'))
|
||||
needs_review, reason = publisher_bot.check_safety(article, safety_cfg)
|
||||
try:
|
||||
needs_review, reason = publisher_bot.check_safety(article, safety_cfg)
|
||||
except Exception as e:
|
||||
logger.warning(f"check_safety 실패, 수동 검토로 전환: {e}")
|
||||
reason = '안전검사 오류 — 수동 검토'
|
||||
article['pending_reason'] = reason or '수동 승인 필요'
|
||||
dest = pending_dir / f.name
|
||||
pending_name = f.stem + '_pending.json'
|
||||
dest = pending_dir / pending_name
|
||||
dest.write_text(json.dumps(article, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||
f.unlink()
|
||||
logger.info(f"검토 대기로 이동: {f.name} ({reason})")
|
||||
logger.info(f"검토 대기로 이동: {pending_name} ({reason})")
|
||||
except Exception as e:
|
||||
logger.error(f"publish_next 오류 ({f.name}): {e}")
|
||||
logger.error(f"publish_next 오류 ({f.name}): {e}", exc_info=True)
|
||||
|
||||
|
||||
def job_convert():
|
||||
@@ -686,7 +695,8 @@ async def cmd_write(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
await loop.run_in_executor(None, _publish_next)
|
||||
# pending_review에서 방금 작성된 글 찾기
|
||||
pending_dir = DATA_DIR / 'pending_review'
|
||||
pending_file = pending_dir / topic_file.name
|
||||
pending_name = topic_file.stem + '_pending.json'
|
||||
pending_file = pending_dir / pending_name
|
||||
if pending_file.exists():
|
||||
article = json.loads(pending_file.read_text(encoding='utf-8'))
|
||||
title = article.get('title', '')[:50]
|
||||
@@ -695,8 +705,8 @@ async def cmd_write(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
# 인라인 버튼으로 승인/거부
|
||||
keyboard = InlineKeyboardMarkup([
|
||||
[
|
||||
InlineKeyboardButton("✅ 승인 발행", callback_data=f"approve:{topic_file.name}"),
|
||||
InlineKeyboardButton("🗑 거부", callback_data=f"reject:{topic_file.name}"),
|
||||
InlineKeyboardButton("✅ 승인 발행", callback_data=f"approve:{pending_name}"),
|
||||
InlineKeyboardButton("🗑 거부", callback_data=f"reject:{pending_name}"),
|
||||
]
|
||||
])
|
||||
await update.message.reply_text(
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"legal_keywords": [
|
||||
"불법", "위법", "처벌", "벌금", "징역", "기소"
|
||||
],
|
||||
"always_manual_review": ["팩트체크", "재테크절약"],
|
||||
"always_manual_review": ["팩트체크", "재테크"],
|
||||
"min_sources_required": 2,
|
||||
"min_quality_score_for_auto": 101
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user