3 Commits

3 changed files with 8 additions and 33 deletions

1
.gitignore vendored
View File

@@ -30,6 +30,7 @@ env/
.config/
config*.yaml
!config.yaml.example
.archive/
# Logs
*.log

24
bot.sh
View File

@@ -1,24 +0,0 @@
#!/bin/bash
# Check if any arguments were provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <config.yaml> [additional configs...]"
exit 1
fi
while true; do
# Remove any existing restart flags before starting
rm -f .restart_flag_*
python main.py "$@"
# Check for any restart flags
if ls .restart_flag_* 1> /dev/null 2>&1; then
echo "Restart flag(s) found, restarting bot(s)..."
sleep 1
continue
else
echo "Bot(s) exited without restart flag, stopping..."
break
fi
done

16
main.py
View File

@@ -492,8 +492,6 @@ class IcecastBot:
first_line = handler.__doc__.strip().split('\n')[0]
# Format it using the template and add (admin only) if needed
desc = first_line.split(':', 1)[1].strip()
if pattern in self.admin_commands:
desc = f"{desc} (admin only)"
help_text = self.help_specific_format.format(
prefix=self.cmd_prefix,
cmd=pattern,
@@ -559,7 +557,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('restart'))
@self.admin_required
async def restart_bot(message):
"""!restart: Restart the bot (admin only)
"""!restart: Restart the bot
Gracefully shuts down the bot and signals the bot.sh script
to restart it. This ensures a clean restart.
@@ -581,7 +579,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('quit'))
@self.admin_required
async def quit_bot(message):
"""!quit: Shutdown the bot (admin only)
"""!quit: Shutdown the bot
Gracefully shuts down the bot and exits without restarting.
@@ -600,7 +598,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('reconnect'))
@self.admin_required
async def reconnect_stream(message):
"""!reconnect: Reconnect to the stream (admin only)
"""!reconnect: Reconnect to the stream
Attempts to reconnect to the stream and verifies the connection.
Reports success or failure back to the channel.
@@ -616,7 +614,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('stop'))
@self.admin_required
async def stop_monitoring(message):
"""!stop: Stop stream monitoring (admin only)
"""!stop: Stop stream monitoring
Stops monitoring the stream for metadata changes.
The bot remains connected to IRC.
@@ -632,7 +630,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('start'))
@self.admin_required
async def start_monitoring(message):
"""!start: Start stream monitoring (admin only)
"""!start: Start stream monitoring
Starts monitoring the stream for metadata changes.
Will announce new songs in the channel.
@@ -648,7 +646,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('quiet'))
@self.admin_required
async def quiet_bot(message):
"""!quiet: Disable song announcements (admin only)
"""!quiet: Disable song announcements
Continues monitoring the stream for metadata changes,
but stops announcing songs in the channel.
@@ -665,7 +663,7 @@ class IcecastBot:
@self.bot.on_message(create_command_pattern('unquiet'))
@self.admin_required
async def unquiet_bot(message):
"""!unquiet: Enable song announcements (admin only)
"""!unquiet: Enable song announcements
Resumes announcing songs in the channel.
The bot must already be monitoring the stream.