feat: started multiple whatsapps support

This commit is contained in:
canove
2020-09-04 20:18:11 -03:00
parent f7fe3286b8
commit 8786c7ca5e
6 changed files with 72 additions and 36 deletions

View File

@@ -132,12 +132,13 @@ const handleMessage = async (msg, ticket, contact) => {
});
};
const wbotMessageListener = () => {
const wbot = getWbot();
const wbotMessageListener = dbSession => {
const wbot = getWbot(dbSession.name);
const io = getIO();
wbot.on("message_create", async msg => {
console.log(msg);
if (
msg.from === "status@broadcast" ||
msg.type === "location" ||

View File

@@ -7,7 +7,7 @@ const { getWbot, init } = require("../libs/wbot");
const wbotMonitor = dbSession => {
const io = getIO();
const wbot = getWbot();
const wbot = getWbot(dbSession.name);
try {
wbot.on("change_state", async newState => {
@@ -58,8 +58,8 @@ const wbotMonitor = dbSession => {
setTimeout(
() =>
init()
.then(({ dbSession }) => {
init(dbSession)
.then(() => {
wbotMessageListener();
wbotMonitor(dbSession);
})