feat: /write 명령에 카테고리 오버라이드 기능 추가
/write 7 AI인사이트 형태로 카테고리를 변경하여 발행 가능. 두 번째 인자가 유효한 카테고리명이면 corner 오버라이드, 아니면 기존 direction으로 처리. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -648,7 +648,8 @@ async def cmd_write(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
lines.append(f" {i}. [{data.get('corner','')}] {data.get('topic','')[:50]}")
|
||||
except Exception:
|
||||
pass
|
||||
lines.append("\n사용법: /write [번호] [방향(선택)]")
|
||||
lines.append("\n사용법: /write [번호] [카테고리(선택)] [방향(선택)]")
|
||||
lines.append("예: /write 7 AI인사이트 ← 카테고리 변경 발행")
|
||||
await update.message.reply_text('\n'.join(lines))
|
||||
return
|
||||
try:
|
||||
@@ -661,11 +662,25 @@ async def cmd_write(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
return
|
||||
topic_file = files[idx]
|
||||
topic_data = json.loads(topic_file.read_text(encoding='utf-8'))
|
||||
direction = ' '.join(args[1:]) if len(args) > 1 else ''
|
||||
# 두 번째 인자: 유효한 카테고리명이면 corner 오버라이드, 아니면 direction
|
||||
VALID_CORNERS = {"AI인사이트", "여행맛집", "스타트업", "TV로보는세상", "제품리뷰", "생활꿀팁", "건강정보", "재테크", "팩트체크"}
|
||||
override_corner = ''
|
||||
direction = ''
|
||||
if len(args) > 1:
|
||||
candidate = args[1]
|
||||
if candidate in VALID_CORNERS:
|
||||
override_corner = candidate
|
||||
direction = ' '.join(args[2:]) if len(args) > 2 else ''
|
||||
else:
|
||||
direction = ' '.join(args[1:])
|
||||
if override_corner:
|
||||
topic_data['corner'] = override_corner
|
||||
draft_path = DATA_DIR / 'originals' / topic_file.name
|
||||
(DATA_DIR / 'originals').mkdir(exist_ok=True)
|
||||
corner_msg = f"\n카테고리: {override_corner} (변경됨)" if override_corner else ""
|
||||
await update.message.reply_text(
|
||||
f"✍️ 글 작성 중...\n주제: {topic_data.get('topic','')[:50]}"
|
||||
+ corner_msg
|
||||
+ (f"\n방향: {direction}" if direction else "")
|
||||
)
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
Reference in New Issue
Block a user