Alexa-Sickbeard/lib/utils.js

35 lines
925 B
JavaScript
Raw Normal View History

2016-03-27 16:22:50 -04:00
function buildPrompt(shows) {
var promptData = {
searchResults: shows.slice(0, 5),
yesAction : 'addShow',
yesResponse: ['Added', shows[0].name, 'to your list of shows to download.'].join(' ')
};
if (shows.length > 1) {
promptData.noAction = 'suggestNextShow';
promptData.noResponse = 'Ok, did you mean ' + shows[1].name + '?';
}
else {
promptData.noAction = 'endSession';
promptData.noResponse = 'Ok. I\'m out of suggestions. Sorry about that.';
}
return promptData;
}
2016-03-27 17:53:56 -04:00
function createSearchResponse(shows, resp) {
2016-03-27 16:22:50 -04:00
if(!shows || !shows.length) {
return resp.say('No show found for ' + showName).send();
}
2016-03-27 17:53:56 -04:00
return resp
2016-03-27 16:22:50 -04:00
.say(['Add', shows[0].name, 'to your list?'].join(' '))
.session('promptData', buildPrompt(shows.slice(0, 5)))
2016-03-27 17:53:56 -04:00
.shouldEndSession(false);
2016-03-27 16:22:50 -04:00
}
module.exports = {
buildPrompt: buildPrompt,
2016-03-27 17:53:56 -04:00
createSearchResponse: createSearchResponse
2016-03-27 16:22:50 -04:00
};