Exemple #1
0
        private void PromptForNumber(IDialogContext context)
        {
            var promptDialog = new PromptDialog.PromptInt64(
                promptOptions: new PromptOptions <long>(
                    prompt: "Please pick a number between one and ten (hint: UnitX).",
                    retry: "Sorry, I didn't get that. Please enter a number between one and ten.",
                    tooManyAttempts: "Too many attempts. I'm ending this conversation.",
                    promptStyler: new PromptStyler(PromptStyle.None)
                    ),
                min: 1,
                max: 10);

            context.Call(promptDialog, ResumeAfterNumberEntered);
        }
Exemple #2
0
        private async Task DiceChoiceReceivedAsync(IDialogContext context, IAwaitable <string> result)
        {
            GameData game;

            if (context.UserData.TryGetValue <GameData>(Utils.GameDataKey, out game))
            {
                int sides;
                if (int.TryParse(await result, out sides))
                {
                    game.Sides = sides;
                    context.UserData.SetValue <GameData>(Utils.GameDataKey, game);
                }

                var promptText = string.Format(Resources.ChooseCount, sides);

                // TODO: When supported, update to pass Min and Max paramters
                var promptOption = new PromptOptions <long>(promptText, speak: SSMLHelper.Speak(Utils.RandomPick(Resources.ChooseCountSSML)));

                var prompt = new PromptDialog.PromptInt64(promptOption, min: 1, max: 100);
                context.Call <long>(prompt, this.DiceNumberReceivedAsync);
            }
        }