fix: /idea RSS 소스 검색 복원 + 15초 타임아웃 폴백
검색 성공 시 소스 표시, 15초 초과 시 키워드만으로 저장 후 진행. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+30
-19
@@ -742,25 +742,31 @@ 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()
|
||||||
if not corner:
|
try:
|
||||||
corner = _guess_corner(keyword, keyword)
|
topic_data = await asyncio.wait_for(
|
||||||
|
loop.run_in_executor(None, _search_and_build_topic, keyword, corner),
|
||||||
topic_data = {
|
timeout=15
|
||||||
'topic': keyword,
|
)
|
||||||
'description': f"{keyword}에 대한 최신 정보와 분석",
|
except (asyncio.TimeoutError, Exception):
|
||||||
'source': 'idea',
|
# 검색 실패 시 키워드만으로 저장
|
||||||
'source_name': '직접 입력',
|
if not corner:
|
||||||
'source_url': '',
|
corner = _guess_corner(keyword, keyword)
|
||||||
'published_at': datetime.now().strftime('%Y-%m-%d'),
|
topic_data = {
|
||||||
'corner': corner,
|
'topic': keyword,
|
||||||
'quality_score': 85,
|
'description': f"{keyword}에 대한 최신 정보와 분석",
|
||||||
'search_demand_score': 9,
|
'source': 'idea',
|
||||||
'topic_type': 'trending',
|
'source_name': '직접 입력',
|
||||||
'source_image': '',
|
'source_url': '',
|
||||||
'is_english': not any('\uAC00' <= c <= '\uD7A3' for c in keyword),
|
'published_at': datetime.now().strftime('%Y-%m-%d'),
|
||||||
'sources': [],
|
'corner': corner,
|
||||||
}
|
'quality_score': 85,
|
||||||
|
'search_demand_score': 9,
|
||||||
|
'topic_type': 'trending',
|
||||||
|
'source_image': '',
|
||||||
|
'is_english': not any('\uAC00' <= c <= '\uD7A3' for c in keyword),
|
||||||
|
'sources': [],
|
||||||
|
}
|
||||||
|
|
||||||
# topics 폴더에 저장
|
# topics 폴더에 저장
|
||||||
topics_dir = DATA_DIR / 'topics'
|
topics_dir = DATA_DIR / 'topics'
|
||||||
@@ -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