Exemplo n.º 1
0
        public async Task <string> GetReply(string input)
        {
            CleverbotReply reply = await GetReplyObject(input);

            if (reply.clever_accuracy > 90)
            {
                return(reply.clever_output);
            }
            else
            {
                return(reply.output);
            }
        }
Exemplo n.º 2
0
        private async Task <CleverbotReply> GetReplyObject(string input)
        {
            HttpWebResponse Reply = await WebConnection.MakeRequest(new GetQuery($"{CLEVERBOTENDPOINT}/getreply?key={CleverbotConnection.Token}&input={input}&cs={Conversation ?? ""}", null));

            string jsonReply;

            using (StreamReader reader = new StreamReader(Reply.GetResponseStream()))
            {
                jsonReply = await reader.ReadToEndAsync();
            }
            CleverbotReply output = JsonConvert.DeserializeObject <CleverbotReply>(jsonReply);

            Conversation = output.cs;
            return(output);
        }