feat: full artifact content in Discord (split into chunks) + full task content display

This commit is contained in:
2026-03-07 14:36:18 +09:00
parent 046c58879c
commit d44b4c2f77

35
bot.py
View File

@@ -272,9 +272,15 @@ class GravityBot(commands.Bot):
):
progress = parse_task_progress(event.content)
# Full task content (truncated to embed limit)
full_content = event.content.strip()
description = format_task_embed_text(progress) + "\n\n" + full_content
if len(description) > 4000:
description = description[:4000] + "\n…(truncated)"
embed = discord.Embed(
title="📋 Task 진행 현황",
description=format_task_embed_text(progress),
description=description,
color=discord.Color.gold() if progress.in_progress > 0
else discord.Color.green() if progress.done == progress.total
else discord.Color.greyple(),
@@ -304,20 +310,37 @@ class GravityBot(commands.Bot):
label = labels.get(event.file_name, f"📄 {event.file_name}")
event_label = "생성" if event.event_type == EventType.FILE_CREATED else "업데이트"
lines = event.content.strip().splitlines()
preview = "\n".join(l for l in lines[:6] if l.strip())
if len(lines) > 6:
preview += f"\n... (+{len(lines) - 6} lines)"
full_content = event.content.strip()
CHUNK_SIZE = 4000 # Discord embed desc limit is 4096
# Split into chunks for long content
chunks = []
while full_content:
chunks.append(full_content[:CHUNK_SIZE])
full_content = full_content[CHUNK_SIZE:]
if not chunks:
chunks = ["(빈 파일)"]
# First chunk with title
embed = discord.Embed(
title=f"{label} ({event_label}됨)",
description=preview[:1000],
description=chunks[0],
color=discord.Color.blue(),
timestamp=datetime.now(timezone.utc),
)
embed.set_footer(text=f"Session: {event.conversation_id[:8]}")
await channel.send(embed=embed)
# Additional chunks if content is long
for i, chunk in enumerate(chunks[1:], 2):
embed = discord.Embed(
title=f"{label} (계속 {i}/{len(chunks)})",
description=chunk,
color=discord.Color.blue(),
)
await channel.send(embed=embed)
# ─── Approval Scanner ────────────────────────────────────────────
@tasks.loop(seconds=3)