botbuilder
Advanced tools
Comparing version 3.8.0-beta2 to 3.8.0-beta3
@@ -15,3 +15,4 @@ "use strict"; | ||
webchat: 'webchat', | ||
console: 'console' | ||
console: 'console', | ||
cortana: 'cortana' | ||
}; | ||
@@ -44,2 +45,3 @@ function supportsKeyboards(session, buttonCnt) { | ||
case exports.channels.webchat: | ||
case exports.channels.cortana: | ||
return (buttonCnt <= 100); | ||
@@ -51,2 +53,15 @@ default: | ||
exports.supportsCardActions = supportsCardActions; | ||
function hasMessageFeed(session) { | ||
switch (getChannelId(session)) { | ||
case exports.channels.cortana: | ||
return false; | ||
default: | ||
return true; | ||
} | ||
} | ||
exports.hasMessageFeed = hasMessageFeed; | ||
function maxActionTitleLength(session) { | ||
return 20; | ||
} | ||
exports.maxActionTitleLength = maxActionTitleLength; | ||
function getChannelId(addressable) { | ||
@@ -53,0 +68,0 @@ var channelId; |
@@ -90,6 +90,20 @@ "use strict"; | ||
if (!err && choices) { | ||
var sendChoices = context.turns === 0; | ||
var listStyle = options.listStyle; | ||
if (listStyle === undefined || listStyle === null || listStyle === Prompt_1.ListStyle.auto) { | ||
if (Channel.supportsKeyboards(session, choices.length)) { | ||
var maxTitleLength_1 = 0; | ||
choices.forEach(function (choice) { | ||
var l = choice.action && choice.action.title ? choice.action.title.length : choice.value.length; | ||
if (l > maxTitleLength_1) { | ||
maxTitleLength_1 = l; | ||
} | ||
}); | ||
var supportsKeyboards = Channel.supportsKeyboards(session, choices.length); | ||
var supportsCardActions = Channel.supportsCardActions(session, choices.length); | ||
var maxActionTitleLength = Channel.maxActionTitleLength(session); | ||
var hasMessageFeed = Channel.hasMessageFeed(session); | ||
if (maxTitleLength_1 <= maxActionTitleLength && | ||
(supportsKeyboards || (!hasMessageFeed && supportsCardActions))) { | ||
listStyle = Prompt_1.ListStyle.button; | ||
sendChoices = true; | ||
} | ||
@@ -104,4 +118,3 @@ else { | ||
} | ||
var keyboardsOnly = context.turns > 0; | ||
msg = PromptChoice.formatMessage(session, listStyle, text, speak, choices, keyboardsOnly); | ||
msg = PromptChoice.formatMessage(session, listStyle, text, speak, sendChoices ? choices : null); | ||
} | ||
@@ -145,4 +158,3 @@ callback(err, msg); | ||
}; | ||
PromptChoice.formatMessage = function (session, listStyle, text, speak, choices, keyboardsOnly) { | ||
if (keyboardsOnly === void 0) { keyboardsOnly = false; } | ||
PromptChoice.formatMessage = function (session, listStyle, text, speak, choices) { | ||
var options = session.dialogData.options; | ||
@@ -188,25 +200,21 @@ var locale = session.preferredLocale(); | ||
case Prompt_1.ListStyle.inline: | ||
if (values_1.length > 0 && !keyboardsOnly) { | ||
txt += ' ('; | ||
values_1.forEach(function (v, index) { | ||
txt += connector_1 + (index + 1) + '. ' + v; | ||
if (index == (values_1.length - 2)) { | ||
var cid = index == 0 ? 'list_or' : 'list_or_more'; | ||
connector_1 = Prompt_1.Prompt.gettext(session, cid, consts.Library.system); | ||
} | ||
else { | ||
connector_1 = ', '; | ||
} | ||
}); | ||
txt += ')'; | ||
} | ||
txt += ' ('; | ||
values_1.forEach(function (v, index) { | ||
txt += connector_1 + (index + 1) + '. ' + v; | ||
if (index == (values_1.length - 2)) { | ||
var cid = index == 0 ? 'list_or' : 'list_or_more'; | ||
connector_1 = Prompt_1.Prompt.gettext(session, cid, consts.Library.system); | ||
} | ||
else { | ||
connector_1 = ', '; | ||
} | ||
}); | ||
txt += ')'; | ||
break; | ||
case Prompt_1.ListStyle.list: | ||
if (values_1.length > 0 && !keyboardsOnly) { | ||
txt += '\n\n '; | ||
values_1.forEach(function (v, index) { | ||
txt += connector_1 + (index + 1) + '. ' + v; | ||
connector_1 = '\n '; | ||
}); | ||
} | ||
txt += '\n\n '; | ||
values_1.forEach(function (v, index) { | ||
txt += connector_1 + (index + 1) + '. ' + v; | ||
connector_1 = '\n '; | ||
}); | ||
break; | ||
@@ -213,0 +221,0 @@ } |
@@ -34,2 +34,46 @@ "use strict"; | ||
}); | ||
_this.onFormatMessage(function (session, text, speak, callback) { | ||
var context = session.dialogData; | ||
var options = context.options; | ||
var hasMinValue = typeof options.minValue === 'number'; | ||
var hasMaxValue = typeof options.maxValue === 'number'; | ||
var hasIntegerOnly = options.integerOnly; | ||
if (context.turns > 0 && (hasMinValue || hasMaxValue || hasIntegerOnly)) { | ||
var errorPrompt = void 0; | ||
var context_1 = session.toRecognizeContext(); | ||
var top_2 = PromptRecognizers_1.PromptRecognizers.findTopEntity(PromptRecognizers_1.PromptRecognizers.recognizeNumbers(context_1)); | ||
if (top_2) { | ||
var value = top_2.entity; | ||
var bellowMin = hasMinValue && value < options.minValue; | ||
var aboveMax = hasMaxValue && value > options.maxValue; | ||
var notInteger = hasIntegerOnly && Math.floor(value) !== value; | ||
if (hasMinValue && hasMaxValue && (bellowMin || aboveMax)) { | ||
errorPrompt = 'number_range_error'; | ||
} | ||
else if (hasMinValue && bellowMin) { | ||
errorPrompt = 'number_minValue_error'; | ||
} | ||
else if (hasMaxValue && aboveMax) { | ||
errorPrompt = 'number_maxValue_error'; | ||
} | ||
else if (hasIntegerOnly && notInteger) { | ||
errorPrompt = 'number_integer_error'; | ||
} | ||
} | ||
if (errorPrompt) { | ||
var text_1 = Prompt_1.Prompt.gettext(session, errorPrompt, consts.Library.system); | ||
var msg = { text: session.gettext(text_1, options) }; | ||
if (speak) { | ||
msg.speak = Prompt_1.Prompt.gettext(session, speak); | ||
} | ||
callback(null, msg); | ||
} | ||
else { | ||
callback(null, null); | ||
} | ||
} | ||
else { | ||
callback(null, null); | ||
} | ||
}); | ||
_this.matches(consts.Intents.Repeat, function (session) { | ||
@@ -36,0 +80,0 @@ session.dialogData.turns = 0; |
@@ -85,3 +85,3 @@ "use strict"; | ||
(typeof options.maxValue !== 'number' || n <= options.maxValue) && | ||
(!options.intergerOnly || Math.floor(n) == n)) { | ||
(!options.integerOnly || Math.floor(n) == n)) { | ||
entities.push({ | ||
@@ -88,0 +88,0 @@ type: consts.Entities.Number, |
@@ -16,4 +16,8 @@ { | ||
"number_terms": "0=zero|1=one|2=two|3=three|4=four|5=five|6=six|7=seven|8=eight|9=nine|10=ten|11=eleven|12=twelve|13=thirteen|14=fourteen|15=fifteen|16=sixteen|17=seventeen|18=eighteen|19=nineteen|20=twenty", | ||
"number_ordinals": "1=1st,first|2=2nd,second|3=3rd,third|4=4th,fourth|5=5th,fifth|6=6th,sixth|7=7th,seventh|8=8th,eigth|9=9th,ninth|10=10th,tenth", | ||
"number_reverse_ordinals": "-1=last|-2=next to last,second to last,second from last|-3=third to last,third from last|-4=fourth to last,fourth from last|-5=fifth to last,fith from last" | ||
"number_ordinals": "1=1st,first|2=2nd,second|3=3rd,third|4=4th,fourth|5=5th,fifth|6=6th,sixth|7=7th,seventh|8=8th,eighth|9=9th,ninth|10=10th,tenth", | ||
"number_reverse_ordinals": "-1=last|-2=next to last,second to last,second from last|-3=third to last,third from last|-4=fourth to last,fourth from last|-5=fifth to last,fifth from last", | ||
"number_minValue_error": "The number you entered was below the minimum allowed value of %(minValue)d. Please enter a valid number.", | ||
"number_maxValue_error": "The number you entered was above the maximum allowed value of %(maxValue)d. Please enter a valid number.", | ||
"number_range_error": "The number you entered was outside the allowed range of %(minValue)d to %(maxValue)d. Please enter a valid number.", | ||
"number_integer_error": "The number you entered was not an integer. Please enter a number without a decimal mark." | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.", | ||
"version": "3.8.0-beta2", | ||
"version": "3.8.0-beta3", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
587606
12768