mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
26 lines
634 B
TypeScript
26 lines
634 B
TypeScript
import { initWbot } from "../../libs/wbot";
|
|
import Whatsapp from "../../models/Whatsapp";
|
|
import wbotMessageListener from "./wbotMessageListener";
|
|
import { getIO } from "../../libs/socket";
|
|
import wbotMonitor from "./wbotMonitor";
|
|
|
|
export const StartWhatsAppSession = async (
|
|
whatsapp: Whatsapp
|
|
): Promise<void> => {
|
|
await whatsapp.update({ status: "OPENING" });
|
|
|
|
const io = getIO();
|
|
io.emit("whatsappSession", {
|
|
action: "update",
|
|
session: whatsapp
|
|
});
|
|
|
|
try {
|
|
const wbot = await initWbot(whatsapp);
|
|
wbotMessageListener(wbot);
|
|
wbotMonitor(wbot, whatsapp);
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
};
|