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. '); resp.say('Couldn\'t find ' + showName + ' queued for download. ');
sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) { sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) {
utils.sendSearchResponse(searchResults.data.results, resp); utils
.createSearchResponse(searchResults.data.results, resp)
.send();
}); });
} }
else { else {
resp 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(); .send();
} }
}); });
@ -53,7 +59,9 @@ function handleAddShowIntent(req, resp) {
var showName = req.slot('showName'); var showName = req.slot('showName');
sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) { sb.cmd('sb.searchtvdb', {name: showName}).then(function (searchResults) {
utils.sendSearchResponse(searchResults.data.results, resp); utils
.createSearchResponse(searchResults.data.results, resp)
.send();
}); });
//Async response //Async response
@ -66,7 +74,7 @@ function handleYesIntent(req, resp) {
if (!promptData) { if (!promptData) {
console.log('Got a AMAZON.YesIntent but no promptData. Ending session.'); console.log('Got a AMAZON.YesIntent but no promptData. Ending session.');
resp.send(); resp.shouldEndSession(true).send();
} }
else if (promptData.yesAction === 'addShow') { else if (promptData.yesAction === 'addShow') {
show = promptData.searchResults[0]; show = promptData.searchResults[0];
@ -95,7 +103,7 @@ function handleNoIntent(req, resp) {
if (!promptData) { if (!promptData) {
console.log('Got a AMAZON.YesIntent but no promptData. Ending session.'); console.log('Got a AMAZON.YesIntent but no promptData. Ending session.');
resp.send(); resp.shouldEndSession(true).send();
} }
else if (promptData.noAction === 'endSession') { else if (promptData.noAction === 'endSession') {
resp.say(promptData.noResponse).send(); resp.say(promptData.noResponse).send();

View File

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