Trabalhando no restore automatico
parent
330299726d
commit
1ef86354f8
|
@ -138,10 +138,7 @@ export const initWbot = async (whatsapp: Whatsapp, backupSessionRestore: boolean
|
||||||
});
|
});
|
||||||
|
|
||||||
wbot.on("ready", async () => {
|
wbot.on("ready", async () => {
|
||||||
logger.info(`Session: ${sessionName} READY`);
|
logger.info(`Session: ${sessionName} READY`);
|
||||||
|
|
||||||
// console.log('>>>>>>>>>>>>>> ready wbot.ts MOBILE NUMBER: ', wbot.info["wid"]["user"])
|
|
||||||
// console.log('::::::: WHATSAPP INFO: ', JSON.parse(JSON.stringify(whatsapp)))
|
|
||||||
|
|
||||||
if(whatsapp.name.includes(wbot.info["wid"]["user"])){
|
if(whatsapp.name.includes(wbot.info["wid"]["user"])){
|
||||||
console.log('-----------------> THIS IS THE RIGHT NUMBER')
|
console.log('-----------------> THIS IS THE RIGHT NUMBER')
|
||||||
|
|
|
@ -8,6 +8,8 @@ import { insertOrUpeateWhatsCache } from "../../helpers/WhatsCache";
|
||||||
|
|
||||||
export const StartWhatsAppSession = async (whatsapp: Whatsapp, backupSession: boolean = false): Promise<void> => {
|
export const StartWhatsAppSession = async (whatsapp: Whatsapp, backupSession: boolean = false): Promise<void> => {
|
||||||
await whatsapp.update({ status: "OPENING" });
|
await whatsapp.update({ status: "OPENING" });
|
||||||
|
|
||||||
|
console.log('kkkkkkkkkkkkkxxxxxxxxxxxxxxxxxx')
|
||||||
|
|
||||||
await insertOrUpeateWhatsCache(`whatsapp:${whatsapp.id}`, {
|
await insertOrUpeateWhatsCache(`whatsapp:${whatsapp.id}`, {
|
||||||
status: "OPENING",
|
status: "OPENING",
|
||||||
|
|
|
@ -60,6 +60,7 @@ const wbotMonitor = async (
|
||||||
wbot.on("disconnected", async reason => {
|
wbot.on("disconnected", async reason => {
|
||||||
logger.info(`Disconnected session: ${sessionName}, reason: ${reason}`);
|
logger.info(`Disconnected session: ${sessionName}, reason: ${reason}`);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await whatsapp.update({ status: "OPENING", session: "" });
|
await whatsapp.update({ status: "OPENING", session: "" });
|
||||||
await insertOrUpeateWhatsCache(`whatsapp:${whatsapp.id}`, { status: "OPENING", session: "" })
|
await insertOrUpeateWhatsCache(`whatsapp:${whatsapp.id}`, { status: "OPENING", session: "" })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue