Skip to content

Commit

Permalink
[Live] Make live notifs clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
noahkw committed Oct 9, 2023
1 parent 85d9fdb commit 5bb0453
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cogs/Live.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ async def connect_ws(self):


class ChannelUpdater(Subscriber):
def __init__(self, channel: discord.TextChannel):
def __init__(self, channel: discord.TextChannel, live_url: str = ""):
self.channel = channel
# TTL of 15 minutes
self.live_users: TTLCache = TTLCache(maxsize=128, ttl=15 * 60)
self.live_url = live_url

async def notify(self, data: LiveUsers):
newly_live = []
Expand All @@ -196,7 +197,7 @@ async def notify(self, data: LiveUsers):

if len(newly_live) > 0:
await self.channel.send(
f"Now live: {', '.join([new_live_user.userName for new_live_user in newly_live])}"
f"Now live: {', '.join([f'{self.live_url}{new_live_user.userName}' for new_live_user in newly_live])}"
)


Expand All @@ -211,7 +212,8 @@ def __init__(self, bot):
config["sync_stream_ws"], config["sync_stream_token"], self.session
)
self.channel_updater = ChannelUpdater(
bot.get_channel(config["sync_stream_updates_channel"])
bot.get_channel(config["sync_stream_updates_channel"]),
config["live_url"],
)
self.sync_stream_ws.subscribe("getliveusers", self.channel_updater)

Expand Down
1 change: 1 addition & 0 deletions config.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ cogs:
sync_stream_ws: 'XXXXXXXXXXXXXXXXXXXXXX'
sync_stream_token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sync_stream_updates_channel: XXXXXXXXXXXXXXXXX
live_url: 'https://xxxxxxxx/live/'

0 comments on commit 5bb0453

Please sign in to comment.