Created
July 18, 2016 05:08
-
-
Save beachside-project/a1961f422507a66b5c9c4ae481d682e5 to your computer and use it in GitHub Desktop.
EchoCommandDialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Microsoft.Bot.Builder.Dialogs; | |
using System.Text.RegularExpressions; | |
namespace DialogDemo.Dialogs | |
{ | |
public class EchoCommandDialog | |
{ | |
public static readonly CommandDialog<object> dialog | |
= new CommandDialog<object>() | |
.On<bool>(new Regex("^reset"), | |
async (context, msg) => | |
{ | |
PromptDialog.Confirm(context, dialog.ResultHandler, DialogSampleUtil.GetConfirmMessage(nameof(EchoCommandDialog)), BotMessage.NotGetThat); | |
}, | |
async (context, result) => | |
{ | |
var confirm = await result; | |
if (confirm) | |
{ | |
DialogSampleUtil.ResetCount(context); | |
await context.PostAsync(BotMessage.ResetDone); | |
} | |
else | |
{ | |
await context.PostAsync(BotMessage.ResetCancelled); | |
} | |
}) | |
.OnDefault<object>(async (context, msg) => | |
{ | |
var count = DialogSampleUtil.IncrementCount(context); | |
var messageActivity = await msg; | |
await context.PostAsync(DialogSampleUtil.GetIncrementedMessage(count, messageActivity.Text)); | |
context.Wait(dialog.MessageReceived); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment