From d1db387d1c183e8add42b03962756c2f78031575 Mon Sep 17 00:00:00 2001 From: IFM Telegram Bot Date: Mon, 23 Feb 2026 11:22:11 +0700 Subject: [PATCH] chore: update .gitignore and untrack bot.pid, update bot.sh Co-Authored-By: Claude Opus 4.6 --- .gitignore | 1 + bot.pid | 1 - bot.sh | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) delete mode 100644 bot.pid diff --git a/.gitignore b/.gitignore index 5042d53..1549f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ target/ *.class *.jar *.log +*.pid .env data/ downloads/ diff --git a/bot.pid b/bot.pid deleted file mode 100644 index 5ee7533..0000000 --- a/bot.pid +++ /dev/null @@ -1 +0,0 @@ -3367690 diff --git a/bot.sh b/bot.sh index 06ec6a3..0633849 100755 --- a/bot.sh +++ b/bot.sh @@ -46,9 +46,24 @@ do_start() { # Kill any stale tmux session tmux kill-session -t "$TMUX_SESSION" 2>/dev/null + # Build env string from .env for tmux (since tmux doesn't inherit exports) + local ENV_EXPORTS="" + if [ -f "$BOT_DIR/.env" ]; then + while IFS='=' read -r key value; do + # Skip comments and empty lines + [[ "$key" =~ ^#.*$ || -z "$key" ]] && continue + # Remove surrounding quotes from value + value="${value%\"}" + value="${value#\"}" + value="${value%\'}" + value="${value#\'}" + ENV_EXPORTS+="export ${key}='${value}'; " + done < "$BOT_DIR/.env" + fi + # Start bot inside a detached tmux session (UTF-8 for Thai text) tmux new-session -d -s "$TMUX_SESSION" \ - "cd '$BOT_DIR' && LANG=C.UTF-8 LC_ALL=C.UTF-8 exec java -Dfile.encoding=UTF-8 -jar '$JAR_FILE' >> '$LOG_DIR/console.log' 2>&1" + "cd '$BOT_DIR' && ${ENV_EXPORTS}LANG=C.UTF-8 LC_ALL=C.UTF-8 exec java -Dfile.encoding=UTF-8 -jar '$JAR_FILE' >> '$LOG_DIR/console.log' 2>&1" sleep 3