diff --git a/src/core/slack.py b/src/core/slack.py index 9ad121e..1b410b3 100644 --- a/src/core/slack.py +++ b/src/core/slack.py @@ -27,15 +27,14 @@ except Exception as e: logger.error(f"Failed to initialize Slack client: {e}") -announcements: list[dict[str, str]] = [ - { - "content": "Welcome to Jumpstart!", - "user": "Jumpstart", - "timestamp": datetime.now(ZoneInfo(CALENDAR_TIMEZONE)) - .strftime("%I:%M %p") - .lstrip("0"), - } -] +current_announcement: dict[str, str] = { + "content": "Welcome to Jumpstart!", + "user": "Jumpstart", + "timestamp": datetime.now(ZoneInfo(CALENDAR_TIMEZONE)) + .strftime("%I:%M %p") + .lstrip("0") +} + def clean_text(raw: str) -> str: @@ -164,16 +163,10 @@ def get_announcement() -> dict[str, str] | None: Returns the next announcement in the queue. Returns: - dict | None: The next announcement text and user, or None if there are no announcements. + dict[str,str]: The next announcement text and user, or None if there are no announcements. """ - if len(announcements) == 0: - return None - - if len(announcements) == 1: - return announcements[0] - - return announcements.pop(0) + return current_announcement def add_announcement(announcement_text: str, username: str) -> None: @@ -184,6 +177,7 @@ def add_announcement(announcement_text: str, username: str) -> None: announcement_text (str): The text of the announcement to be added. user_id (str): The user_id of the person """ + global current_announcement if announcement_text is None or announcement_text.strip() == "": logger.warning("Attempted to add empty announcement, skipping!") @@ -198,4 +192,4 @@ def add_announcement(announcement_text: str, username: str) -> None: "timestamp": current_time, } - announcements.append(new_addition) + current_announcement = new_addition diff --git a/tests/src/core/test_slack.py b/tests/src/core/test_slack.py index b1a143e..ea952a4 100644 --- a/tests/src/core/test_slack.py +++ b/tests/src/core/test_slack.py @@ -135,8 +135,8 @@ def test_get_and_add_announcement(monkeypatch): slack = import_slack_module(monkeypatch) - slack.announcements.clear() - assert slack.get_announcement() is None + slack.current_announcement = None + assert slack.current_announcement is None skip_announcements: list[str | None] = [None, "", " "] for ann in skip_announcements: @@ -148,8 +148,6 @@ def test_get_and_add_announcement(monkeypatch): for ann in test_announcements: slack.add_announcement(ann, "FAKE ID") - - for ann in test_announcements: assert slack.get_announcement().get("content", "") == ann assert (