From b700fd01a4a46acc785c2b7c954784dc495e348b Mon Sep 17 00:00:00 2001 From: elishadavidi <62501723+elishadavidi@users.noreply.github.com> Date: Thu, 28 May 2026 12:54:32 +0300 Subject: [PATCH] add simple ui --- .gitignore | 1 + index.js | 155 ++++++++++++++++++++++++++++++++++++++++++++-- package-lock.json | 2 +- 3 files changed, 153 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c82602a..56ecc27 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ .wwebjs_auth/ .wwebjs_cache/ *.session +.idea/ \ No newline at end of file diff --git a/index.js b/index.js index 0fe4efb..e711655 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,11 @@ let starting = false; let restarting = false; let msgCounter = 0; +let startTime = Date.now(); +let totalForwarded = 0; +let userStats = {}; +let groupStats = {}; + function ts() { return new Date().toLocaleString('he-IL', { hour12: false }); } @@ -76,6 +81,11 @@ async function flushQueue() { try { await sendSMS(text); log('INFO', `Flushed ${batch.length} messages`); + for (const m of batch) { + userStats[m.sender] = (userStats[m.sender] || 0) + 1; + groupStats[m.group] = (groupStats[m.group] || 0) + 1; + totalForwarded++; + } } catch (err) { log('ERROR', `Flush failed: ${err.message}`); messageQueue = batch.concat(messageQueue); @@ -256,12 +266,149 @@ async function startClient() { } } -/** - * 🔥 FIX: detect detached frame / WhatsApp Web crashes - */ +const http = require('http'); +function renderDashboard() { + const uptime = Math.floor((Date.now() - startTime) / 1000); + const h = Math.floor(uptime / 3600); + const m = Math.floor((uptime % 3600) / 60); + const s = uptime % 60; + const uptimeStr = `${h}h ${m}m ${s}s`; + + const userRows = Object.entries(userStats) + .sort((a, b) => b[1] - a[1]) + .map(([name, count]) => + `
WhatsApp group messages forwarded via SMS
+| Name | Messages |
|---|
| Group | Messages |
|---|