public Dictionary <string, object> Answer(string command) { Dictionary <string, object> responseProperties = new Dictionary <string, object>(); bool isEnd = false; var answers = replics.GetAnswersCollection(); if (command.ToLower() == "") { Q = QPart.hello; A = APart.hello; } else if (replics.GetAnswers(APart.end).Any(s => s.IndexOf(command.ToLower(), StringComparison.CurrentCultureIgnoreCase) > -1)) { A = APart.end; Q = QPart.end; isEnd = true; } else { A = APart.end; Q = QPart.error; isEnd = true; foreach (var key in answers.Keys) { if (answers[key].Any(s => s.IndexOf(command.ToLower(), StringComparison.CurrentCultureIgnoreCase) > -1)) { A = key; Q = replics.GetNextQuestion(A); break; } } } if (Q == QPart.status && A == APart.status) { responseProperties = GetCofeeStatus(); responseProperties["text"] += GetRandomQuestion(replics.GetQuestions(Q)); responseProperties["tts"] += (string)responseProperties["text"]; } else { responseProperties["text"] = GetRandomQuestion(replics.GetQuestions(Q)); responseProperties["tts"] = responseProperties["text"]; responseProperties["isEnd"] = isEnd; } return(responseProperties); }
public QPart GetNextQuestion(APart type) { return(dialogueSchema[type]); }
public string[] GetAnswers(APart type) { return(answerStorage[type]); }