Compare commits
2 Commits
ead52a835a
...
fb0d060018
| Author | SHA1 | Date | |
|---|---|---|---|
| fb0d060018 | |||
| 39a9e67c24 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -3,8 +3,6 @@ node_modules/
|
|||||||
.wwebjs_auth/
|
.wwebjs_auth/
|
||||||
.wwebjs_cache/
|
.wwebjs_cache/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
app.log
|
app.log
|
||||||
@ -16,8 +14,6 @@ yarn-error.log*
|
|||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# OS files
|
# OS files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
@ -37,3 +33,6 @@ build/
|
|||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
*.bak
|
*.bak
|
||||||
|
|
||||||
|
credentials.json
|
||||||
|
token.json
|
||||||
50
BAK/state.json
Normal file
50
BAK/state.json
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"users": {
|
||||||
|
"15192773600@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "2 tier chocolate vegan Star Wars cake",
|
||||||
|
"lastBatchFolderId": "1oJufpdl2yuyZTOEejVv22rKMEf7o6LAV"
|
||||||
|
},
|
||||||
|
"14374329515@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "social currency",
|
||||||
|
"lastBatchFolderId": "1iUdfbHOCg3Cambad7DhmDla9wCBPtk_0"
|
||||||
|
},
|
||||||
|
"918220348218@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "mohan",
|
||||||
|
"lastBatchFolderId": "1MxGKRFjb60x2pcCySc6DBTC_c2qXzG0L"
|
||||||
|
},
|
||||||
|
"16476796537@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "Manesh",
|
||||||
|
"lastBatchFolderId": "1VylDIP7pvKtNa2WV-lAK6f6gNaU9pZ0V"
|
||||||
|
},
|
||||||
|
"919585967575@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "Vijay testing",
|
||||||
|
"lastBatchFolderId": "12zRnuoeIhudGLbKckMciYLDxd7zLJpVA"
|
||||||
|
},
|
||||||
|
"16476229848@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "Clickstogarlands",
|
||||||
|
"lastBatchFolderId": "1fs-6-2FA6RkioHR2Ybo7Q1xGp6ftCU7B"
|
||||||
|
},
|
||||||
|
"15198976975@c.us": {
|
||||||
|
"projectName": null,
|
||||||
|
"folderId": null,
|
||||||
|
"lastBatchFolderName": "TCA _sportsday",
|
||||||
|
"lastBatchFolderId": "1JVzN_9KHMIm0jDQZL0UthM_jCJDkV8Dz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"restartStats": {
|
||||||
|
"date": "2026-04-17",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
7
BAK/token_mohan.json
Normal file
7
BAK/token_mohan.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"access_token": "ya29.a0Aa7MYiqoT1k7-HDBeAYAzTWBp-kS3WvVmeXjdmRmCb6xWxLbT5EVSxCFQCqJJh8_oFxsgNyNqicpy-hBALL3qdTZfeCIMrLiNevV8cTKHgnf4aPfAH0uLRJzybRtp_8Ug62mSrhTopZ3-atQwtJSFsFMbv-xIm5VneLzXswLUrk5JeE_YsQquDfq2b3fCntMJunjUg8aCgYKAbESARUSFQHGX2MiuCZNTXNB8oN5EMVBdHffEQ0206",
|
||||||
|
"refresh_token": "1//0g-1DMMQieY-iCgYIARAAGBASNwF-L9IrbLZtEY9b5aXmbpTJ921vq4lIQ-8KHA-erzu231SNSqwseN4y6L8uQ-MrJ25yAANEGz0",
|
||||||
|
"scope": "https://www.googleapis.com/auth/drive.file",
|
||||||
|
"token_type": "Bearer",
|
||||||
|
"expiry_date": 1776540291131
|
||||||
|
}
|
||||||
122
README.md
122
README.md
@ -1,39 +1,83 @@
|
|||||||
# WhatsApp → Google Drive batch uploader (WD- commands)
|
# WhatsApp -> Google Drive batch uploader (`mcb` commands)
|
||||||
|
|
||||||
Phase 1: Upload user documents into your single Google Drive.
|
Uploads files from WhatsApp chats into structured Google Drive folders using batch commands.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
- WD-START → start a batch
|
- User-friendly (case-insensitive): `start`, `done`, `cancel`, `status`, `help`
|
||||||
- WD-END → upload all collected files
|
- Also supported fallback: `mcb-*` and legacy `hi mcb` / `bye mcb`
|
||||||
- WD-CANCEL → cancel batch
|
- Batch management:
|
||||||
- WD-STATUS → show count + time left
|
- `rename <folder-name>` -> change active batch target folder
|
||||||
- WD-PROJECT <name> → set project folder
|
- `list` -> show queued file names and sizes
|
||||||
- WD-HELP → help
|
- `undo` -> remove last queued file
|
||||||
|
- `retry-failed` -> retry previously failed uploads
|
||||||
## Setup
|
- Project/admin:
|
||||||
1) Install deps
|
- `mcb-project <name>` -> set/save a project folder
|
||||||
```
|
- `admin-stats` -> today + lifetime operational stats
|
||||||
npm install
|
- `admin-stats 7d` -> rolling summary for last N days (example: `7d`)
|
||||||
```
|
- `admin-stats YYYY-MM-DD` -> stats for a specific date
|
||||||
|
- `admin-health` -> live ops snapshot (heartbeat, queues, alerts)
|
||||||
2) Copy env
|
|
||||||
```
|
## Local setup (Windows/Linux)
|
||||||
copy .env.example .env
|
1) Install dependencies:
|
||||||
```
|
```bash
|
||||||
|
npm install
|
||||||
3) Put your Google OAuth client JSON at `credentials.json`
|
```
|
||||||
|
|
||||||
4) Generate token
|
2) Create `.env` (example values):
|
||||||
```
|
```env
|
||||||
npm run auth
|
GOOGLE_CREDENTIALS=./credentials.json
|
||||||
```
|
GOOGLE_TOKEN=./token.json
|
||||||
|
DEFAULT_ROOT_FOLDER=Whatsapp-Drive
|
||||||
5) Run bot
|
WA_CLIENT_ID=MCB-bot
|
||||||
```
|
OWNER_NUMBER=
|
||||||
npm start
|
BATCH_TTL_MIN=30
|
||||||
```
|
IDLE_RESTART_CHECK_MIN=60
|
||||||
|
IDLE_RESTART_MIN=240
|
||||||
## Notes
|
IDLE_RESTART_MAX_PER_DAY=6
|
||||||
- Bot only responds to messages that start with `WD-`.
|
DOWNLOAD_TIMEOUT_MS=900000
|
||||||
- Files are stored temporarily on disk under your system temp folder.
|
DOWNLOAD_MAX_RETRIES=2
|
||||||
# WhatsDrive-Whatsapp-To-Drive-Manager
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
3) Put Google OAuth client JSON at `credentials.json`.
|
||||||
|
|
||||||
|
4) Generate Drive token:
|
||||||
|
```bash
|
||||||
|
npm run auth
|
||||||
|
```
|
||||||
|
|
||||||
|
5) Start bot:
|
||||||
|
```bash
|
||||||
|
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 (`anyone` with `reader` role).
|
||||||
|
- 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.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user