UNPKG

type2docfx

Version:

A tool to convert json format output from TypeDoc to universal reference model for DocFx to consume.

43 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const internal_1 = require("./internal"); /** * :package: **botbuilder-prompts** * * Creates a new prompt that asks the user to upload one or more attachments. * * **Usage Example:** * * ```JavaScript * const { createAttachmentPrompt } = require('botbuilder-prompts'); * * const imagePrompt = createAttachmentPrompt(async (context, values) => { * if (values && values.length > 0) { * for (let i = 0; i < values.length; i++) { * if (!values[i].contentType.startsWith('image')) { * await imagePrompt.prompt(context, `Only images are accepted.`); * return undefined; * } * } * } else { * await imagePrompt.prompt(context, `Please upload at least one image.`); * } * return values; * }); * ``` * @param O (Optional) type of result returned by the `recognize()` method. This defaults to an `attachment[]` but can be changed by the prompts custom validator. * @param validator (Optional) validator for providing additional validation logic or customizing the prompt sent to the user when invalid. */ function createAttachmentPrompt(validator) { return { prompt: function prompt(context, prompt, speak) { return internal_1.sendPrompt(context, prompt, speak); }, recognize: function recognize(context) { const values = context.activity ? context.activity.attachments : undefined; return Promise.resolve(validator ? validator(context, values) : values); } }; } exports.createAttachmentPrompt = createAttachmentPrompt; //# sourceMappingURL=attachmentPrompt.js.map