Beispiel #1
0
        public JarvisResponse Handle(JarvisIntent intent)
        {
            var o     = intent.Intent.BestOutcome;
            var query = o.GetFirstString("wolfram_search_query").Value;
            var w     = new WolframAlpha("8GXWYP-Q8TLWGUH4H");

            w.Formats = new List <Format>()
            {
                Format.Plaintext
            };
            w.ScanTimeout = 0.1f;

            var results = w.Query(query);

            if (results != null)
            {
                var result = results.Pods.Find((p) => p.Title == "Result");
                if (result != null)
                {
                    return(new JarvisResponse(ProcessOutput(result.SubPods.First().Plaintext)));
                }
                else
                {
                    var pods      = results.RecalculateResults();
                    var newResult = pods.Find((p) => p.Title == "Result");
                    if (newResult != null)
                    {
                        return(new JarvisResponse(ProcessOutput(newResult.SubPods.First().Plaintext)));
                    }
                }
            }
            return(JarvisResponse.Unknown);
        }
        public JarvisResponse Handle(JarvisIntent intent)
        {
            var request  = WebRequest.Create("http://catfacts-api.appspot.com/api/facts");
            var response = request.GetResponse();
            var stream   = response.GetResponseStream();
            var bytes    = new StreamReader(stream).ReadToEnd();
            var cf       = JsonConvert.DeserializeObject <CatFactResponse>(bytes);

            var fact = cf.Facts.First();

            return(new JarvisResponse(fact));
        }
Beispiel #3
0
        public JarvisResponse Handle(JarvisIntent intent)
        {
            var o = intent.Intent.BestOutcome;

            if (o.Intent == "action")
            {
                return(HandleAction(o));
            }
            else if (o.Intent == "music")
            {
                return(HandleMusic(o));
            }
            else
            {
                return(JarvisResponse.Unknown);
            }
        }