Example #1
0
        public async Task StartAsync(IDialogContext context)
        {
            System.Threading.Thread.Sleep(2000);
            await context.PostAsync($"{FitBotResponses.UppercaseFirst(this.name)}, what is your height in inches?");

            context.Wait(this.MessageReceivedAsync);
        }
Example #2
0
        private async Task ResumeAfterWeightDialog(IDialogContext context, IAwaitable <int> result)
        {
            try
            {
                this.weight  = await result;
                heightInFeet = (this.height) / 12;

                await context.PostAsync($"Name: { FitBotResponses.UppercaseFirst(this.name) } \nAge: {age} yrs\nHeight: {Math.Round(heightInFeet, 2)} ft \n Weight: {weight} lbs");

                System.Threading.Thread.Sleep(1000);
                await context.PostAsync(FitBotResponses.calcBMIOptsArray[rnd.Next(FitBotResponses.calcBMIOptsArray.Length)]);

                System.Threading.Thread.Sleep(2000);

                BMI        = ((this.weight / this.height) / this.height) * 703;
                roundedBMI = (Math.Round(BMI, 2));


                await context.PostAsync($"Current BMI: {roundedBMI.ToString()}");

                System.Threading.Thread.Sleep(2000);


                //BMI Standards: Underweight -> Normalweight -> Overweight -> Heavyweight
                if (roundedBMI <= 18.5)
                {
                    await context.PostAsync($"With a BMI of {roundedBMI}, you are considered underweight.");
                }
                else if (roundedBMI >= 18.5 && roundedBMI <= 24.5)
                {
                    await context.PostAsync($"With a BMI of {roundedBMI}, you are considered normal weight.");
                }
                else if (roundedBMI >= 25 && roundedBMI <= 29.9)
                {
                    await context.PostAsync($"With a BMI of {roundedBMI}, you are considered overweight.");
                }
                else
                {
                    await context.PostAsync("With a BMI over 30, you are considered heavyweight, open a can of whoop ass.");
                }

                System.Threading.Thread.Sleep(5000);
            }
            catch (TooManyAttemptsException)
            {
                await context.PostAsync("I'm sorry, I'm having issues understanding. Let's try that again.");
            }
            finally
            {
                await this.StartAsync(context);
            }
        }
Example #3
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            string nameResponseArray = FitBotResponses.nameResponseOptsArray[rnd.Next(FitBotResponses.nameResponseOptsArray.Length)];

            var message = await result;

            if ((message.Text != null) && (message.Text.Trim().Length > 0))
            {
                System.Threading.Thread.Sleep(2000);
                await context.PostAsync($"{ FitBotResponses.UppercaseFirst(message.Text) }, {nameResponseArray}");

                context.Done(message.Text);
            }
        }