private async Task ReturnPlanAsync(IDialogContext context, IAwaitable <string> argument) { var choice = await argument; var plan = new BigBangTheoryClient().GetPlan(choice); if (plan != null) { await context.PostAsync($"If today is {choice} you should {plan}"); } else { await context.PostAsync($"Sorry, {choice} isn't a day of my week"); } ShowOptions(context); }
private async Task FriendSelectedAsync(IDialogContext context, IAwaitable <string> argument) { var choice = await argument; var character = new BigBangTheoryClient().GetCharacter(choice); if (character != null) { await context.PostAsync(character.ToMessage(context)); } else { await context.PostAsync($"Sorry, {choice} isn't in my friends list"); } ShowOptions(context); }
public async Task Plans(IDialogContext context, LuisResult result) { string datetime = string.Empty; EntityRecommendation dateEntRec; if (result.TryFindEntity("builtin.datetime.date", out dateEntRec)) { datetime = dateEntRec.Resolution["date"]; } else if (result.TryFindEntity("builtin.datetime.time", out dateEntRec)) { datetime = dateEntRec.Resolution["time"]; } var dayOfWeek = datetime.GetDayOfWeek(); var plan = new BigBangTheoryClient().GetPlan(dayOfWeek.ToString()); await context.PostAsync($"On a {dayOfWeek} you should {plan} "); context.Wait(MessageReceived); }
public async Task Friends(IDialogContext context, LuisResult result) { var client = new BigBangTheoryClient(); // Did we get a friend name? EntityRecommendation friendEntRec; if (result.TryFindEntity("Friend", out friendEntRec)) { // We got a name string friend = friendEntRec.Entity; var character = client.GetCharacter(friend); if (character != null) { // We know the friend await context.PostAsync($"This is what I can tell you about {character.Name}"); await context.PostAsync(character.ToMessage(context)); } else { // We don't know the friend await context.PostAsync($"Sorry, {friend} isn't in my friends list"); var characters = client.GetAllCharacters(); await context.PostAsync(characters.ToMessage(context)); } } else { // We weren't provided with any friend name await context.PostAsync($"Here are some of my friends"); var characters = client.GetAllCharacters(); await context.PostAsync(characters.ToMessage(context)); } context.Wait(MessageReceived); }