fix: /collect, /topics 전체 글감 표시 (15개 제한 제거)

텔레그램 4096자 제한 고려하여 30개씩 페이지 나눠 전송

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JOUNGWOOK KWON
2026-03-30 12:11:24 +09:00
parent e3c963a014
commit 01f95dbc6b

View File

@@ -620,15 +620,24 @@ async def cmd_collect(update: Update, context: ContextTypes.DEFAULT_TYPE):
if not files:
await update.message.reply_text("✅ 수집 완료! 오늘 수집된 글감이 없습니다.")
return
lines = [f"✅ 수집 완료! 오늘 글감 {len(files)}개:"]
for i, f in enumerate(files[:15], 1):
try:
data = json.loads(f.read_text(encoding='utf-8'))
lines.append(f" {i}. [{data.get('corner','')}] {data.get('topic','')[:50]}")
except Exception:
pass
lines.append("\n✍️ /write [번호] 로 글 작성")
await update.message.reply_text('\n'.join(lines))
# 텔레그램 메시지 4096자 제한 고려, 페이지 나눠 전송
total = len(files)
page_size = 30
for page_start in range(0, total, page_size):
page_files = files[page_start:page_start + page_size]
if page_start == 0:
lines = [f"✅ 수집 완료! 오늘 글감 {total}개:"]
else:
lines = [f"📋 계속 ({page_start + 1}~{page_start + len(page_files)}):"]
for i, f in enumerate(page_files, page_start + 1):
try:
data = json.loads(f.read_text(encoding='utf-8'))
lines.append(f" {i}. [{data.get('corner','')}] {data.get('topic','')[:40]}")
except Exception:
pass
if page_start + page_size >= total:
lines.append(f"\n✍️ /write [번호] 로 글 작성 (1~{total})")
await update.message.reply_text('\n'.join(lines))
except Exception as e:
await update.message.reply_text(f"❌ 수집 오류: {e}")
@@ -686,15 +695,23 @@ async def cmd_show_topics(update: Update, context: ContextTypes.DEFAULT_TYPE):
if not files:
await update.message.reply_text("오늘 수집된 글감이 없습니다.")
return
lines = [f"📋 오늘 수집된 글감 ({len(files)}개):"]
for i, f in enumerate(files[:15], 1):
try:
data = json.loads(f.read_text(encoding='utf-8'))
lines.append(f" {i}. [{data.get('quality_score',0)}점][{data.get('corner','')}] {data.get('topic','')[:50]}")
except Exception:
pass
lines.append("\n✍️ /write [번호] 로 글 작성")
await update.message.reply_text('\n'.join(lines))
total = len(files)
page_size = 30
for page_start in range(0, total, page_size):
page_files = files[page_start:page_start + page_size]
if page_start == 0:
lines = [f"📋 오늘 수집된 글감 ({total}개):"]
else:
lines = [f"📋 계속 ({page_start + 1}~{page_start + len(page_files)}):"]
for i, f in enumerate(page_files, page_start + 1):
try:
data = json.loads(f.read_text(encoding='utf-8'))
lines.append(f" {i}. [{data.get('quality_score',0)}점][{data.get('corner','')}] {data.get('topic','')[:40]}")
except Exception:
pass
if page_start + page_size >= total:
lines.append(f"\n✍️ /write [번호] 로 글 작성 (1~{total})")
await update.message.reply_text('\n'.join(lines))
async def cmd_pending(update: Update, context: ContextTypes.DEFAULT_TYPE):