Skip to content
Open
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
25 changes: 21 additions & 4 deletions src/europython_discord/programme_notifications/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,30 @@ async def on_ready(self) -> None:
await self.purge_all_room_channels()
_logger.debug(f"Simulated start time: {self.config.simulated_start_time}")
_logger.debug(f"Fast mode: {self.config.fast_mode}")
_logger.info("Posting livestream URLs for all rooms...")
await self.post_all_livestream_urls()
_logger.info("Starting the session notifier...")
self.notify_sessions.start()
_logger.info("Cog 'Programme Notifications' is ready")

async def post_all_livestream_urls(self) -> None:
if self.livestream_connector.livestreams_by_room is None:
await self.livestream_connector.fetch_livestreams()

for room_name in self.config.rooms_to_channel_names:
room_channel = self._get_room_channel(room_name)
if room_channel is None:
continue

urls_by_date = self.livestream_connector.livestreams_by_room.get(room_name)
if not urls_by_date:
continue

topic = "\n".join(
f"Stream {day.strftime('%A')}: {url}" for day, url in sorted(urls_by_date.items())
)
await room_channel.edit(topic=topic)

async def cog_load(self) -> None:
"""Start schedule updater task."""
_logger.info(
Expand Down Expand Up @@ -105,11 +125,8 @@ async def notify_sessions(self) -> None:
# send session notification message to room and main channel
await main_notification_channel.send(embed=embed)

# update room's livestream URL
# send session notification message to room
if room_channel is not None:
await room_channel.edit(
topic=f"Livestream: [YouTube]({livestream_url})" if livestream_url else ""
)
await room_channel.send(
content=f"# Starting in 5 minutes @ {session.rooms[0]}",
embed=embed,
Expand Down