diff --git a/README.md b/README.md index c25a954..5491f4f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Bộ công cụ tự động bình luận Twitter/X — gói gọn, chạy 5 ph ## Tiếng Việt — Quick Start ### Yêu cầu -- Node.js 20 trở lên +- Node.js 20 trở lên (nếu lỗi version, hãy cài qua lệnh `nvm install 20`) - Một tài khoản Twitter/X có cookies hợp lệ - (Tùy chọn) Telegram bot để nhận cảnh báo - API key của một trong 3 nhà cung cấp AI: DeepSeek (rẻ), OpenAI, hoặc Anthropic @@ -34,7 +34,35 @@ npm start # chạy ngay # hoặc bot đã được cài auto-start lúc boot Windows nếu bạn chọn Y ở wizard ``` -Logs: `data/run.log`. Xem real-time: `Get-Content data/run.log -Wait` (PowerShell) +### Chạy nền trên Server (Linux/macOS) +Để bot chạy ngầm 24/7 (ngay cả khi tắt terminal) và tự động cài Node.js 20: + +1. **Cài đặt Node.js 20 (NVM):** + ```bash + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 20 && nvm use 20 + ``` +2. **Khởi chạy bot (PM2):** + ```bash + npm install -g pm2 + pm2 start src/index.mjs --name "twitter-bot" + pm2 save + ``` + +Logs: `data/run.log`. Xem real-time: `pm2 logs twitter-bot` (nếu dùng PM2) hoặc `Get-Content data/run.log -Wait` (PowerShell) + +**Các lệnh PM2 hữu ích:** +- Xem log (những gì bot đang in ra): + ```bash + pm2 logs twitter-bot + ``` +- Dừng hoặc khởi động lại bot: + ```bash + pm2 stop twitter-bot + pm2 restart twitter-bot + ``` ### 3 chế độ tóm tắt - **A — List comment**: bot crawl các list bạn chọn, comment vào từng tweet bằng AI theo ngôn ngữ + phong cách bạn cấu hình. @@ -57,7 +85,7 @@ schtasks /Delete /TN TwitterCommentPack_Startup /F ## English — Quick Start ### Requirements -- Node.js 20+ +- Node.js 20+ (if you get errors, install via `nvm install 20`) - Valid Twitter/X account cookies - (Optional) Telegram bot for alerts - API key for one of: DeepSeek (cheap), OpenAI, or Anthropic @@ -73,7 +101,37 @@ npm run setup The wizard asks 4 main questions + AI key. Guides for each are in `guides/`. -Start: `npm start`. Logs: `data/run.log`. +Start on terminal: `npm start`. + +### Run in Background (Linux/macOS) +To run the bot 24/7 (even when the terminal is closed) and easily install Node.js 20: + +1. **Install Node.js 20 (NVM):** + ```bash + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 20 && nvm use 20 + ``` +2. **Start the bot (PM2):** + ```bash + npm install -g pm2 + pm2 start src/index.mjs --name "twitter-bot" + pm2 save + ``` + +Logs: `data/run.log`. Watch real-time: `pm2 logs twitter-bot` (if using PM2) or `tail -f data/run.log`. + +**Useful PM2 commands:** +- View logs (see what the bot is printing): + ```bash + pm2 logs twitter-bot + ``` +- Stop or restart the bot: + ```bash + pm2 stop twitter-bot + pm2 restart twitter-bot + ``` ### 3 modes - **A — List comment**: crawl chosen lists, AI-comment per language and persona.