Skip to content

Commit

Permalink
cleanup, restrict to proper channels
Browse files Browse the repository at this point in the history
  • Loading branch information
wizzdom committed Nov 23, 2024
1 parent 35d0e65 commit e5d273e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/extensions/agenda.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ def generate_time_choices():


@agenda.include
@arc.with_hook(restrict_to_channels(channel_ids=[CHANNEL_IDS["bots-cmt"]]))
@arc.with_hook(
restrict_to_channels(
channel_ids=[
CHANNEL_IDS[
"bots-cmt", "committee-announcements", "cowboys-and-cowgirls-committee"
]
]
)
)
@arc.with_hook(restrict_to_roles(role_ids=[ROLE_IDS["committee"]]))
@arc.slash_subcommand(
"generate",
Expand Down Expand Up @@ -73,6 +81,8 @@ async def gen_agenda(
TIME = parsed_datetime.strftime("%H:%M")
full_datetime = parsed_datetime.strftime("%A, %Y-%m-%d %H:%M")

ROOM = room

if "https://md.redbrick.dcu.ie" not in url:
await ctx.respond(
f"❌ `{url}` is not a valid MD URL. Please provide a valid URL.",
Expand All @@ -97,7 +107,7 @@ async def gen_agenda(

content = await response.text()

modified_content = content.format(DATE=DATE, TIME=TIME, ROOM=room)
modified_content = content.format(DATE=DATE, TIME=TIME, ROOM=ROOM)

post_url = f"{parsed_url.scheme}://{parsed_url.hostname}/new"
post_headers = {"Content-Type": "text/markdown"}
Expand All @@ -116,7 +126,7 @@ async def gen_agenda(

new_agenda_url = response.url
announce_text = f"""
## 📣 Agenda for this week's meeting | {full_datetime} | {room} <:bigRed:634311607039819776>
## 📣 Agenda for this week's meeting | {full_datetime} | {ROOM} <:bigRed:634311607039819776>
[{DATE} Agenda](<{new_agenda_url}>)
Expand All @@ -130,7 +140,7 @@ async def gen_agenda(
"""

announce = await plugin.client.rest.create_message(
CHANNEL_IDS["bots-cmt"],
CHANNEL_IDS["committee-announcements"],
mentions_everyone=False,
user_mentions=True,
role_mentions=True,
Expand Down

0 comments on commit e5d273e

Please sign in to comment.