From 7159e7f062260018aa6d77a5759fce5b3b6ea994 Mon Sep 17 00:00:00 2001 From: agnescameron Date: Wed, 5 Feb 2020 12:31:42 -0500 Subject: [PATCH] fixed map problem --- src/App.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 5ba5a90..0434a5d 100644 --- a/src/App.js +++ b/src/App.js @@ -60,12 +60,18 @@ class App extends Component { } } - processResponse = (text) => { + processResponse = async (text) => { + + let messages; + //check if message pure punctuation, let it pass if so + if(text.match(/[a-zA-Z\s]/g)){ + //breaks sentences into different messages + messages = text + .match(/[^.!?]+[.!?]*/g) + .map(str => str.trim()); + } + else messages = text; - //breaks sentences into different messages - const messages = text - .match(/[^.!?]+[.!?]*/g) - .map(str => str.trim()); this.botQueue = this.botQueue.concat(messages); // start processing bot queue @@ -81,7 +87,9 @@ class App extends Component { if(!preProcess){ runSample(text, this.state.currentBot) - .then( botResponse => { this.processResponse(botResponse); }) + .then( + botResponse => { + this.processResponse(botResponse); }) } else this.processResponse(preProcess); }