2.8 KiB
2.8 KiB
WhatsApp -> Google Drive batch uploader (Baileys, mcb commands)
Uploads files from WhatsApp chats into structured Google Drive folders using batch commands.
Commands
- User-friendly (case-insensitive):
start,done,cancel,status,help - Also supported fallback:
mcb-*and legacyhi mcb/bye mcb - Batch management:
rename <folder-name>-> change active batch target folderlist-> show queued file names and sizesundo-> remove last queued fileretry-failed-> retry previously failed uploads
- Project/admin:
mcb-project <name>-> set/save a project folderadmin-stats-> today + lifetisw me operational statsadmin-stats 7d-> rolling summary for last N days (example:7d)admin-stats YYYY-MM-DD-> stats for a specific dateadmin-health-> live ops snapshot (heartbeat, queues, alerts)
Local setup (Windows/Linux)
- Install dependencies:
npm install
- Create
.env(example values):
GOOGLE_CREDENTIALS=./credentials.json
GOOGLE_TOKEN=./token.json
DEFAULT_ROOT_FOLDER=Whatsapp-Drive
WA_CLIENT_ID=MCB-bot
BAILEYS_AUTH_DIR=./baileys_auth
OWNER_NUMBER=
BATCH_TTL_MIN=30
IDLE_RESTART_CHECK_MIN=60
IDLE_RESTART_MIN=240
IDLE_RESTART_MAX_PER_DAY=6
DOWNLOAD_TIMEOUT_MS=900000
DOWNLOAD_MAX_RETRIES=2
DOWNLOAD_RETRY_DELAY_MS=5000
MAX_MEDIA_MB=95
WA_PROTOCOL_TIMEOUT=9000000
WA_INIT_RETRIES=3
WA_INIT_RETRY_DELAY_MS=5000
WA_HEADLESS=true
LOG_DIR=./logs
HEARTBEAT_INTERVAL_SEC=60
RETRY_MAX_ITEMS=200
SMART_SUBFOLDERS=true
FAIL_ALERT_WINDOW=10
FAIL_ALERT_THRESHOLD_PCT=20
FAIL_ALERT_COOLDOWN_MIN=30
# Optional on Linux VPS if Chromium is not auto-detected:
# WA_EXECUTABLE_PATH=/usr/bin/chromium-browser
-
Put Google OAuth client JSON at
credentials.json. -
Generate Drive token:
npm run auth
- Start bot:
npm start
Linux VPS notes
- Install Chromium/Chrome and required libraries for Puppeteer.
- If Chromium path is custom, set
WA_EXECUTABLE_PATH. - Use a process manager (for example PM2/systemd) for auto-restart.
Runtime notes
- Temporary files are written under your OS temp directory (
MCB-batches). - Upload target folders are auto-created in Drive.
- Uploaded folder gets read-only public link (
anyonewithreaderrole). - Duplicate protection is enabled per batch (same filename + size is skipped).
- Failed uploads are moved to retry queue and can be retried with
retry-failed. - Structured rotating logs are written to
logs/app-YYYY-MM-DD.jsonl. - Heartbeat logs are emitted periodically for VPS monitoring.
- Uploads are auto-organized into Drive subfolders by date + event type (
Invoices,Photos,Documents). - Active upload sessions are restored from disk after process restart (within batch TTL).
- Owner receives failure alerts when recent upload failures exceed configured threshold.