使用MicrosoftBot的FormBuilder跳过确认步骤
在填写表格之前我不需要任何确认。 但是,在FormBuilder类的以下Build()方法中有一个确认(“这是你的选择吗?\ n { }”)*。
public IForm Build() { if (!_form._steps.Any((step) => step.Type == StepType.Field)) { var paths = new List(); FormBuilder.FieldPaths(typeof(T), "", paths); IFormBuilder builder = this; foreach (var path in paths) { builder.Field(new FieldReflector(path)); } builder.Confirm("Is this your selection?\n{*}"); } Validate(); return this._form; }
在调用build之后,有什么办法可以从生成的Form中删除这一步吗?
var form = new FormBuilder() .OnCompletionAsync(async (context, state) => { await context.PostAsync("L'exercice est maintenant terminé. A bientot !"); }) .Build();
只需使用带有ActiveDelegate
参数的重载并使方法处理程序返回false
然后就不会显示确认消息。
return new FormBuilder() .AddRemainingFields() .Confirm("No verification will be shown", state => false) .Message("L'exercice est maintenant terminé. A bientot !") .Build();
要发送消息,您只需使用流畅的方法Message
。
您可以在FormBuilder上使用.AddRemainingFields()。 它不会要求任何确认。 。当您要为任何特定字段添加自定义确认消息时,应使用确认。