Exemplo n.º 1
0
        private async Task ResumeAfterOptionSelected(IDialogContext context, IAwaitable <string> result)
        {
            var option = await result;

            if (option == null)
            {
                context.Done <object>(null);
                return;
            }

            if (option.Equals(Resources.HelpDialog_start_over, StringComparison.OrdinalIgnoreCase))
            {
                context.Call(dialogFactory.Create <IDialog <object> >(), null);
                return;
            }

            if (option.Equals(Resources.HelpDialog_connect_operator, StringComparison.OrdinalIgnoreCase))
            {
                context.Call(dialogFactory.Create <HandoverDialog>(), null);
                return;
            }

            if (option.Equals(Resources.HelpDialog_edit_details, StringComparison.OrdinalIgnoreCase))
            {
                context.Call(dialogFactory.Create <EditDetailsDialog, Person>(person), OnPersonalDetailsCorrected);
                return;
            }

            await StartAsync(context);
        }
Exemplo n.º 2
0
 public async Task StartAsync(IDialogContext context)
 {
     PromptDialog.Choice(context, async(dialogContext, result) =>
     {
         var choice = await result;
         Enum.TryParse <DebugOptions>(choice, out var selected);
         var dialog = dialogFactory.Create <MluviiDialog, DebugOptions>(selected);
         dialogContext.Call(dialog, null);
     },
                         new [] { "GotoFinalConfirmation", "GotoOperatorSearch", "GotoMap" },
                         "DEBUG MENU");
 }
Exemplo n.º 3
0
        private async Task OnSingleOperatorConfirmed(IDialogContext context, IAwaitable <string> result, string operatorName)
        {
            try
            {
                await result;
            }
            catch (TooManyAttemptsException)
            {
                context.Call(dialogFactory.Create <HelpDialog, bool>(false), null);
                return;
            }

            var choice = await result;

            if (choice.ToLower() == "mluvit")
            {
                await OnOperatorSelected(context, new AwaitableFromItem <string>(operatorName));
            }
            else
            {
                await OnOperatorSelected(context, new AwaitableFromItem <string>(Resources.OperatorSelection_not_interesed));
            }
        }
Exemplo n.º 4
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            try
            {
                await result;
            }
            catch (TooManyAttemptsException)
            {
                context.Call(dialogFactory.Create <HelpDialog, bool>(false), null);
            }

            var message = await result;

            //Some bug in PromptDialog.Choice causes message.Type to be null
            if (message.Text == null) //message.Type != ActivityTypes.Message)
            {
                await StartAsync(context);

                return;
            }

            if (conversationReference == null)
            {
                conversationReference = message.ToConversationReference();
            }

            if (debugOptions != DebugOptions.None)
            {
                await DebugMenu(context);

                return;
            }

            var lower = message.Text.ToLower();

            if (lower.Contains("produkt") || lower.Contains("1") || lower.Contains("zájem") || lower.Contains("zajem") || lower.Contains("koupit"))
            {
                await context.SayAsync("Děkuji, nyní bych od Vás potřeboval několik údajů:");

                OnProductInterestSelected(context);
                return;
            }

            if (lower.Contains("dotaz") || lower.Contains("2") || lower.Contains("pouze") || lower.Contains("operator") || lower.Contains("operátor") || lower.Contains("člověk") || lower.Contains("clovek"))
            {
                await CheckAvailableOperators(context);

                return;
            }

            StartOver(context);
        }
Exemplo n.º 5
0
        private async Task ResumeAfterOptionSelected(IDialogContext context, IAwaitable <string> result)
        {
            try
            {
                var option = await result;

                if (option == null)
                {
                    context.Done(person);
                    return;
                }

                if (option.Equals(Resources.EditDetailsDialog_option_address, StringComparison.OrdinalIgnoreCase))
                {
                    var locationDialog = dialogFactory.Create <LocationDialog>(
                        new Dictionary <string, object>
                    {
                        { "channelId", context.Activity.ChannelId }
                    });

                    context.Call(locationDialog, OnAddressChanged);
                    return;
                }

                if (option.Equals(Resources.EditDetailsDialog_option_name, StringComparison.OrdinalIgnoreCase))
                {
                    person.FirstName = null;
                    person.LastName  = null;
                }

                if (option.Equals(Resources.EditDetailsDialog_option_email, StringComparison.OrdinalIgnoreCase))
                {
                    person.Email = null;
                }

                if (option.Equals(Resources.EditDetailsDialog_option_phone, StringComparison.OrdinalIgnoreCase))
                {
                    person.Phone = null;
                }

                var form = new FormDialog <Person>(person, Person.BuildForm, FormOptions.PromptInStart);
                context.Call(form, OnPersonDetailsChanged);
            }
            catch (TooManyAttemptsException)
            {
                await StartAsync(context);
            }
        }
Exemplo n.º 6
0
        public async Task PostAsync(IActivity item, object state, CancellationToken token)
        {
            var message = item as IMessageActivity;

            if (message != null)
            {
                var DebugDialog = dialogFactory.Create <DebugDialog>();

                // wrap it with an additional dialog that will restart the wait for
                // messages from the user once the child dialog has finished
                var interruption = DebugDialog.Void <object, IMessageActivity>();

                // put the interrupting dialog on the stack
                task.Call(interruption, null);

                // start running the interrupting dialog
                await task.PollAsync(token);
            }
        }