private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { if (_people == null) { _people = await PeopleService.GetPeopleLisAtAsync(); } var mess = await result as IMessageActivity; if (context.ConversationData.ContainsKey(Constants.LAST_PERSON_KEY)) { var lastPerson = context.ConversationData.GetValue <Person>(Constants.LAST_PERSON_KEY); var guessResult = _people.FindByName(mess.Text); if (guessResult.Count > 3 && guessResult.Contains(lastPerson, new PersonComparer())) { await context.PostAsync("That is too generic. Try again."); context.Wait(MessageReceivedAsync); } else if (guessResult.Contains(lastPerson, new PersonComparer())) { // správná odpověď TelemetryService.SendTelemetry(new TelemetryModel("correct", lastPerson.Name)); await context.PostAsync("✔️ Correct!"); // zvednout skóre if (context.ConversationData.ContainsKey(Constants.SECOND_CHANCE)) { await context.PostAsync("That's **0.5** points for you."); await Utils.ChangeScoreAsync(context, 0.5); context.ConversationData.RemoveValue(Constants.SECOND_CHANCE); } else { await context.PostAsync("That's **2** points for you."); await Utils.ChangeScoreAsync(context, 2); } // DEBUG //context.Done(1.0); //return; // zobrazit další await GoNext(context); } else { // špatná odpověď - dáme nápovědu, pokud už nejsme v nápovědě :) TelemetryService.SendTelemetry(new TelemetryModel("incorrect", lastPerson.Name)); if (context.ConversationData.ContainsKey(Constants.SECOND_CHANCE)) { await context.PostAsync($"❌ That is not correct. Let's try another speaker."); context.ConversationData.RemoveValue(Constants.SECOND_CHANCE); await GoNext(context); } else { await context.PostAsync("Not correct. I'll give you a hint. But it will be for less points. This person's name is one of those:"); var msg = context.MakeMessage(); msg.Attachments.Add(PrepareButtonsCard(_people.GetRandomPeople(lastPerson, 5).Select(p => p.Name).ToArray()).ToAttachment()); await context.PostAsync(msg); context.ConversationData.SetValue(Constants.SECOND_CHANCE, "true"); context.Wait(MessageReceivedAsync); } } } else { await GoNext(context); } }