Tratando erro no msg.body

pull/20/head
adriano 2023-04-17 16:42:15 -03:00
parent 3f29ce5d5f
commit 48f6943ece
1 changed files with 12 additions and 11 deletions

View File

@ -307,7 +307,7 @@ const monitoramento_response2 = async (response: any | null, wbot: any, contact:
async function sendDelayedMessages(wbot: any, ticket: Ticket, contact: Contact, message: string, _msg?: WbotMessage) { async function sendDelayedMessages(wbot: Session, ticket: Ticket, contact: Contact, message: string, _msg?: WbotMessage) {
const body = message.replace(/\\n/g, '\n'); const body = message.replace(/\\n/g, '\n');
if (body.search('dialog_actions') != -1) { if (body.search('dialog_actions') != -1) {
@ -544,9 +544,9 @@ const extractCallCode = (str: string) => {
} }
const sendDialogflowAwswer = async ( const sendDialogflowAwswer = async (
wbot: any, wbot: Session,
ticket: Ticket, ticket: Ticket,
msg: WbotMessage, msg: any,
contact: Contact, contact: Contact,
chat: Chat chat: Chat
) => { ) => {
@ -555,7 +555,9 @@ const sendDialogflowAwswer = async (
return; return;
} }
wbot.sendPresenceAvailable(); // wbot.sendPresenceAvailable();
// console.log('(msg: ', msg )
// console.log('typeof(msg.type): ', typeof (msg.type), ' | msg.type: ', msg.type) // console.log('typeof(msg.type): ', typeof (msg.type), ' | msg.type: ', msg.type)
@ -669,7 +671,6 @@ const verifyQueue = async (
const _ticket = await ShowTicketService(ticket.id); const _ticket = await ShowTicketService(ticket.id);
// const chat = await msg.getChat(); // const chat = await msg.getChat();
const chat = wbot.chat const chat = wbot.chat
await sendDialogflowAwswer(wbot, _ticket, msg, contact, chat); await sendDialogflowAwswer(wbot, _ticket, msg, contact, chat);
return return
@ -735,7 +736,7 @@ const verifyQueue = async (
} }
}; };
const transferTicket = async (queueIndex: number, wbot: any, ticket: Ticket, contact: Contact) => { const transferTicket = async (queueIndex: number, wbot: Session, ticket: Ticket, contact: Contact) => {
const botInfo = await BotIsOnQueue('botqueue') const botInfo = await BotIsOnQueue('botqueue')
@ -791,7 +792,7 @@ const isValidMsg = (msg: WbotMessage): boolean => {
}; };
const queuesOutBot = async (wbot: any, botId: string | number) => { const queuesOutBot = async (wbot: Session, botId: string | number) => {
const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!); const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!);
@ -805,7 +806,7 @@ const queuesOutBot = async (wbot: any, botId: string | number) => {
} }
const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact, wbot: any) => { const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact, wbot: Session) => {
await ticket.update({ userId: null }); await ticket.update({ userId: null });
@ -813,7 +814,7 @@ const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact
} }
const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: any, mediaPath: string, fileNameExtension: string) => { const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: Session, mediaPath: string, fileNameExtension: string) => {
const debouncedSentMessage = debounce( const debouncedSentMessage = debounce(
@ -845,7 +846,7 @@ const botSendMedia = async (ticket: Ticket, contact: Contact, wbot: any, mediaPa
} }
const botSendMessage = (ticket: Ticket, contact: Contact, wbot: any, msg: string) => { const botSendMessage = (ticket: Ticket, contact: Contact, wbot: Session, msg: string) => {
const debouncedSentMessage = debounce( const debouncedSentMessage = debounce(
@ -1177,7 +1178,7 @@ const handleMsgAck = async (msg_id: any, ack: any) => {
} }
}; };
const wbotMessageListener = (wbot: any): void => { const wbotMessageListener = (wbot: Session): void => {
wbot.on("message_create", async msg => { wbot.on("message_create", async msg => {
handleMessage(msg, wbot); handleMessage(msg, wbot);