Skip to content
3 changes: 3 additions & 0 deletions capy_discord/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ class Settings(EnvConfig):
# Ticket System Configuration
ticket_feedback_channel_id: int = 0

# Event System Configuration

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new announcement_channel_name configuration setting is not documented in the example.env file. All other configuration settings in config.py have corresponding entries in example.env for documentation purposes. Users won't know this configuration option exists or how to override the default "test-announcements" value. Add an entry like ANNOUNCEMENT_CHANNEL_NAME= to example.env.

Suggested change
# Event System Configuration
# Event System Configuration
# Environment variable: ANNOUNCEMENT_CHANNEL_NAME

Copilot uses AI. Check for mistakes.
announcement_channel_name: str = "test-announcements"

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value "test-announcements" for the announcement channel name is a test/development value that has been hardcoded in production configuration. This should either use a more production-appropriate default (like "announcements" or "events") or not have a default value at all (requiring explicit configuration). The "test-" prefix suggests this is temporary configuration that shouldn't be in the main codebase.

Suggested change
announcement_channel_name: str = "test-announcements"
announcement_channel_name: str = "announcements"

Copilot uses AI. Check for mistakes.


settings = Settings()
1 change: 1 addition & 0 deletions capy_discord/exts/event/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Event management module."""
46 changes: 46 additions & 0 deletions capy_discord/exts/event/_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from datetime import date, datetime, time

from pydantic import BaseModel, Field, field_validator


class EventSchema(BaseModel):
"""Pydantic model defining the Event schema and validation rules."""

event_name: str = Field(title="Event Name", description="Name of the event", max_length=100)
event_date: date = Field(
title="Event Date",
description="Date of the event (MM-DD-YYYY)",
default_factory=date.today,
)
event_time: time = Field(
title="Event Time",
description="Time of the event (HH:MM, 24-hour) or (HH:MM AM/PM)",
default_factory=lambda: datetime.now().astimezone().time(),
)
location: str = Field(title="Location", description="Location of the event", max_length=200, default="")
description: str = Field(
title="Description", description="Detailed description of the event", max_length=1000, default=""
)

@field_validator("event_date", mode="before")
@classmethod
def _parse_event_date(cls, value: object) -> date | object:
if isinstance(value, str):
value = value.strip()
return datetime.strptime(f"{value} +0000", "%m-%d-%Y %z").date()
return value

@field_validator("event_time", mode="before")
@classmethod
def _parse_event_time(cls, value: object) -> time | object:
if isinstance(value, str):
value = value.strip()
if " " in value:
# Handle 00:XX AM/PM by converting to 12:XX AM/PM
if value.lower().startswith("00:"):

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time parsing logic has a potential issue with "00:XX AM/PM" format. Converting "00:" to "12:" is correct for midnight (00:00 AM = 12:00 AM), but "00:00 PM" doesn't exist in standard 12-hour format. Consider adding validation to reject invalid combinations like "00:XX PM" to prevent user confusion.

Suggested change
if value.lower().startswith("00:"):
lower_value = value.lower()
if lower_value.startswith("00:"):
# 00:XX PM is not a valid 12-hour time; reject to avoid confusion
if "pm" in lower_value:
raise ValueError("Invalid time format: '00:XX PM' is not a valid 12-hour time.")

Copilot uses AI. Check for mistakes.
value = "12:" + value[3:]
parsed = datetime.strptime(f"{value} +0000", "%I:%M %p %z")
else:
parsed = datetime.strptime(f"{value} +0000", "%H:%M %z")
return parsed.timetz().replace(tzinfo=None)
return value
Loading