dont add announcement job if one exists

This commit is contained in:
deflax 2024-01-17 05:13:57 +02:00
parent 751edc5903
commit 41e2e5f77c

View file

@ -77,10 +77,14 @@ async def update_database():
stream_name = value['name']
stream_start_at = value['start_at']
if stream_start_at == 'now':
logger_discord.info(f'{stream_name} live stream detected!')
scheduler.add_job(func=announce_live_channel, trigger='interval', seconds=60, id='announce_live_channel', args=(stream_name,))
return
try:
job = scheduler.get_job('announce_live_channel')
if not job:
logger_discord.info(f'{stream_name} live stream detected!')
scheduler.add_job(func=announce_live_channel, trigger='interval', seconds=60, id='announce_live_channel', args=(stream_name,))
return
except JobLookupError:
pass
try:
job = scheduler.get_job('announce_live_channel')
if job:
@ -88,10 +92,8 @@ async def update_database():
live_channel = bot.get_channel(announce_channel_id)
logger_discord.info(f'{stream_name} finished')
await live_channel.send(f'{stream_name} finished')
else:
return
except JobLookupError:
return
pass
async def announce_live_channel(stream_name):
if announce_channel_id == 'disabled':