Comparing version 0.2.2 to 0.2.3
@@ -15,2 +15,3 @@ import { IChatInput } from './Chat'; | ||
text(promptKey: string, text: string, action: Action<S>): void; | ||
choicePrompt(promptKey: string, text: string, choices: string[], action: Action<S>): PromptStuff<S>; | ||
choice(promptKey: string, text: string, choices: string[], action: Action<S>): void; | ||
@@ -17,0 +18,0 @@ confirm(promptKey: string, text: string, action: Action<S>): void; |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,5 +37,5 @@ var Rules_1 = require("./Rules"); | ||
}; | ||
Prompt.prototype.choice = function (promptKey, text, choices, action) { | ||
Prompt.prototype.choicePrompt = function (promptKey, text, choices, action) { | ||
var _this = this; | ||
this.add(promptKey, { | ||
return { | ||
matcher: function (input) { return choices.find(function (choice) { return choice.toLowerCase() === input.text.toLowerCase(); }); }, | ||
@@ -48,6 +56,13 @@ action: action, | ||
} | ||
}); | ||
}; | ||
}; | ||
Prompt.prototype.choice = function (promptKey, text, choices, action) { | ||
this.add(promptKey, this.choicePrompt(promptKey, text, choices, action)); | ||
}; | ||
Prompt.prototype.confirm = function (promptKey, text, action) { | ||
return this.choice(promptKey, text, ['Yes', 'No'], action); | ||
var choice = this.choicePrompt(promptKey, text, ['Yes', 'No'], action); | ||
this.add(promptKey, __assign({}, choice, { matcher: function (input) { | ||
var args = choice.matcher(input); | ||
return args !== undefined && args; | ||
} })); | ||
}; | ||
@@ -54,0 +69,0 @@ Prompt.prototype.rule = function () { |
{ | ||
"name": "prague", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "experimental Rx-based bot technology", | ||
@@ -5,0 +5,0 @@ "main": "dist/prague.js", |
@@ -68,4 +68,4 @@ import { CardAction, IChatInput, Activity } from './Chat'; | ||
choice(promptKey: string, text: string, choices: string[], action: Action<S>) { | ||
this.add(promptKey, { | ||
choicePrompt(promptKey: string, text: string, choices: string[], action: Action<S>): PromptStuff<S> { | ||
return { | ||
matcher: (input) => choices.find(choice => choice.toLowerCase() === input.text.toLowerCase()), | ||
@@ -86,7 +86,18 @@ action, | ||
} | ||
}); | ||
}; | ||
} | ||
choice(promptKey: string, text: string, choices: string[], action: Action<S>) { | ||
this.add(promptKey, this.choicePrompt(promptKey, text, choices, action)); | ||
} | ||
confirm(promptKey: string, text: string, action: Action<S>) { | ||
return this.choice(promptKey, text, ['Yes', 'No'], action); | ||
const choice = this.choicePrompt(promptKey, text, ['Yes', 'No'], action); | ||
this.add(promptKey, { | ||
... choice, | ||
matcher: (input) => { | ||
const args: string = choice.matcher(input); | ||
return args !== undefined && args; | ||
} | ||
}); | ||
} | ||
@@ -93,0 +104,0 @@ |
Sorry, the diff of this file is not supported yet
64150
1199