Skip to content

Commit

Permalink
fixed map problem
Browse files Browse the repository at this point in the history
  • Loading branch information
agnescameron committed Feb 5, 2020
1 parent e3741a6 commit 7159e7f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit 7159e7f

Please sign in to comment.