fix: /idea RSS 소스 검색 복원 + 15초 타임아웃 폴백
검색 성공 시 소스 표시, 15초 초과 시 키워드만으로 저장 후 진행. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -742,25 +742,31 @@ async def cmd_idea(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
await update.message.reply_text("❌ 키워드를 입력하세요.")
|
||||
return
|
||||
|
||||
# 네트워크 없이 즉시 topic_data 생성
|
||||
if not corner:
|
||||
corner = _guess_corner(keyword, keyword)
|
||||
|
||||
topic_data = {
|
||||
'topic': keyword,
|
||||
'description': f"{keyword}에 대한 최신 정보와 분석",
|
||||
'source': 'idea',
|
||||
'source_name': '직접 입력',
|
||||
'source_url': '',
|
||||
'published_at': datetime.now().strftime('%Y-%m-%d'),
|
||||
'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': [],
|
||||
}
|
||||
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:
|
||||
corner = _guess_corner(keyword, keyword)
|
||||
topic_data = {
|
||||
'topic': keyword,
|
||||
'description': f"{keyword}에 대한 최신 정보와 분석",
|
||||
'source': 'idea',
|
||||
'source_name': '직접 입력',
|
||||
'source_url': '',
|
||||
'published_at': datetime.now().strftime('%Y-%m-%d'),
|
||||
'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_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'))
|
||||
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(
|
||||
f"✅ 글감 등록! (#{idx})\n"
|
||||
f"주제: {topic_data.get('topic', '')[:60]}\n"
|
||||
f"카테고리: {topic_data.get('corner', '')}\n\n"
|
||||
f"📰 참고 자료:\n{sources_text}\n\n"
|
||||
f"👉 /write {idx}"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user