Make sure temp files get cleaned up.
This commit is contained in:
8
bot.sh
8
bot.sh
@@ -51,6 +51,11 @@ if [[ ${#missingCore[@]} -gt 0 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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.
|
# Function called on exit to remove the temporary input file.
|
||||||
rm_input() {
|
rm_input() {
|
||||||
if [[ -f "$input" ]]; then
|
if [[ -f "$input" ]]; then
|
||||||
@@ -86,6 +91,9 @@ trap rm_input EXIT
|
|||||||
# Reconnection loop - keeps bot connected even if connection drops
|
# Reconnection loop - keeps bot connected even if connection drops
|
||||||
reconnectDelay=10
|
reconnectDelay=10
|
||||||
while true; do
|
while true; do
|
||||||
|
# Clean up old temp files from previous runs
|
||||||
|
cleanup_old_tempfiles
|
||||||
|
|
||||||
# Set up the connection.
|
# 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 -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"
|
echo "NICK $nick" > "$input"
|
||||||
|
|||||||
Reference in New Issue
Block a user