使用MicrosoftBot的FormBuilder跳过确认步骤

Ama*_*ury 3 c# botframework

在填写表格之前,我不需要任何确认.但是,在FormBuilder类的以下Build()方法中有一个Confirm("这是你的选择吗?\n { }")*.

    public IForm<T> Build()
    {
        if (!_form._steps.Any((step) => step.Type == StepType.Field))
        {
            var paths = new List<string>();
            FormBuilder<T>.FieldPaths(typeof(T), "", paths);
            IFormBuilder<T> builder = this;
            foreach (var path in paths)
            {
                builder.Field(new FieldReflector<T>(path));
            }
            builder.Confirm("Is this your selection?\n{*}");
        }
        Validate();
        return this._form;
    }
Run Code Online (Sandbox Code Playgroud)

在调用build之后,有什么办法可以从生成的Form中删除这一步吗?

            var form =  new FormBuilder<QuestionYourThinking>()
            .OnCompletionAsync(async (context, state) =>
            {
                await context.PostAsync("L'exercice est maintenant terminé. A bientot !");
            })
            .Build();
Run Code Online (Sandbox Code Playgroud)

Cod*_*und 7

只需使用带ActiveDelegate参数的重载并使方法处理程序返回,false然后就不会显示确认消息.

return new FormBuilder<QuestionYourThinking>()
    .AddRemainingFields()
    .Confirm("No verification will be shown", state => false)
    .Message("L'exercice est maintenant terminé. A bientot !")
    .Build();
Run Code Online (Sandbox Code Playgroud)

要发送消息,您只需使用流畅的方法即可Message.