Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 12 additions & 18 deletions src/core/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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!")
Expand All @@ -198,4 +192,4 @@ def add_announcement(announcement_text: str, username: str) -> None:
"timestamp": current_time,
}

announcements.append(new_addition)
current_announcement = new_addition
6 changes: 2 additions & 4 deletions tests/src/core/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 (
Expand Down
Loading