Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ def fmt_deadline(value: Optional[Union[datetime, str]]) -> str:


def _lecture_datetime_str(lecture: Dict[str, Any]) -> str:
d = fmt_date(lecture.get("lecture_date"))
t = fmt_time(lecture.get("lecture_time"))
return f"{d} {t}".strip()
return fmt_date(lecture.get("lecture_date"))


def _make_progress_bar(enrolled: int, capacity: int, width: int = 10) -> str:
Expand All @@ -112,45 +110,46 @@ def _build_base_embed(
color=EMBED_COLOR,
timestamp=datetime.now(timezone.utc),
)
embed.add_field(name="📌 강연 제목", value=f"**{lecture['title']}**", inline=False)
embed.add_field(name="강연 제목", value=f"**{lecture['title']}**", inline=False)
embed.add_field(
name="🎯 대상자", value=lecture.get("target") or "전체", inline=True
name="연사자", value=lecture.get("creator_name") or "미정", inline=True
)
embed.add_field(name="대상자", value=lecture.get("target") or "전체", inline=True)
embed.add_field(
name="📍 장소", value=lecture.get("lecture_location") or "미정", inline=True
name="장소", value=lecture.get("lecture_location") or "미정", inline=True
)

embed.add_field(name="강연 일시", value=_lecture_datetime_str(lecture), inline=True)
embed.add_field(
name="📅 강연 일시", value=_lecture_datetime_str(lecture), inline=True
)
embed.add_field(
name="⏰ 신청 마감",
name="신청 마감",
value=fmt_deadline(lecture.get("application_deadline")),
inline=True,
)
return embed


def make_new_lecture_embed(lecture: Dict[str, Any]) -> discord.Embed:
embed = _build_base_embed("✨ 새 릴레이 스터디가 등록됐어요!", lecture)
embed = _build_base_embed("✨새 릴레이 스터디가 등록됐어요!", lecture)
if lecture.get("lecture_url"):
embed.add_field(
name="🔗 신청 링크",
value=f"[👉 강연 신청하러 가기]({lecture['lecture_url']})",
name="신청 링크",
value=f"👉[강연 신청하러 가기]({lecture['lecture_url']})",
inline=False,
)
embed.set_footer(text=FOOTER_TEXT)
return embed


def make_confirmed_embed(lecture: Dict[str, Any], enrolled_count: int) -> discord.Embed:
desc = f"🎉 **{lecture['title']}** 강연이 {CONFIRMED_MIN}명 이상 모여 개설 확정됐습니다!"
embed = _build_base_embed("🔥 릴레이 스터디 개설 확정!", lecture, description=desc)
embed.add_field(name="👥 현재 인원", value=f"**{enrolled_count}명**", inline=True)
desc = (
f"**{lecture['title']}** 강연이 {CONFIRMED_MIN}명 이상 모여 개설 확정됐습니다!"
)
embed = _build_base_embed("릴레이 스터디 개설 확정!", lecture, description=desc)
embed.add_field(name="현재 인원", value=f"**{enrolled_count}명**", inline=True)
if lecture.get("lecture_url"):
embed.add_field(
name="🔗 신청 링크",
value=f"[👉 강연 신청하러 가기]({lecture['lecture_url']})",
name="신청 링크",
value=f"[강연 신청하러 가기]({lecture['lecture_url']})",
inline=False,
)
embed.set_footer(text=FOOTER_TEXT)
Expand Down Expand Up @@ -262,7 +261,7 @@ async def cmd_rels(ctx: commands.Context) -> None:
display_lectures = lectures[:25]

embed = discord.Embed(
title="📋 신청 가능한 강연 목록",
title="신청 가능한 강연 목록",
color=EMBED_COLOR,
timestamp=datetime.now(timezone.utc),
)
Expand All @@ -273,14 +272,12 @@ async def cmd_rels(ctx: commands.Context) -> None:

lines = []
if is_confirmed:
lines.append("✅ **개설 확정**")
lines.append(f"📅 **일시:** {_lecture_datetime_str(lecture)}")
lines.append(
f"⏰ **마감:** {fmt_deadline(lecture.get('application_deadline'))}"
)
lines.append(f"🎯 **대상:** {target}")
lines.append("**개설 확정**")
lines.append(f"일시: {_lecture_datetime_str(lecture)}")
lines.append(f"마감: {fmt_deadline(lecture.get('application_deadline'))}")
lines.append(f"대상: {target}")
if lecture.get("lecture_url"):
lines.append(f"🔗 [신청하기]({lecture['lecture_url']})")
lines.append(f"[신청하기]({lecture['lecture_url']})")

embed.add_field(
name=f"{lecture['title']}",
Expand Down Expand Up @@ -309,7 +306,7 @@ async def cmd_headcount(ctx: commands.Context) -> None:
return

embed = discord.Embed(
title="📊 릴레이 스터디 인원 현황",
title="릴레이 스터디 인원 현황",
color=EMBED_COLOR,
timestamp=datetime.now(timezone.utc),
)
Expand All @@ -323,9 +320,9 @@ async def cmd_headcount(ctx: commands.Context) -> None:

bar = _make_progress_bar(enrolled_count, capacity)
status_tag = (
"개설 확정"
"개설 확정"
if enrolled_count >= CONFIRMED_MIN
else f"{CONFIRMED_MIN - enrolled_count}명 더 모이면 확정"
else f"{CONFIRMED_MIN - enrolled_count}명 더 모이면 확정"
)

value = f"`{bar}` **{enrolled_count}/{capacity}명** | {status_tag}"
Expand All @@ -340,7 +337,7 @@ async def cmd_headcount(ctx: commands.Context) -> None:

@bot.command(name="도움말")
async def cmd_help(ctx: commands.Context) -> None:
embed = discord.Embed(title="💡 릴스 봇 명령어 목록", color=EMBED_COLOR)
embed = discord.Embed(title="릴스 봇 명령어 목록", color=EMBED_COLOR)
embed.add_field(name="!릴스", value="현재 신청 가능한 강연 목록 보기", inline=False)
embed.add_field(name="!인원", value="강연별 신청 인원 현황 보기", inline=False)
embed.add_field(name="!도움말", value="명령어 안내", inline=False)
Expand Down
Loading