4a. import content from WP ; change design to reflect 4a
This commit is contained in:
@@ -3,9 +3,8 @@ const config = require ('../config/config');
|
||||
var databaseHelper = require ('../helpers/database');
|
||||
var emailHelper = require ('../helpers/email');
|
||||
const constants = require ('../config/constants');
|
||||
let Parser = require('rss-parser');
|
||||
let predefinedSourceHelper = require ('../helpers/externalSource');
|
||||
|
||||
let parser = new Parser();
|
||||
var handlers = {};
|
||||
var destinationEmail;
|
||||
|
||||
@@ -46,7 +45,8 @@ module.exports = {
|
||||
'ms"/>';
|
||||
}
|
||||
});
|
||||
listOfPossibleQuestions += 'If you dont know what to do, just say help or stop';
|
||||
listOfPossibleQuestions +=
|
||||
'If you dont know what to do, just say help or stop';
|
||||
|
||||
//Handler for launch requestconsole.log()
|
||||
handlers = {
|
||||
@@ -60,7 +60,7 @@ module.exports = {
|
||||
'Would you like to hear list of questions that you can ask me'
|
||||
)
|
||||
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
|
||||
this.attributes['LaunchRequestYesNo'] = true;
|
||||
this.attributes['LaunchRequestYesNo'] = true;
|
||||
this.emit (':responseReady');
|
||||
},
|
||||
};
|
||||
@@ -68,20 +68,23 @@ module.exports = {
|
||||
//Handlers for user defined questions
|
||||
activeSkill.intents.map (intent => {
|
||||
handlers[intent.intentName] = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
}
|
||||
if (intent.predefinedAnswer) {
|
||||
const url = 'https://www.klix.ba/rss/naslovnica';
|
||||
let feed = await parser.parseURL(url);
|
||||
console.log(feed.title);
|
||||
|
||||
feed.items.forEach(item => {
|
||||
console.log(item.title + ':' + item.link)
|
||||
});
|
||||
let answer = '';
|
||||
switch (intent.answerType){
|
||||
case constants.answerType.PREDEFINED:
|
||||
answer = intent.answer;
|
||||
break;
|
||||
case constants.answerType.EXTERNAL_SOURCE_WP_JSON:
|
||||
answer = predefinedSourceHelper.getAnswerFromWP(intent.externalAnswerSource);
|
||||
break;
|
||||
case constants.answerType.EXTERNAL_SOURCE_RSS:
|
||||
answer = 'Not implemented yet'
|
||||
break;
|
||||
}
|
||||
this.response
|
||||
.speak (intent.answer)
|
||||
.speak (answer)
|
||||
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
|
||||
this.emit (':responseReady');
|
||||
};
|
||||
@@ -89,7 +92,7 @@ module.exports = {
|
||||
|
||||
//Handler for sending message
|
||||
handlers.SendMessageIntent = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
}
|
||||
|
||||
@@ -182,7 +185,7 @@ module.exports = {
|
||||
//Built-In intents
|
||||
|
||||
handlers.CancelIntent = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
}
|
||||
this.response.speak ('Thank you for using Saburly');
|
||||
@@ -190,7 +193,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
handlers.HelpIntent = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
}
|
||||
this.response
|
||||
@@ -199,26 +202,32 @@ module.exports = {
|
||||
this.emit (':responseReady');
|
||||
};
|
||||
|
||||
handlers.YesIntent = function(){
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
handlers.YesIntent = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
this.emit('HelpIntent');
|
||||
}else{
|
||||
this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit(':responseReady');
|
||||
this.emit ('HelpIntent');
|
||||
} else {
|
||||
this.response
|
||||
.speak (constants.voiceResponseStrings.DIDNT_ASK_ANYTHING)
|
||||
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit (':responseReady');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handlers.NoIntent = function (){
|
||||
if (this.attributes['LaunchRequestYesNo']){
|
||||
handlers.NoIntent = function () {
|
||||
if (this.attributes['LaunchRequestYesNo']) {
|
||||
this.attributes['LaunchRequestYesNo'] = false;
|
||||
this.response.speak('').listen(constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit(':responseReady');
|
||||
}else{
|
||||
this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit(':responseReady');
|
||||
this.response
|
||||
.speak ('')
|
||||
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit (':responseReady');
|
||||
} else {
|
||||
this.response
|
||||
.speak (constants.voiceResponseStrings.DIDNT_ASK_ANYTHING)
|
||||
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE);
|
||||
this.emit (':responseReady');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Default handler for unknown question
|
||||
|
||||
|
||||
Reference in New Issue
Block a user