fluxy-bot 0.15.14 → 0.16.1
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
CHANGED
|
@@ -212,6 +212,15 @@ export class WhatsAppChannel implements ChannelProvider {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
private async connectInternal(): Promise<void> {
|
|
215
|
+
// Clean up any existing socket before creating a new one
|
|
216
|
+
if (this.sock) {
|
|
217
|
+
try { this.sock.ev.removeAllListeners('creds.update'); } catch {}
|
|
218
|
+
try { this.sock.ev.removeAllListeners('connection.update'); } catch {}
|
|
219
|
+
try { this.sock.ev.removeAllListeners('messages.upsert'); } catch {}
|
|
220
|
+
try { this.sock.end(undefined); } catch {}
|
|
221
|
+
this.sock = null;
|
|
222
|
+
}
|
|
223
|
+
|
|
215
224
|
// Ensure auth directory exists
|
|
216
225
|
fs.mkdirSync(AUTH_DIR, { recursive: true });
|
|
217
226
|
|
|
@@ -291,6 +300,13 @@ export class WhatsAppChannel implements ChannelProvider {
|
|
|
291
300
|
return;
|
|
292
301
|
}
|
|
293
302
|
|
|
303
|
+
// Connection replaced (440) — another instance took over intentionally, don't fight it
|
|
304
|
+
if (statusCode === DisconnectReason.connectionReplaced) {
|
|
305
|
+
log.info('[whatsapp] Connection replaced by a new instance — not reconnecting');
|
|
306
|
+
this.emitStatus();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
294
310
|
// Any other disconnect — try to reconnect
|
|
295
311
|
log.info('[whatsapp] Reconnecting in 5s...');
|
|
296
312
|
this.reconnectTimer = setTimeout(() => this.connectInternal(), 5000);
|
package/supervisor/index.ts
CHANGED
|
@@ -449,7 +449,10 @@ export async function startSupervisor() {
|
|
|
449
449
|
${connected
|
|
450
450
|
? `<div class="confetti-wrap">${confettiHTML}</div>
|
|
451
451
|
<div class="video-wrap"><video autoplay muted playsinline><source src="/fluxy_happy_reappearing.mov" type='video/mp4; codecs="hvc1"'><source src="/fluxy_happy_reappearing.webm" type="video/webm"></video></div>
|
|
452
|
-
<div class="text-wrap"><div class="title">Connected!</div><p class="subtitle">WhatsApp is linked. You can close this page.</p
|
|
452
|
+
<div class="text-wrap"><div class="title">Connected!</div><p class="subtitle">WhatsApp is linked. You can close this page.</p>
|
|
453
|
+
<button onclick="relink()" style="margin-top:20px;padding:10px 24px;background:#2a2a2a;border:1px solid rgba(255,255,255,0.15);border-radius:10px;color:#999;font-size:13px;cursor:pointer;font-family:inherit;transition:all .2s" onmouseover="this.style.borderColor='#AF27E3';this.style.color='#f5f5f5'" onmouseout="this.style.borderColor='rgba(255,255,255,0.15)';this.style.color='#999'">Relink to a different number</button>
|
|
454
|
+
</div>
|
|
455
|
+
<script>async function relink(){await fetch('/api/channels/whatsapp/logout',{method:'POST'});await fetch('/api/channels/whatsapp/connect',{method:'POST'});setTimeout(()=>location.reload(),2000)}</script>`
|
|
453
456
|
: qr
|
|
454
457
|
? `<div class="qr-card"><div class="qr-inner">${qr}</div></div><p class="scan-hint">Scan with WhatsApp to link</p>`
|
|
455
458
|
: '<p class="loading">Starting WhatsApp... Refresh in a moment.</p>'}
|