check if live_channel_id fallback is 0

This commit is contained in:
deflax 2024-01-17 06:01:38 +02:00
parent 0aa810fd9e
commit 2ea654f344
2 changed files with 9 additions and 10 deletions

View file

@ -10,7 +10,7 @@ import logging
# Read env variables
bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token')
announce_channel_id = os.environ.get('DISCORDBOT_LIVE_CHANNEL_ID', 'disabled')
live_channel_id = os.environ.get('DISCORDBOT_LIVE_CHANNEL_ID', 0)
scheduler_hostname = os.environ.get('SCHEDULER_API_HOSTNAME', 'tv.example.com')
# Discord API Intents
@ -104,17 +104,16 @@ async def update_database():
# Cleanup the announce job
if scheduler.get_job('announce_live_channel') is not None:
scheduler.remove_job('announce_live_channel')
#live_channel = bot.get_channel(announce_channel_id)
logger_discord.info(f'Live stream is offline.')
#await live_channel.send('Live stream is offline.')
if live_channel_id != 0:
update_channel = bot.get_channel(live_channel_id)
await update_channel.send('Live stream is offline.')
async def announce_live_channel(stream_name):
if announce_channel_id == 'disabled':
return
else:
#live_channel = bot.get_channel(announce_channel_id)
logger_discord.info(f'{stream_name} is live!')
#await live_channel.send(f'{stream_name} is live!')
if live_channel_id != 0:
live_channel = bot.get_channel(live_channel_id)
await live_channel.send(f'{stream_name} is live!')
# Run the bot with your token
asyncio.run(bot.run(bot_token))

View file

@ -7,4 +7,4 @@ CORE_API_AUTH_PASSWORD=changeme
SCHEDULER_LOG_LEVEL=warn
SCHEDULER_API_HOSTNAME=tv.example.com
DISCORDBOT_TOKEN=changeme
DISCORDBOT_LIVE_CHANNEL_ID=disabled
DISCORDBOT_LIVE_CHANNEL_ID=0