Fix bug with apostraphe's in response

This commit is contained in:
Joseph Schmitt 2016-03-27 17:53:56 -04:00
parent fe2a34f698
commit fee32d0bb7
4 changed files with 17 additions and 10 deletions

BIN
icon-108x108.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
icon-tv-108x108.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -35,12 +35,18 @@ function handleFindShowIntent(req, resp) {
resp.say('Couldn\'t find ' + showName + ' queued for download. ');
sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) {
utils.sendSearchResponse(searchResults.data.results, resp);
utils
.createSearchResponse(searchResults.data.results, resp)
.send();
});
}
else {
resp
.say(['It looks like', result.show_name, 'is already on your list.'].join(' '))
.say([
'It looks like',
result.show_name.replace('\'s', 's'),
'is already on your list.'
].join(' '))
.send();
}
});
@ -53,7 +59,9 @@ function handleAddShowIntent(req, resp) {
var showName = req.slot('showName');
sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) {
utils.sendSearchResponse(searchResults.data.results, resp);
utils
.createSearchResponse(searchResults.data.results, resp)
.send();
});
//Async response
@ -66,7 +74,7 @@ function handleYesIntent(req, resp) {
if (!promptData) {
console.log('Got a AMAZON.YesIntent but no promptData. Ending session.');
resp.send();
resp.shouldEndSession(true).send();
}
else if (promptData.yesAction === 'addShow') {
show = promptData.searchResults[0];
@ -95,7 +103,7 @@ function handleNoIntent(req, resp) {
if (!promptData) {
console.log('Got a AMAZON.YesIntent but no promptData. Ending session.');
resp.send();
resp.shouldEndSession(true).send();
}
else if (promptData.noAction === 'endSession') {
resp.say(promptData.noResponse).send();

View File

@ -17,19 +17,18 @@ function buildPrompt(shows) {
return promptData;
}
function sendSearchResponse(shows, resp) {
function createSearchResponse(shows, resp) {
if(!shows || !shows.length) {
return resp.say('No show found for ' + showName).send();
}
resp
return resp
.say(['Add', shows[0].name, 'to your list?'].join(' '))
.session('promptData', buildPrompt(shows.slice(0, 5)))
.shouldEndSession(false)
.send();
.shouldEndSession(false);
}
module.exports = {
buildPrompt: buildPrompt,
sendSearchResponse: sendSearchResponse
createSearchResponse: createSearchResponse
};