Exemplo n.º 1
0
        public async Task <ChatterBotThought> Think(ChatterBotThought thought)
        {
            vars["input"] = thought.Text;

            var response = await ChatterBotUtils.PostAsync("https://www.pandorabots.com/pandora/talk-xml", vars, null);

            var responseThought = new ChatterBotThought();

            responseThought.Text = ChatterBotUtils.XPathSearch(response, "//result/that/text()");

            return(responseThought);
        }
Exemplo n.º 2
0
        public async Task <ChatterBotThought> Think(ChatterBotThought thought)
        {
            vars["stimulus"] = thought.Text;

            var formData         = ChatterBotUtils.ParametersToWWWFormURLEncoded(vars);
            var formDataToDigest = formData.Substring(9, endIndex);
            var formDataDigest   = ChatterBotUtils.MD5(formDataToDigest);

            vars["icognocheck"] = formDataDigest;

            var response = await ChatterBotUtils.PostAsync(url, vars, cookies);

            var responseValues = response.Split('\r');

            //vars[""] = Utils.StringAtIndex(responseValues, 0); ??
            vars["sessionid"] = ChatterBotUtils.StringAtIndex(responseValues, 1);
            vars["logurl"]    = ChatterBotUtils.StringAtIndex(responseValues, 2);
            vars["vText8"]    = ChatterBotUtils.StringAtIndex(responseValues, 3);
            vars["vText7"]    = ChatterBotUtils.StringAtIndex(responseValues, 4);
            vars["vText6"]    = ChatterBotUtils.StringAtIndex(responseValues, 5);
            vars["vText5"]    = ChatterBotUtils.StringAtIndex(responseValues, 6);
            vars["vText4"]    = ChatterBotUtils.StringAtIndex(responseValues, 7);
            vars["vText3"]    = ChatterBotUtils.StringAtIndex(responseValues, 8);
            vars["vText2"]    = ChatterBotUtils.StringAtIndex(responseValues, 9);
            vars["prevref"]   = ChatterBotUtils.StringAtIndex(responseValues, 10);
            //vars[""] = Utils.StringAtIndex(responseValues, 11); ??
            //            vars["emotionalhistory"] = Utils.StringAtIndex(responseValues, 12);
            //            vars["ttsLocMP3"] = Utils.StringAtIndex(responseValues, 13);
            //            vars["ttsLocTXT"] = Utils.StringAtIndex(responseValues, 14);
            //            vars["ttsLocTXT3"] = Utils.StringAtIndex(responseValues, 15);
            //            vars["ttsText"] = Utils.StringAtIndex(responseValues, 16);
            //            vars["lineRef"] = Utils.StringAtIndex(responseValues, 17);
            //            vars["lineURL"] = Utils.StringAtIndex(responseValues, 18);
            //            vars["linePOST"] = Utils.StringAtIndex(responseValues, 19);
            //            vars["lineChoices"] = Utils.StringAtIndex(responseValues, 20);
            //            vars["lineChoicesAbbrev"] = Utils.StringAtIndex(responseValues, 21);
            //            vars["typingData"] = Utils.StringAtIndex(responseValues, 22);
            //            vars["divert"] = Utils.StringAtIndex(responseValues, 23);

            var responseThought = new ChatterBotThought();

            responseThought.Text = ChatterBotUtils.StringAtIndex(responseValues, 0);

            return(responseThought);
        }