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
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CALENDAR_EVENT_MAXIMUM=
CALENDAR_CACHE_REFRESH=
CALENDAR_TIMEZONE=

SLACK_MEETINGS_KEYWORD=""
SLACK_NONTECHNICAL_SEMINAR_KEYWORD=""
SLACK_TECHNICAL_SEMINAR_KEYWORD=""

SLACK_ALLOW_ANNOUNCEMENTS=false
SLACK_ANNOUNCEMENT_CHANNEL=
SLACK_ACTIVE_GROUP_ID=
Expand Down
4 changes: 4 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ 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_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")

SLACK_ALLOW_ANNOUNCEMENTS: bool = (
_get_env_variable("SLACK_ALLOW_ANNOUNCEMENTS", "false") == "true"
)
Expand Down
37 changes: 17 additions & 20 deletions src/core/announcement_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
SLACK_ACTIVE_GROUP_ID,
SLACK_FROSH_GROUP_ID,
SLACK_MEETINGS_GROUP_ID,
SLACK_TEST_GROUP_ID,
SLACK_ALLOW_ANNOUNCEMENTS,

SLACK_TECHNICAL_SEMINAR_KEYWORD,
SLACK_NONTECHNICAL_SEMINAR_KEYWORD,
SLACK_MEETINGS_KEYWORD
)

logger: Logger = getLogger(__name__)
Expand All @@ -25,11 +30,6 @@
queued_announcement_id_cache: dict[str, asyncio.Task] = {}

TEN_MINUTES = 60 * 10
TECHNICAL_SEMINAR_KEYWORD: str = "technical"
STANDARD_SEMINAR_KEYWORD: str = "seminar"
MEETING_KEYWORD: str = "meeting"
TEST_KEYWORD: str = "test_gick"

MINUTES_BEFORE_EVENT_PING = 15


Expand Down Expand Up @@ -133,7 +133,7 @@ def check_for_announcement(event: dict[str, Any], time: datetime) -> None:
loc = event.get("LOCATION", None)

description = description.lower().strip()
if TECHNICAL_SEMINAR_KEYWORD.lower() in description:
if SLACK_NONTECHNICAL_SEMINAR_KEYWORD.lower() in description:
if loc:
queue_announcement(
uid,
Expand All @@ -148,7 +148,7 @@ def check_for_announcement(event: dict[str, Any], time: datetime) -> None:
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 STANDARD_SEMINAR_KEYWORD.lower() in description:
elif SLACK_TECHNICAL_SEMINAR_KEYWORD.lower() in description:
if loc:
queue_announcement(
uid,
Expand All @@ -163,7 +163,7 @@ def check_for_announcement(event: dict[str, Any], time: datetime) -> None:
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 MEETING_KEYWORD.lower() in description:
elif SLACK_MEETINGS_KEYWORD.lower() in description:
if loc:
queue_announcement(
uid,
Expand All @@ -178,18 +178,15 @@ def check_for_announcement(event: dict[str, Any], time: datetime) -> None:
f"<!subteam^{SLACK_MEETINGS_GROUP_ID}> The {title} directorship will be happening in {MINUTES_BEFORE_EVENT_PING} minutes!",
time,
)


# elif TEST_KEYWORD.lower() in description:
# if loc:
# queue_announcement(
# uid, rec_id, f"<!subteam^{SLACK_TEST_GROUP_ID}> testing in the {loc}!", time
# )
# else:
# queue_announcement(
# uid, rec_id, f"<!subteam^{SLACK_TEST_GROUP_ID}> testing!", time
# )
# )
elif "gick" in description:
if loc:
queue_announcement(
uid, rec_id, f"<!subteam^{SLACK_TEST_GROUP_ID}> gick go to the {loc}!", time
)
else:
queue_announcement(
uid, rec_id, f"<!subteam^{SLACK_TEST_GROUP_ID}> hi gick!", time
)

# if TECHNICAL_SEMINAR_KEYWORD.lower() in description:
# taskmanager.create_background_task(create_announcement_worker(
Expand Down
Loading