fix: /idea 타임아웃 — 리다이렉트/크롤링 제거하고 RSS만 파싱
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -742,14 +742,25 @@ async def cmd_idea(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
await update.message.reply_text("❌ 키워드를 입력하세요.")
|
await update.message.reply_text("❌ 키워드를 입력하세요.")
|
||||||
return
|
return
|
||||||
|
|
||||||
await update.message.reply_text(f"🔎 관련 자료 검색 중...\n키워드: {keyword}")
|
# 네트워크 없이 즉시 topic_data 생성
|
||||||
|
if not corner:
|
||||||
|
corner = _guess_corner(keyword, keyword)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
topic_data = {
|
||||||
try:
|
'topic': keyword,
|
||||||
topic_data = await loop.run_in_executor(None, _search_and_build_topic, keyword, corner)
|
'description': f"{keyword}에 대한 최신 정보와 분석",
|
||||||
except Exception as e:
|
'source': 'idea',
|
||||||
await update.message.reply_text(f"❌ 검색 실패: {e}")
|
'source_name': '직접 입력',
|
||||||
return
|
'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 폴더에 저장
|
||||||
topics_dir = DATA_DIR / 'topics'
|
topics_dir = DATA_DIR / 'topics'
|
||||||
@@ -764,21 +775,11 @@ 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 = []
|
|
||||||
for s in sources[:3]:
|
|
||||||
source_lines.append(f" • {s.get('title', '')[:40]}")
|
|
||||||
|
|
||||||
sources_text = '\n'.join(source_lines) if source_lines else " (직접 검색 결과 없음 — AI가 자체 지식으로 작성)"
|
|
||||||
|
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
f"✅ 글감 등록 완료! (#{idx})\n\n"
|
f"✅ 글감 등록! (#{idx})\n"
|
||||||
f"주제: {topic_data.get('topic', '')}\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} 로 바로 글 작성\n"
|
|
||||||
f"👉 /write {idx} AI인사이트 로 카테고리 변경 가능"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user