fix: /idea RSS 소스 검색 복원 + 15초 타임아웃 폴백
검색 성공 시 소스 표시, 15초 초과 시 키워드만으로 저장 후 진행. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-2
@@ -742,10 +742,16 @@ async def cmd_idea(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
await update.message.reply_text("❌ 키워드를 입력하세요.")
|
await update.message.reply_text("❌ 키워드를 입력하세요.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 네트워크 없이 즉시 topic_data 생성
|
loop = asyncio.get_event_loop()
|
||||||
|
try:
|
||||||
|
topic_data = await asyncio.wait_for(
|
||||||
|
loop.run_in_executor(None, _search_and_build_topic, keyword, corner),
|
||||||
|
timeout=15
|
||||||
|
)
|
||||||
|
except (asyncio.TimeoutError, Exception):
|
||||||
|
# 검색 실패 시 키워드만으로 저장
|
||||||
if not corner:
|
if not corner:
|
||||||
corner = _guess_corner(keyword, keyword)
|
corner = _guess_corner(keyword, keyword)
|
||||||
|
|
||||||
topic_data = {
|
topic_data = {
|
||||||
'topic': keyword,
|
'topic': keyword,
|
||||||
'description': f"{keyword}에 대한 최신 정보와 분석",
|
'description': f"{keyword}에 대한 최신 정보와 분석",
|
||||||
@@ -775,10 +781,15 @@ async def cmd_idea(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
all_files = sorted(topics_dir.glob(f'{today}_*.json'))
|
all_files = sorted(topics_dir.glob(f'{today}_*.json'))
|
||||||
idx = next((i for i, f in enumerate(all_files, 1) if f.name == filename), len(all_files))
|
idx = next((i for i, f in enumerate(all_files, 1) if f.name == filename), len(all_files))
|
||||||
|
|
||||||
|
sources = topic_data.get('sources', [])
|
||||||
|
source_lines = [f" • {s.get('title', '')[:45]}" for s in sources[:3]]
|
||||||
|
sources_text = '\n'.join(source_lines) if source_lines else " (AI 자체 지식으로 작성)"
|
||||||
|
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
f"✅ 글감 등록! (#{idx})\n"
|
f"✅ 글감 등록! (#{idx})\n"
|
||||||
f"주제: {topic_data.get('topic', '')[:60]}\n"
|
f"주제: {topic_data.get('topic', '')[:60]}\n"
|
||||||
f"카테고리: {topic_data.get('corner', '')}\n\n"
|
f"카테고리: {topic_data.get('corner', '')}\n\n"
|
||||||
|
f"📰 참고 자료:\n{sources_text}\n\n"
|
||||||
f"👉 /write {idx}"
|
f"👉 /write {idx}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user