Code wird nicht richtig dargestellt

Hier können Anmerkungen zum Forum und seinen Funktionen gegeben werden.
Antworten

Themenstarter
gehwissenlos

Sa 18. Feb 2017, 10:18

Ich finde an diesem Forum super, dass man sich auch auch über die Skillprogrammierung austausche kann. Leider werden jedoch Teile des Codes entfernt. Zum einen wird aus

Code: Alles auswählen

output = output + entry.title + " <break time=\"0.6s\"/> ";

Code: Alles auswählen

output = output + entry.title + "   ";
(siehe Ende folgendes Beispiel) und zum anderen wird am Ende einfach etwas abgeschnitten.

Code: Alles auswählen

/**
* App ID for the skill
*/
var APP_ID = "amzn1.ask.skill.+++++++";

var AlexaSkill = require('./AlexaSkill');
var parser = require('rss-parser');

var RssReader = function () {
  AlexaSkill.call(this, APP_ID);
};

// Extend AlexaSkill
RssReader.prototype = Object.create(AlexaSkill.prototype);
RssReader.prototype.constructor = RssReader;

RssReader.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {
  console.log("RssReader onSessionStarted requestId: " + sessionStartedRequest.requestId
  + ", sessionId: " + session.sessionId);
  // any initialization logic goes here
};

RssReader.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
  console.log("RssReader onLaunch requestId: " + launchRequest.requestId + ", sessionId: " + session.sessionId);
  var speechOutput = "Hallo, was soll ich tun?";
  var repromptText = "Möchtest du News? Dann frage mich: Was gibt es Neues.";
  response.ask(speechOutput, repromptText);
};

RssReader.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
  console.log("RssReader onSessionEnded requestId: " + sessionEndedRequest.requestId
  + ", sessionId: " + session.sessionId);
  // any cleanup logic goes here
};

RssReader.prototype.intentHandlers = {
  // register custom intent handlers
  "GetNews": function (intent, session, response) {
    var url;
    url = "https://www.beispielurl.de/feed/alexa/";
    /*if(intent.slots && intent.slots.FeedName)
    {
      switch (intent.slots.FeedName.value.toLowerCase()) {
        case "world":
        url = "http://feeds.bbci.co.uk/news/world/rss.xml?edition=uk";
        break;
        case "front page":
        case "uk":
        case "main":
        url = "http://feeds.bbci.co.uk/news/rss.xml?edition=uk";
        break;
        case "technology":
        case "tech":
        url = "http://feeds.bbci.co.uk/news/technology/rss.xml?edition=uk";
        console.log("tech");
        break;
        case "local":
        case "northern ireland":
        url = "http://feeds.bbci.co.uk/news/northern_ireland/rss.xml?edition=uk";
        break;
        case "business":
        url = "http://feeds.bbci.co.uk/news/business/rss.xml?edition=uk";
        break;
        case "politics":
        url = "http://feeds.bbci.co.uk/news/politics/rss.xml?edition=uk";
        break;
        case "health":
        url = "http://feeds.bbci.co.uk/news/health/rss.xml?edition=uk";
        break;
        case "education":
        url = "http://feeds.bbci.co.uk/news/education/rss.xml?edition=uk";
        break;
        case "science":
        url = "http://feeds.bbci.co.uk/news/science_and_environment/rss.xml?edition=uk";
        break;
        case "entertainment":
        url = "http://feeds.bbci.co.uk/news/entertainment_and_arts/rss.xml?edition=uk";
        break;

        default:
        response.tellWithCard("Unable to understand " + intent.slots.FeedName.value, "RSS Headlines", "Couldn't understand " + intent.slots.FeedName.value);
        return;
      }
    }
    else
    {
      //response.tellWithCard("Unable to understand that request", "RSS Headlines", "Couldn't understand the request");
        url = "http://feeds.bbci.co.uk/news/technology/rss.xml?edition=uk";
      return;
    }*/

    parser.parseURL(url, function(err,parsed){

      var output = "" + parsed.feed.title + " <break time=\"0.8s\"/> ";

      var i = 0;
      parsed.feed.entries.forEach(function(entry){
        if(i <= 4)
        {
          output = output + entry.title + " <break time=\"0.6s\"/> ";
          output = output + entry.description + " <break time=\"0.1s\"/><audio src='https://www.beispiel-url.de/wp-content/uploads/2017/02/alexa-pageflip.mp3'/><break time=\"0.1s\"/> ";
          i++;
        }
      })

      var ssmlOutput = {
        speech: '<speak>' + output + '</speak>',
        type: AlexaSkill.speechOutputType.SSML
      };

      response.tellWithCard(ssmlOutput, "Neues vom Verein", "Lese Zusammenfassung von " + parsed.feed.title);
    });

  },
  "AMAZON.HelpIntent": function (intent, session, response) {
    response.ask("Frage mich: was gibt es Neues.");
  },
  "AMAZON.StopIntent": function (intent, session, response) {
      var speechOutput = {
                speech: "Bis bald!",
                type: AlexaSkill.speechOutputType.PLAIN_TEXT
        };
    response.tell(speechOutput);
  },
  "AMAZON.CancelIntent": function (intent, session, response) {
      var speechOutput = {
                speech: "Bis bald!",
                type: AlexaSkill.speechOutputType.PLAIN_TEXT
        };
    response.tell(speechOutput);
  }
};

// Create the handler that responds to the Alexa Request.
exports.handler = function (event, context) {
  // Create an instance of the RssReader skill.
  var rssReader = new RssReader();
  rssReader.execute(event, context);
};
Warum?
0 x
Benutzeravatar

Olli
Beiträge: 12
Registriert: Mi 15. Feb 2017, 21:46
Wohnort: NRW
Vorhandene Echos: 1

Mo 20. Feb 2017, 04:08

Ich weiß nicht, ob die Codecs übereinstimmen, bei einem früher von mir verwendeten läge es an dem Leerzeichen, das da jeweils nach und vor dem Anführungszeichen steht.
0 x
Life fast, die young... Mist, verpasst.
Antworten

Zurück zu „Anmerkungen“

  • Information