diff --git a/package-lock.json b/package-lock.json index 58f4ec1..819c541 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "wbot", - "version": "0.21.0", + "version": "0.22.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 98d3583..932dd11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wbot", - "version": "0.21.0", + "version": "0.22.0", "description": "A simple whatsapp reply bot using puppeteer.", "main": "src/index.js", "scripts": { diff --git a/src/inject.js b/src/inject.js index 117cacf..5af1a3f 100644 --- a/src/inject.js +++ b/src/inject.js @@ -151,16 +151,11 @@ async function processMessages(data) { if (exactMatch != undefined) { response = await resolveSpintax(exactMatch.response); window.log(`Replying with ${response}`); - } else { - response = await resolveSpintax(intents.noMatch); - window.log(`No exact match found. So replying with ${response} instead`); } var PartialMatch = intents.bot.find(obj => obj.contains.find(ex => message.body.toLowerCase().search(ex) > -1)); if (PartialMatch != undefined) { response = await resolveSpintax(PartialMatch.response); window.log(`Replying with ${response}`); - } else { - console.log("No partial match found"); } WAPI.sendSeen(message.chatId._serialized); response = response.fillVariables({ name: message.sender.pushname, phoneNumber: message.sender.id.user, greetings: greetings() }) @@ -200,6 +195,13 @@ async function processMessages(data) { window.log("Processing webhook from block") processWebhook((exactMatch || PartialMatch).webhook, message, body) } + } else { + // We are sure we haven't found any exact or partial match + // as we are already checking it in the above if statement + // So process with the noMatch logic only + response = await resolveSpintax(intents.noMatch); + window.log(`No exact or partial match found. So replying with ${response} instead`); + WAPI.sendMessage2(message.chatId._serialized, response); } } }