beast-agent 0.23.0 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agent/whatsapp.js +30 -2
- package/src/main.js +18 -12
package/package.json
CHANGED
package/src/agent/whatsapp.js
CHANGED
|
@@ -58,6 +58,7 @@ class WhatsAppBridge {
|
|
|
58
58
|
this.reconnectTimer = null;
|
|
59
59
|
this._tracked = new Map(); // msgId -> { jid, preview, ts, status, receiptDetail }
|
|
60
60
|
this._watchJids = new Set(); // presence aboneliği tutulacak sohbetler
|
|
61
|
+
this._seenIds = new Set(); // işlenen mesaj id'leri — offline replay + notify çift işlemeyi önler
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/* main tarafı waChats anahtarlarını bildirir; bağlantı varsa anında abone olunur */
|
|
@@ -126,7 +127,10 @@ class WhatsAppBridge {
|
|
|
126
127
|
printQRInTerminal: false,
|
|
127
128
|
browser: ['Beast Agent', 'Chrome', '1.0.0'],
|
|
128
129
|
syncFullHistory: false,
|
|
129
|
-
|
|
130
|
+
/* false OLMALI: bot "çevrimiçi" işaretlenirse WhatsApp sunucusu kesintide
|
|
131
|
+
gelen mesajları bu cihaz için kuyruklamayı aksatıyor. false ile kesintideki
|
|
132
|
+
mesajlar sunucuda bekler, bağlantı dönünce 'append' upsert'iyle iletilir. */
|
|
133
|
+
markOnlineOnConnect: false,
|
|
130
134
|
});
|
|
131
135
|
|
|
132
136
|
this.sock.ev.on('creds.update', saveCreds);
|
|
@@ -263,14 +267,38 @@ class WhatsAppBridge {
|
|
|
263
267
|
}
|
|
264
268
|
|
|
265
269
|
_handleMessages(m) {
|
|
266
|
-
|
|
270
|
+
/* 'notify' = canlı mesaj akışı
|
|
271
|
+
'append' = bağlantı kesintisinde KAÇIRILMIŞ mesajlar — bağlantı dönünce
|
|
272
|
+
sunucu bunları oynatır; FALLOUT sorunu tam olarak burasıydı:
|
|
273
|
+
yalnızca 'notify' işlendiği için kesintideki mesajlar sessizce
|
|
274
|
+
düşüyor ve cevapsız kalıyordu. 'append' içindeki eski history
|
|
275
|
+
kayıtlarını elemek için son 15 dk tazelik filtresi kullanılır. */
|
|
276
|
+
if (m.type !== 'notify' && m.type !== 'append') return;
|
|
277
|
+
const nowMs = Date.now();
|
|
267
278
|
for (const msg of m.messages || []) {
|
|
279
|
+
/* aynı mesaj hem 'append' hem 'notify' ile gelebilir — ID dedup */
|
|
280
|
+
const mid = msg.key && msg.key.id;
|
|
281
|
+
if (mid) {
|
|
282
|
+
if (this._seenIds.has(mid)) continue;
|
|
283
|
+
this._seenIds.add(mid);
|
|
284
|
+
if (this._seenIds.size > 600) {
|
|
285
|
+
for (const k of [...this._seenIds].slice(0, 300)) this._seenIds.delete(k);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
268
288
|
/* tepkiler ayrı kanal: onay kapısı bunları dinler */
|
|
269
289
|
const rm = msg.message && msg.message.reactionMessage;
|
|
270
290
|
if (rm) {
|
|
271
291
|
this._handleReaction(msg, rm);
|
|
272
292
|
continue;
|
|
273
293
|
}
|
|
294
|
+
if (m.type === 'append') {
|
|
295
|
+
const ts = Number(msg.messageTimestamp) || 0;
|
|
296
|
+
const tsMs = ts > 1e12 ? ts : ts * 1000; // saniye/ms normalizasyonu
|
|
297
|
+
if (!tsMs || nowMs - tsMs > 15 * 60 * 1000) continue; // eski history — işleme
|
|
298
|
+
try {
|
|
299
|
+
waLogSafe(`offline/append mesaj işleniyor (kesintiden kalan, ${new Date(tsMs).toISOString()})`);
|
|
300
|
+
} catch {}
|
|
301
|
+
}
|
|
274
302
|
this._processIncoming(msg).catch(() => {});
|
|
275
303
|
}
|
|
276
304
|
}
|
package/src/main.js
CHANGED
|
@@ -4073,20 +4073,26 @@ function npmSelfUpdate() {
|
|
|
4073
4073
|
" exit 1",
|
|
4074
4074
|
"}",
|
|
4075
4075
|
"L 'npm install tamam, yeniden baslatma'",
|
|
4076
|
-
"$
|
|
4077
|
-
"if ($
|
|
4078
|
-
"
|
|
4079
|
-
"
|
|
4076
|
+
"$prefix = (& $npmCmd prefix -g 2>$null)",
|
|
4077
|
+
"if (-not $prefix) { $prefix = Join-Path $env:APPDATA 'npm' }",
|
|
4078
|
+
"$appDir = Join-Path $prefix 'node_modules\\beast-agent'",
|
|
4079
|
+
"$exe = Join-Path $appDir 'node_modules\\electron\\dist\\electron.exe'",
|
|
4080
|
+
"if (-not (Test-Path $exe)) { $exe = Join-Path $prefix 'node_modules\\electron\\dist\\electron.exe' }",
|
|
4081
|
+
"if (Test-Path $exe) {",
|
|
4082
|
+
" L \"dogrudan electron: $exe\"",
|
|
4083
|
+
" # WindowStyle Hidden KULLANMA: gizli bayragi Chromium miras alir, ilk pencere tray'de kaybolur",
|
|
4084
|
+
" Start-Process -FilePath $exe -ArgumentList \"`\"$appDir`\"\"",
|
|
4080
4085
|
"} else {",
|
|
4081
|
-
" $
|
|
4082
|
-
" if (
|
|
4083
|
-
"
|
|
4084
|
-
"
|
|
4085
|
-
"
|
|
4086
|
-
"
|
|
4087
|
-
"
|
|
4086
|
+
" $shim = Get-Command 'beast-agent.cmd' -ErrorAction SilentlyContinue",
|
|
4087
|
+
" if ($shim) {",
|
|
4088
|
+
" L \"shim uzerinden: $($shim.Source)\"",
|
|
4089
|
+
" Start-Process -FilePath $shim.Source",
|
|
4090
|
+
" } else {",
|
|
4091
|
+
" L 'HATA: electron.exe ve shim bulunamadi - yeniden baslatma yapilamadi'",
|
|
4092
|
+
" exit 1",
|
|
4093
|
+
" }",
|
|
4088
4094
|
"}",
|
|
4089
|
-
"L '=== self-update bitti ==='",
|
|
4095
|
+
"L '=== self-update bitti ==='",
|
|
4090
4096
|
].join('\r\n');
|
|
4091
4097
|
const psFile = path.join(APP_DIR, 'update-helper.ps1');
|
|
4092
4098
|
fs.writeFileSync(psFile, ps, 'utf8');
|