From 3f29ce5d5f484e6291a3eafcc6b5498f04054515 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 17 Apr 2023 16:31:14 -0300 Subject: [PATCH] =?UTF-8?q?altera=C3=A7ao=20para=20possibilitar=20=20que?= =?UTF-8?q?=20o=20wbot=20origine=20de=20sessoes=20remotas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WbotServices/wbotMessageListener.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 012828b..6260c6d 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -307,7 +307,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact: -async function sendDelayedMessages(wbot: Session, ticket: Ticket, contact: Contact, message: string, _msg?: WbotMessage) { +async function sendDelayedMessages(wbot: any, ticket: Ticket, contact: Contact, message: string, _msg?: WbotMessage) { const body = message.replace(/\\n/g, '\n'); if (body.search('dialog_actions') != -1) { @@ -544,7 +544,7 @@ const extractCallCode = (str: string) => { } const sendDialogflowAwswer = async ( - wbot: Session, + wbot: any, ticket: Ticket, msg: WbotMessage, contact: Contact, @@ -592,7 +592,7 @@ const sendDialogflowAwswer = async ( const verifyQueue = async ( - wbot: Session, + wbot: any, msg: WbotMessage, ticket: Ticket, contact: Contact @@ -667,7 +667,9 @@ const verifyQueue = async ( }); const _ticket = await ShowTicketService(ticket.id); - const chat = await msg.getChat(); + // const chat = await msg.getChat(); + const chat = wbot.chat + await sendDialogflowAwswer(wbot, _ticket, msg, contact, chat); return @@ -733,7 +735,7 @@ const verifyQueue = async ( } }; -const transferTicket = async (queueIndex: number, wbot: Session, ticket: Ticket, contact: Contact) => { +const transferTicket = async (queueIndex: number, wbot: any, ticket: Ticket, contact: Contact) => { const botInfo = await BotIsOnQueue('botqueue') @@ -789,7 +791,7 @@ const isValidMsg = (msg: WbotMessage): boolean => { }; -const queuesOutBot = async (wbot: Session, botId: string | number) => { +const queuesOutBot = async (wbot: any, botId: string | number) => { const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!); @@ -803,7 +805,7 @@ const queuesOutBot = async (wbot: Session, botId: string | number) => { } -const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact, wbot: Session) => { +const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact, wbot: any) => { await ticket.update({ userId: null }); @@ -811,7 +813,7 @@ const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact } -const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: Session, mediaPath: string, fileNameExtension: string) => { +const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: any, mediaPath: string, fileNameExtension: string) => { const debouncedSentMessage = debounce( @@ -843,7 +845,7 @@ const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: Session, med } -const botSendMessage = (ticket: Ticket, contact: Contact, wbot: Session, msg: string) => { +const botSendMessage = (ticket: Ticket, contact: Contact, wbot: any, msg: string) => { const debouncedSentMessage = debounce( @@ -1175,7 +1177,7 @@ const handleMsgAck = async (msg_id: any, ack: any) => { } }; -const wbotMessageListener = (wbot: Session): void => { +const wbotMessageListener = (wbot: any): void => { wbot.on("message_create", async msg => { handleMessage(msg, wbot);