Bot: página /qr para vincular WhatsApp con QR escaneable
El QR de Baileys solo salía como ASCII en los logs (ilegible en Dokploy). Ahora el WhatsappService empuja el QR al WebhookListener, que sirve GET /qr?key= <FUNNEL_API_KEY> con el código como imagen (lib qrcode), autorrefresco y estado "ya conectado". Añade dependencia qrcode. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -136,17 +136,20 @@ export class WhatsappService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
if (qr) {
|
||||
QRCode.generate(qr, { small: true });
|
||||
console.log('\n📲 Escanea este QR con WhatsApp\n');
|
||||
console.log('\n📲 Escanea este QR con WhatsApp (o abre /qr?key=FUNNEL_API_KEY)\n');
|
||||
this.webhookListener.setQr(qr);
|
||||
}
|
||||
|
||||
if (connection === 'close') {
|
||||
const shouldReconnect =
|
||||
(lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut;
|
||||
this.logger.warn(`Conexion cerrada. Reconectar: ${shouldReconnect}.`);
|
||||
this.webhookListener.setConectado(false);
|
||||
if (shouldReconnect) setTimeout(() => this.conectar(), 5000);
|
||||
else this.logger.error('Sesion cerrada (logged out).');
|
||||
} else if (connection === 'open') {
|
||||
this.logger.log('✅ WhatsApp conectado. Luisa esta lista.');
|
||||
this.webhookListener.setConectado(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user