From 01f95dbc6b0c8d2436ece992fecfdd43f1f5ab34 Mon Sep 17 00:00:00 2001 From: JOUNGWOOK KWON Date: Mon, 30 Mar 2026 12:11:24 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20/collect,=20/topics=20=EC=A0=84=EC=B2=B4?= =?UTF-8?q?=20=EA=B8=80=EA=B0=90=20=ED=91=9C=EC=8B=9C=20(15=EA=B0=9C=20?= =?UTF-8?q?=EC=A0=9C=ED=95=9C=20=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 텔레그램 4096자 제한 고려하여 30개씩 페이지 나눠 전송 Co-Authored-By: Claude Opus 4.6 --- bots/scheduler.py | 53 +++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/bots/scheduler.py b/bots/scheduler.py index 09f9750..24c6154 100644 --- a/bots/scheduler.py +++ b/bots/scheduler.py @@ -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):