Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_env_variable(name: str, default: str | None = None) -> str | Any:

BASE_DIR: str = os.path.dirname(os.path.abspath(__file__))

SLACK_MEETINGS_KEYWORD: str = _get_env_variable("SLACK_MEETINGS_KEYWORD", "meetings")
SLACK_MEETINGS_KEYWORD: str = _get_env_variable("SLACK_MEETINGS_KEYWORD", "meeting")
SLACK_NONTECHNICAL_SEMINAR_KEYWORD: str = _get_env_variable("SLACK_NONTECHNICAL_SEMINAR_KEYWORD", "non-technical")
SLACK_TECHNICAL_SEMINAR_KEYWORD: str = _get_env_variable("SLACK_TECHNICAL_SEMINAR_KEYWORD", "technical")

Expand Down
12 changes: 8 additions & 4 deletions src/core/announcement_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
TEN_MINUTES = 60 * 10
MINUTES_BEFORE_EVENT_PING = 15

logger.info(SLACK_MEETINGS_KEYWORD)
logger.info(SLACK_TECHNICAL_SEMINAR_KEYWORD)

async def create_announcement_worker(
event_uid: str, event_recurrence_id: str, text: str, event_time: datetime
Expand All @@ -47,6 +49,7 @@ async def create_announcement_worker(
"""
key: str = f"{event_uid}:{event_recurrence_id}" # we should use redis instead

logger.info(key)
current_time: datetime = datetime.now(ZoneInfo(CALENDAR_TIMEZONE))
if current_time < (event_time - timedelta(minutes=MINUTES_BEFORE_EVENT_PING)):
wait_time = (
Expand Down Expand Up @@ -133,34 +136,35 @@ def check_for_announcement(event: dict[str, Any], time: datetime) -> None:
loc = event.get("LOCATION", None)

description = description.lower().strip()

if SLACK_NONTECHNICAL_SEMINAR_KEYWORD.lower() in description:
if loc:
queue_announcement(
uid,
rec_id,
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Technical Seminar {title} will be happening in the {loc} in {MINUTES_BEFORE_EVENT_PING} minutes!",
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Non-Technical Seminar {title} will be happening in the {loc} in {MINUTES_BEFORE_EVENT_PING} minutes!",
time,
)
else:
queue_announcement(
uid,
rec_id,
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Technical Seminar {title} will be happening in {MINUTES_BEFORE_EVENT_PING} minutes!",
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Non-Technical Seminar {title} will be happening in {MINUTES_BEFORE_EVENT_PING} minutes!",
time,
)
elif SLACK_TECHNICAL_SEMINAR_KEYWORD.lower() in description:
if loc:
queue_announcement(
uid,
rec_id,
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Non-Technical Seminar {title} will be happening in the {loc} in {MINUTES_BEFORE_EVENT_PING} minutes!",
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Technical Seminar {title} will be happening in the {loc} in {MINUTES_BEFORE_EVENT_PING} minutes!",
time,
)
else:
queue_announcement(
uid,
rec_id,
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Non-Technical Seminar {title} will be happening in {MINUTES_BEFORE_EVENT_PING} minutes!",
f"<!subteam^{SLACK_ACTIVE_GROUP_ID}> <!subteam^{SLACK_FROSH_GROUP_ID}> The Technical Seminar {title} will be happening in {MINUTES_BEFORE_EVENT_PING} minutes!",
time,
)
elif SLACK_MEETINGS_KEYWORD.lower() in description:
Expand Down
Loading