[repo] desacoplamento e maior coesão
This commit is contained in:
synt-xerror
2026-03-13 11:30:34 -03:00
parent fe95e77a68
commit 88a7abba5d
19 changed files with 439 additions and 393 deletions

View File

@@ -0,0 +1,28 @@
import pkg from "whatsapp-web.js";
import qrcode from "qrcode-terminal";
import { exec } from "child_process";
import { CLIENT_ID } from "../config.js";
export const { Client, LocalAuth, MessageMedia } = pkg;
export const client = new Client({
authStrategy: new LocalAuth({ clientId: CLIENT_ID }),
puppeteer: { headless: true }
});
client.on("qr", qr => {
console.log("[BOT] Escaneie o QR Code");
qrcode.generate(qr, { small: true });
});
client.on("ready", () => {
exec("clear");
console.log("[BOT] WhatsApp conectado.");
});
client.on("disconnected", reason => {
console.warn("[BOT] Reconectando:", reason);
setTimeout(() => client.initialize(), 5000);
});
export default client;