From f6990bcc811509e4bfef1f836dc5b58d64a34fb8 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 24 Oct 2025 23:11:01 -0400 Subject: [PATCH] Make sure temp files get cleaned up. --- bot.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bot.sh b/bot.sh index bc7dcf7..0051538 100755 --- a/bot.sh +++ b/bot.sh @@ -51,6 +51,11 @@ if [[ ${#missingCore[@]} -gt 0 ]]; then exit 1 fi +# Clean up any leftover temporary files from previous runs +cleanup_old_tempfiles() { + find . -maxdepth 1 -type f -name '.[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]' -mmin +5 -delete 2>/dev/null +} + # Function called on exit to remove the temporary input file. rm_input() { if [[ -f "$input" ]]; then @@ -86,6 +91,9 @@ trap rm_input EXIT # Reconnection loop - keeps bot connected even if connection drops reconnectDelay=10 while true; do + # Clean up old temp files from previous runs + cleanup_old_tempfiles + # Set up the connection. echo -e "Session started $(date "+%I:%M%p%n %A, %B %d, %Y").\n\nTo gracefully exit, make sure you are in the allow list and send the command exit to the bot.\n\n" | tee -a "$log" echo "NICK $nick" > "$input"