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); } }
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); }